Merge pull request #716 from gradido/gdt-list-pagination

feat: Add Pagination Buttons to GDT Transaction List
This commit is contained in:
Moriz Wahl 2021-08-11 17:45:59 +02:00 committed by GitHub
commit 92549faba4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View File

@ -110,7 +110,6 @@ export default {
data() { data() {
return { return {
currentPage: 1, currentPage: 1,
startDecay: 0,
} }
}, },
props: { props: {

View File

@ -111,23 +111,53 @@
<!-- Collaps End --> <!-- Collaps End -->
</b-list-group-item> </b-list-group-item>
</b-list-group> </b-list-group>
<pagination-buttons
v-if="transactionGdtCount > pageSize"
:has-next="hasNext"
:has-previous="hasPrevious"
:total-pages="totalPages"
:current-page="currentPage"
@show-next="showNext"
@show-previous="showPrevious"
></pagination-buttons>
</div> </div>
</template> </template>
<script> <script>
import communityAPI from '../../../apis/communityAPI' import communityAPI from '../../../apis/communityAPI'
import PaginationButtons from '../../../components/PaginationButtons'
export default { export default {
name: 'gdt-transaction-list', name: 'gdt-transaction-list',
components: {
PaginationButtons,
},
data() { data() {
return { return {
transactionsGdt: { default: () => [] }, transactionsGdt: { default: () => [] },
transactionGdtCount: { type: Number, default: 0 }, transactionGdtCount: { type: Number, default: 0 },
currentPage: 1,
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() {
const result = await communityAPI.transactionsgdt(this.$store.state.sessionId) const result = await communityAPI.transactionsgdt(
this.$store.state.sessionId,
this.currentPage,
this.pageSize,
)
if (result.success) { if (result.success) {
this.transactionsGdt = result.result.data.gdtEntries this.transactionsGdt = result.result.data.gdtEntries
this.transactionGdtCount = result.result.data.count this.transactionGdtCount = result.result.data.count
@ -135,6 +165,16 @@ export default {
this.$toasted.error(result.result.message) this.$toasted.error(result.result.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()