mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
refactoring is working
This commit is contained in:
parent
7ede572f4b
commit
4f5ca22363
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="pagination-buttons">
|
<div class="pagination-buttons" v-if="totalRows > perPage">
|
||||||
<b-row class="m-4">
|
<b-row class="m-4">
|
||||||
<b-col class="text-right">
|
<b-col class="text-right">
|
||||||
<b-button class="previous-page" :disabled="!hasPrevious" @click="$emit('show-previous')">
|
<b-button class="previous-page" :disabled="!hasPrevious" @click="currentValue--">
|
||||||
<b-icon icon="chevron-left" variant="primary"></b-icon>
|
<b-icon icon="chevron-left" variant="primary"></b-icon>
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-col>
|
</b-col>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
<p class="text-center pt-2">{{ value }} / {{ 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="currentValue++">
|
||||||
<b-icon icon="chevron-right" variant="primary"></b-icon>
|
<b-icon icon="chevron-right" variant="primary"></b-icon>
|
||||||
</b-button>
|
</b-button>
|
||||||
</b-col>
|
</b-col>
|
||||||
@ -18,35 +18,36 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'PaginationButtons',
|
name: 'PaginationButtons',
|
||||||
props: {
|
props: {
|
||||||
totalRows: { type: Number, required: true },
|
totalRows: { type: Number, required: true },
|
||||||
pageSize: { type: Number, required: true },
|
perPage: { type: Number, required: true },
|
||||||
value: { type: Number, , required: true },
|
value: { type: Number, required: true },
|
||||||
},
|
},
|
||||||
computed: {
|
data() {
|
||||||
hasNext() {
|
return {
|
||||||
return this.value * this.pageSize < this.totalCount
|
currentValue: { type: Number, default: 1 },
|
||||||
},
|
}
|
||||||
hasPrevious() {
|
},
|
||||||
return this.value > 1
|
computed: {
|
||||||
},
|
hasNext() {
|
||||||
totalPages() {
|
return this.value * this.perPage < this.totalRows
|
||||||
return Math.ceil(this.totalCount / this.pageSize)
|
},
|
||||||
},
|
hasPrevious() {
|
||||||
},
|
return this.value > 1
|
||||||
methods: {
|
},
|
||||||
showNext() {
|
totalPages() {
|
||||||
this.value++
|
return Math.ceil(this.totalRows / this.perPage)
|
||||||
this.updateGdt()
|
},
|
||||||
window.scrollTo(0, 0)
|
},
|
||||||
},
|
created() {
|
||||||
showPrevious() {
|
this.currentValue = this.value
|
||||||
this.value--
|
},
|
||||||
this.updateGdt()
|
watch: {
|
||||||
window.scrollTo(0, 0)
|
currentValue() {
|
||||||
},
|
if (this.currentValue !== this.value) this.$emit('input', this.currentValue)
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -84,13 +84,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<pagination-buttons
|
<pagination-buttons
|
||||||
v-if="showPagination && transactionCount > pageSize"
|
v-model="currentPage"
|
||||||
:has-next="hasNext"
|
:per-page="pageSize"
|
||||||
:has-previous="hasPrevious"
|
:total-rows="transactionCount"
|
||||||
:total-pages="totalPages"
|
|
||||||
:current-page="currentPage"
|
|
||||||
@show-next="showNext"
|
|
||||||
@show-previous="showPrevious"
|
|
||||||
></pagination-buttons>
|
></pagination-buttons>
|
||||||
<div v-if="transactions.length === 0" class="mt-4 text-center">
|
<div v-if="transactions.length === 0" class="mt-4 text-center">
|
||||||
<span>{{ $t('transaction.nullTransactions') }}</span>
|
<span>{{ $t('transaction.nullTransactions') }}</span>
|
||||||
@ -128,23 +124,6 @@ export default {
|
|||||||
transactionCount: { type: Number, default: 0 },
|
transactionCount: { type: Number, default: 0 },
|
||||||
showPagination: { type: Boolean, default: false },
|
showPagination: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
timestamp: {
|
|
||||||
immediate: true,
|
|
||||||
handler: 'updateTransactions',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
hasNext() {
|
|
||||||
return this.currentPage * this.pageSize < this.transactionCount
|
|
||||||
},
|
|
||||||
hasPrevious() {
|
|
||||||
return this.currentPage > 1
|
|
||||||
},
|
|
||||||
totalPages() {
|
|
||||||
return Math.ceil(this.transactionCount / this.pageSize)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
updateTransactions() {
|
updateTransactions() {
|
||||||
this.$emit('update-transactions', {
|
this.$emit('update-transactions', {
|
||||||
@ -165,15 +144,14 @@ export default {
|
|||||||
throwError(msg) {
|
throwError(msg) {
|
||||||
throw new Error(msg)
|
throw new Error(msg)
|
||||||
},
|
},
|
||||||
showNext() {
|
},
|
||||||
this.currentPage++
|
watch: {
|
||||||
|
currentPage() {
|
||||||
this.updateTransactions()
|
this.updateTransactions()
|
||||||
window.scrollTo(0, 0)
|
|
||||||
},
|
},
|
||||||
showPrevious() {
|
timestamp: {
|
||||||
this.currentPage--
|
immediate: true,
|
||||||
this.updateTransactions()
|
handler: 'updateTransactions',
|
||||||
window.scrollTo(0, 0)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,12 +28,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<pagination-buttons
|
<pagination-buttons
|
||||||
v-if="transactionGdtCount > pageSize"
|
|
||||||
v-model="currentPage"
|
v-model="currentPage"
|
||||||
:per-page="pageSize"
|
:per-page="pageSize"
|
||||||
:total-rows="transactionGdtCount"
|
:total-rows="transactionGdtCount"
|
||||||
@show-next="showNext"
|
|
||||||
@show-previous="showPrevious"
|
|
||||||
></pagination-buttons>
|
></pagination-buttons>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -73,25 +70,21 @@ export default {
|
|||||||
} = result
|
} = result
|
||||||
this.transactionsGdt = listGDTEntries.gdtEntries
|
this.transactionsGdt = listGDTEntries.gdtEntries
|
||||||
this.transactionGdtCount = listGDTEntries.count
|
this.transactionGdtCount = listGDTEntries.count
|
||||||
|
window.scrollTo(0, 0)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.error(error.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
showNext() {
|
|
||||||
this.currentPage++
|
|
||||||
this.updateGdt()
|
|
||||||
window.scrollTo(0, 0)
|
|
||||||
},
|
|
||||||
showPrevious() {
|
|
||||||
this.currentPage--
|
|
||||||
this.updateGdt()
|
|
||||||
window.scrollTo(0, 0)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateGdt()
|
this.updateGdt()
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
currentPage() {
|
||||||
|
this.updateGdt()
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user