-
{{ $t('transaction.nullTransactions') }}
@@ -128,29 +125,13 @@ export default {
transactionCount: { type: Number, default: 0 },
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: {
updateTransactions() {
this.$emit('update-transactions', {
firstPage: this.currentPage,
items: this.pageSize,
})
+ window.scrollTo(0, 0)
},
getProperties(givenType) {
const type = iconsByType[givenType]
@@ -165,15 +146,14 @@ export default {
throwError(msg) {
throw new Error(msg)
},
- showNext() {
- this.currentPage++
+ },
+ watch: {
+ currentPage() {
this.updateTransactions()
- window.scrollTo(0, 0)
},
- showPrevious() {
- this.currentPage--
- this.updateTransactions()
- window.scrollTo(0, 0)
+ timestamp: {
+ immediate: true,
+ handler: 'updateTransactions',
},
},
}
diff --git a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js
index a3c737d10..8d06de5c6 100644
--- a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js
+++ b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js
@@ -46,6 +46,9 @@ const apolloMock = jest.fn().mockResolvedValue({
})
const toastErrorMock = jest.fn()
+const windowScrollToMock = jest.fn()
+
+window.scrollTo = windowScrollToMock
describe('GdtTransactionList', () => {
let wrapper
@@ -90,6 +93,10 @@ describe('GdtTransactionList', () => {
}),
)
})
+
+ it('scrolls to (0, 0) after API call', () => {
+ expect(windowScrollToMock).toBeCalledWith(0, 0)
+ })
})
describe('server returns error', () => {
@@ -105,5 +112,21 @@ describe('GdtTransactionList', () => {
expect(toastErrorMock).toBeCalledWith('Ouch!')
})
})
+
+ describe('change of currentPage', () => {
+ it('calls the API after currentPage changes', async () => {
+ jest.clearAllMocks()
+ wrapper.setData({ currentPage: 2 })
+ await wrapper.vm.$nextTick()
+ expect(apolloMock).toBeCalledWith(
+ expect.objectContaining({
+ variables: {
+ currentPage: 2,
+ pageSize: 25,
+ },
+ }),
+ )
+ })
+ })
})
})
diff --git a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue
index 1ad4ba13e..dde5e31e8 100644
--- a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue
+++ b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.vue
@@ -28,13 +28,9 @@
@@ -52,23 +48,12 @@ export default {
},
data() {
return {
- transactionsGdt: { default: () => [] },
+ transactionsGdt: [],
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: {
async updateGdt() {
this.$apollo
@@ -85,25 +70,21 @@ export default {
} = result
this.transactionsGdt = listGDTEntries.gdtEntries
this.transactionGdtCount = listGDTEntries.count
+ window.scrollTo(0, 0)
})
.catch((error) => {
this.$toasted.error(error.message)
})
},
- showNext() {
- this.currentPage++
- this.updateGdt()
- window.scrollTo(0, 0)
- },
- showPrevious() {
- this.currentPage--
- this.updateGdt()
- window.scrollTo(0, 0)
- },
},
mounted() {
this.updateGdt()
},
+ watch: {
+ currentPage() {
+ this.updateGdt()
+ },
+ },
}