mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
refactor: Pagination Buttons
This commit is contained in:
parent
6f28b257c5
commit
7ede572f4b
@ -7,7 +7,7 @@
|
|||||||
</b-button>
|
</b-button>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col cols="3">
|
<b-col cols="3">
|
||||||
<p class="text-center pt-2">{{ currentPage }} / {{ totalPages }}</p>
|
<p class="text-center pt-2">{{ value }} / {{ totalPages }}</p>
|
||||||
</b-col>
|
</b-col>
|
||||||
<b-col>
|
<b-col>
|
||||||
<b-button class="next-page" :disabled="!hasNext" @click="$emit('show-next')">
|
<b-button class="next-page" :disabled="!hasNext" @click="$emit('show-next')">
|
||||||
@ -21,10 +21,32 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'PaginationButtons',
|
name: 'PaginationButtons',
|
||||||
props: {
|
props: {
|
||||||
hasNext: { type: Boolean, default: false },
|
totalRows: { type: Number, required: true },
|
||||||
hasPrevious: { type: Boolean, default: false },
|
pageSize: { type: Number, required: true },
|
||||||
totalPages: { type: Number, default: 1 },
|
value: { type: Number, , required: true },
|
||||||
currentPage: { type: Number, default: 1 },
|
},
|
||||||
|
computed: {
|
||||||
|
hasNext() {
|
||||||
|
return this.value * this.pageSize < this.totalCount
|
||||||
|
},
|
||||||
|
hasPrevious() {
|
||||||
|
return this.value > 1
|
||||||
|
},
|
||||||
|
totalPages() {
|
||||||
|
return Math.ceil(this.totalCount / this.pageSize)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showNext() {
|
||||||
|
this.value++
|
||||||
|
this.updateGdt()
|
||||||
|
window.scrollTo(0, 0)
|
||||||
|
},
|
||||||
|
showPrevious() {
|
||||||
|
this.value--
|
||||||
|
this.updateGdt()
|
||||||
|
window.scrollTo(0, 0)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -29,10 +29,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<pagination-buttons
|
<pagination-buttons
|
||||||
v-if="transactionGdtCount > pageSize"
|
v-if="transactionGdtCount > pageSize"
|
||||||
:has-next="hasNext"
|
v-model="currentPage"
|
||||||
:has-previous="hasPrevious"
|
:per-page="pageSize"
|
||||||
:total-pages="totalPages"
|
:total-rows="transactionGdtCount"
|
||||||
:current-page="currentPage"
|
|
||||||
@show-next="showNext"
|
@show-next="showNext"
|
||||||
@show-previous="showPrevious"
|
@show-previous="showPrevious"
|
||||||
></pagination-buttons>
|
></pagination-buttons>
|
||||||
@ -58,17 +57,6 @@ export default {
|
|||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
hasNext() {
|
|
||||||
return this.currentPage * this.pageSize < this.transactionGdtCount
|
|
||||||
},
|
|
||||||
hasPrevious() {
|
|
||||||
return this.currentPage > 1
|
|
||||||
},
|
|
||||||
totalPages() {
|
|
||||||
return Math.ceil(this.transactionGdtCount / this.pageSize)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
async updateGdt() {
|
async updateGdt() {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user