Verified Commit 064db69e authored by Jakob Moser's avatar Jakob Moser
Browse files

Make pagination work again

parent e1c5b567
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -6,13 +6,11 @@ export default {
    view(vnode) {
        const elements = vnode.attrs.elements.toArray()
        const totalPages = Math.ceil(elements.length / ELEMENTS_PER_PAGE)
        const currentPageIndex = 0

        const startIndex = currentPageIndex * ELEMENTS_PER_PAGE
        const startIndex = (this.currentPageIndex || 0) * ELEMENTS_PER_PAGE
        return [
            elements.slice(startIndex, startIndex + ELEMENTS_PER_PAGE),
            // TODO Actually change the contents on page change
            m(PaginationControls, { currentPage: currentPageIndex + 1, totalPages, onPageChange: console.log })
            m(PaginationControls, { currentPage: (this.currentPageIndex || 0) + 1, totalPages, onPageChange: i => this.currentPageIndex = i-1 })
        ]
    }
}