Add pagination elements

This commit is contained in:
Jakob Moser 2025-11-13 19:48:09 +01:00
parent 7c6ba261f8
commit 6773d6d9bc
Signed by: jakob
GPG Key ID: 3EF2BA2851B3F53C

View File

@ -0,0 +1,16 @@
import PaginationControls from "./PaginationControls.js"
const ELEMENTS_PER_PAGE = 25
export default {
view(vnode) {
const elements = vnode.attrs.elements.toArray()
const totalPages = Math.ceil(elements.length / ELEMENTS_PER_PAGE)
const startIndex = (this.currentPageIndex || 0) * ELEMENTS_PER_PAGE
return [
elements.slice(startIndex, startIndex + ELEMENTS_PER_PAGE),
m(PaginationControls, { currentPage: (this.currentPageIndex || 0) + 1, totalPages, onPageChange: i => this.currentPageIndex = i - 1 })
]
}
}