Skip to content

Commit cffe109

Browse files
committed
Added prop to set page sizes on tiny paginate
1 parent 13672a7 commit cffe109

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/components/TinyPagination.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<a href="#" @click.prevent="nextPage">{{translation.next}}</a>
1212
</li>
1313
<li class="page-item">
14-
<select class="tiny-form-select" v-model="limit">
14+
<select class="tiny-form-select" v-model="currentLimit" @change="onLimitChange">
1515
<option
1616
v-for="(limit, index) in limits"
1717
:value="limit"
@@ -41,13 +41,18 @@ export default {
4141
},
4242
customClass: {
4343
type: String
44+
},
45+
limits: {
46+
type: Array,
47+
default () {
48+
return [10, 15, 20, 50, 100]
49+
}
4450
}
4551
},
4652
data () {
4753
return {
4854
currentPage: 1,
49-
limit: 10,
50-
limits: [10, 15, 20, 50, 100]
55+
currentLimit: 10
5156
}
5257
},
5358
created () {
@@ -58,7 +63,7 @@ export default {
5863
return Language.translations[this.lang]
5964
},
6065
totalPages () {
61-
return Math.ceil(this.total/this.limit)
66+
return Math.ceil(this.total/this.currentLimit)
6267
},
6368
titlePage () {
6469
return `${this.translation.title} ${this.currentPage}`
@@ -86,13 +91,21 @@ export default {
8691
if (this.currentPage > 1) {
8792
this.currentPage -= 1
8893
}
94+
},
95+
onLimitChange () {
96+
this.currentPage = 1
8997
}
9098
},
9199
watch: {
92100
currentPage (value) {
93101
this.$emit('tiny:change-page', {
94102
page: value
95103
})
104+
},
105+
currentLimit (value) {
106+
this.$emit('tiny:change-limit', {
107+
limit: value
108+
})
96109
}
97110
}
98111
}

0 commit comments

Comments
 (0)