Skip to content

Next release #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 19, 2018
Prev Previous commit
Next Next commit
Added prop to set page sizes on tiny paginate
  • Loading branch information
coderdiaz committed Feb 17, 2018
commit cffe1090abb8c8fb56c65d493652153b9e25b3f4
21 changes: 17 additions & 4 deletions src/components/TinyPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<a href="#" @click.prevent="nextPage">{{translation.next}}</a>
</li>
<li class="page-item">
<select class="tiny-form-select" v-model="limit">
<select class="tiny-form-select" v-model="currentLimit" @change="onLimitChange">
<option
v-for="(limit, index) in limits"
:value="limit"
Expand Down Expand Up @@ -41,13 +41,18 @@ export default {
},
customClass: {
type: String
},
limits: {
type: Array,
default () {
return [10, 15, 20, 50, 100]
}
}
},
data () {
return {
currentPage: 1,
limit: 10,
limits: [10, 15, 20, 50, 100]
currentLimit: 10
}
},
created () {
Expand All @@ -58,7 +63,7 @@ export default {
return Language.translations[this.lang]
},
totalPages () {
return Math.ceil(this.total/this.limit)
return Math.ceil(this.total/this.currentLimit)
},
titlePage () {
return `${this.translation.title} ${this.currentPage}`
Expand Down Expand Up @@ -86,13 +91,21 @@ export default {
if (this.currentPage > 1) {
this.currentPage -= 1
}
},
onLimitChange () {
this.currentPage = 1
}
},
watch: {
currentPage (value) {
this.$emit('tiny:change-page', {
page: value
})
},
currentLimit (value) {
this.$emit('tiny:change-limit', {
limit: value
})
}
}
}
Expand Down