Skip to content

Commit 5a21c78

Browse files
committed
feat: add toPage function to FeathersVuexPagination
1 parent c11a687 commit 5a21c78

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/FeathersVuexPagination.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default {
2222
},
2323
// eslint-disable-next-line
2424
setup(props, context) {
25-
// Total
25+
/**
26+
* The number of pages available based on the results returned in the latestQuery prop.
27+
*/
2628
const pageCount = computed(() => {
2729
const q = props.latestQuery
2830
if (q && q.response) {
@@ -31,7 +33,14 @@ export default {
3133
return 1
3234
}
3335
})
34-
// Current Page
36+
37+
/**
38+
* The `currentPage` is calculated based on the $limit and $skip values provided in
39+
* the v-model object.
40+
*
41+
* Setting `currentPage` to a new numeric value will emit the appropriate values out
42+
* the v-model. (using the default `input` event)
43+
*/
3544
const currentPage = computed({
3645
set(pageNumber: number) {
3746
if (pageNumber < 1) {
@@ -67,6 +76,9 @@ export default {
6776
function toEnd(): void {
6877
currentPage.value = pageCount.value
6978
}
79+
function toPage(pageNumber): void {
80+
currentPage.value = pageNumber
81+
}
7082

7183
function next(): void {
7284
currentPage.value++
@@ -85,6 +97,7 @@ export default {
8597
canNext: canNext.value,
8698
toStart,
8799
toEnd,
100+
toPage,
88101
prev,
89102
next
90103
})

0 commit comments

Comments
 (0)