From 17ba78cc012cb1c3abe6eb132d6e1228ed95a2d4 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 11:37:10 +0100 Subject: [PATCH 01/92] add query: listTransactionLinks --- frontend/src/graphql/queries.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 5887d585a..6f67deee8 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -143,3 +143,17 @@ export const queryTransactionLink = gql` } } ` + +export const listTransactionLinks = gql` + query($currentPage: Int = 1, $pageSize: Int = 5, $order: Order = DESC) { + listTransactionLinks(currentPage: $currentPage, pageSize: $pageSize, order: $order) { + amount + holdAvailableAmount + memo + code + createdAt + validUntil + redeemedAt + } + } +` From e5dc99dad60526ab6bc8c0867de4c4f262dcb631 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 11:38:35 +0100 Subject: [PATCH 02/92] add apollo funktion for query transactionLinkList --- frontend/src/components/GddTransactionList.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/GddTransactionList.vue b/frontend/src/components/GddTransactionList.vue index 9c7013ec5..da5f27add 100644 --- a/frontend/src/components/GddTransactionList.vue +++ b/frontend/src/components/GddTransactionList.vue @@ -43,7 +43,7 @@ From 83b1c4c9e19517bccd0e59ea8040888de07b6a18 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 15:55:23 +0100 Subject: [PATCH 11/92] change position from visible on collapse in TransactionLinksSummary.vue --- .../src/components/Transactions/TransactionLinksSummary.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Transactions/TransactionLinksSummary.vue b/frontend/src/components/Transactions/TransactionLinksSummary.vue index d10311e3a..dff7cff3a 100644 --- a/frontend/src/components/Transactions/TransactionLinksSummary.vue +++ b/frontend/src/components/Transactions/TransactionLinksSummary.vue @@ -1,9 +1,9 @@ From 81df36a3fb65b4133e8edcd9f74934135b2f0f22 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 17:15:47 +0100 Subject: [PATCH 14/92] ad function deleteLink and bvModal confirm --- .../TransactionLinks/TransactionLink.vue | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 966fc3f54..d6dfb84f0 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -18,7 +18,7 @@ {{ $moment(item.validUntil).fromNow() }} kopieren - löschen + löschen @@ -41,7 +41,8 @@ export default { }, }) .then((result) => { - console.log(result.data) + this.toastSuccess('Link gelöscht') + this.$emit('update-list-transaction-links') }) .catch((err) => { this.toastError(err.message) @@ -58,6 +59,16 @@ export default { this.toastError(this.$t('gdd_per_link.not-copied')) }) }, + deleteLink(id) { + this.$bvModal + .msgBoxConfirm('Den Link löschen?') + .then(() => { + this.deleteTransactionLink(id) + }) + .catch((err) => { + console.log(err) + }) + }, }, } From baf4f66604a0f7d220e0e653974512d1fd32c4c9 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 17:16:35 +0100 Subject: [PATCH 15/92] ad function updateListTransactionLinks on TransactionLinksSummary.vue --- .../Transactions/TransactionLinksSummary.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Transactions/TransactionLinksSummary.vue b/frontend/src/components/Transactions/TransactionLinksSummary.vue index dff7cff3a..c4496ed0d 100644 --- a/frontend/src/components/Transactions/TransactionLinksSummary.vue +++ b/frontend/src/components/Transactions/TransactionLinksSummary.vue @@ -24,7 +24,10 @@ - + @@ -69,7 +72,7 @@ export default { } }, methods: { - async listTransactionLinks() { + async updateListTransactionLinks() { this.$apollo .query({ query: listTransactionLinks, @@ -81,6 +84,7 @@ export default { }) .then((result) => { this.transactionLinks = result.data.listTransactionLinks + this.$emit('update-transactions') }) .catch((err) => { this.toastError(err.message) @@ -88,7 +92,7 @@ export default { }, }, created() { - this.listTransactionLinks() + this.updateListTransactionLinks() }, } From 9bd74cb1488bf76ed9bd0f7a150752fcd90b49f5 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 17:18:32 +0100 Subject: [PATCH 16/92] yarn lint --fix --- frontend/src/components/TransactionLinks/TransactionLink.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index d6dfb84f0..0ff13a1a0 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -65,9 +65,7 @@ export default { .then(() => { this.deleteTransactionLink(id) }) - .catch((err) => { - console.log(err) - }) + .catch(() => {}) }, }, } From 12f3a7ab4abe56cae81664757070db4508753088 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 15 Mar 2022 21:03:55 +0100 Subject: [PATCH 17/92] set up seed for transaction links --- backend/src/seeds/factory/transactionLink.ts | 21 +++++++++++++++++++ backend/src/seeds/index.ts | 7 +++++++ .../TransactionLinkInterface.ts | 5 +++++ backend/src/seeds/transactionLink/index.ts | 10 +++++++++ 4 files changed, 43 insertions(+) create mode 100644 backend/src/seeds/factory/transactionLink.ts create mode 100644 backend/src/seeds/transactionLink/TransactionLinkInterface.ts create mode 100644 backend/src/seeds/transactionLink/index.ts diff --git a/backend/src/seeds/factory/transactionLink.ts b/backend/src/seeds/factory/transactionLink.ts new file mode 100644 index 000000000..c1ea13915 --- /dev/null +++ b/backend/src/seeds/factory/transactionLink.ts @@ -0,0 +1,21 @@ +import { ApolloServerTestClient } from 'apollo-server-testing' +import { createTransactionLink } from '@/seeds/graphql/mutations' +import { login } from '@/seeds/graphql/queries' +import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface' + +export const transactionLinkFactory = async ( + client: ApolloServerTestClient, + transactionLink: TransactionLinkInterface, +): Promise => { + const { mutate, query } = client + + // login + await query({ query: login, variables: { email: transactionLink.email, password: 'Aa12345_' } }) + + const variables = { + amount: transactionLink.amount, + memo: transactionLink.memo, + } + + await mutate({ mutation: createTransactionLink, variables }) +} diff --git a/backend/src/seeds/index.ts b/backend/src/seeds/index.ts index 3943a63e0..37c9992a7 100644 --- a/backend/src/seeds/index.ts +++ b/backend/src/seeds/index.ts @@ -8,8 +8,10 @@ import { name, internet, random } from 'faker' import { users } from './users/index' import { creations } from './creation/index' +import { transactionLinks } from './transactionLink/index' import { userFactory } from './factory/user' import { creationFactory } from './factory/creation' +import { transactionLinkFactory } from './factory/transactionLink' import { entities } from '@entity/index' const context = { @@ -64,6 +66,11 @@ const run = async () => { await creationFactory(seedClient, creations[i]) } + // create Transaction Links + for (let i = 0; i < transactionLinks.length; i++) { + await transactionLinkFactory(seedClient, transactionLinks[i]) + } + await con.close() } diff --git a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts new file mode 100644 index 000000000..94b14992b --- /dev/null +++ b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts @@ -0,0 +1,5 @@ +export interface TransactionLinkInterface { + email: string + amount: number + memo: string +} diff --git a/backend/src/seeds/transactionLink/index.ts b/backend/src/seeds/transactionLink/index.ts new file mode 100644 index 000000000..cd952c47f --- /dev/null +++ b/backend/src/seeds/transactionLink/index.ts @@ -0,0 +1,10 @@ +import { TransactionLinkInterface } from './TransactionLinkInterface' + +export const transactionLinks: TransactionLinkInterface[] = [ + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: `Kein Trick, keine Zauberrei, +bei Gradidio sei dabei!`, + }, +] From 5b9463ca2a20b31278d99b7244d0fadd7058ee27 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 15 Mar 2022 21:24:44 +0100 Subject: [PATCH 18/92] seed deleted and outdated transaction links --- .../resolver/TransactionLinkResolver.ts | 2 +- backend/src/seeds/factory/transactionLink.ts | 22 ++++++++++ .../TransactionLinkInterface.ts | 2 + backend/src/seeds/transactionLink/index.ts | 42 +++++++++++++++++++ 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index 9e2af6111..32f30807b 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -29,7 +29,7 @@ export const transactionLinkCode = (date: Date): string => { const CODE_VALID_DAYS_DURATION = 14 -const transactionLinkExpireDate = (date: Date): Date => { +export const transactionLinkExpireDate = (date: Date): Date => { const validUntil = new Date(date) return new Date(validUntil.setDate(date.getDate() + CODE_VALID_DAYS_DURATION)) } diff --git a/backend/src/seeds/factory/transactionLink.ts b/backend/src/seeds/factory/transactionLink.ts index c1ea13915..665ae03f3 100644 --- a/backend/src/seeds/factory/transactionLink.ts +++ b/backend/src/seeds/factory/transactionLink.ts @@ -2,6 +2,9 @@ import { ApolloServerTestClient } from 'apollo-server-testing' import { createTransactionLink } from '@/seeds/graphql/mutations' import { login } from '@/seeds/graphql/queries' import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface' +import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver' +import { TransactionLink } from '@entity/TransactionLink' +import { User } from '@entity/User' export const transactionLinkFactory = async ( client: ApolloServerTestClient, @@ -18,4 +21,23 @@ export const transactionLinkFactory = async ( } await mutate({ mutation: createTransactionLink, variables }) + + if (transactionLink.createdAt || transactionLink.deletedAt) { + const user = await User.findOneOrFail({ where: { email: transactionLink.email } }) + const dbTransactionLink = await TransactionLink.findOneOrFail({ + where: { userId: user.id }, + order: { createdAt: 'DESC' }, + }) + + if (transactionLink.createdAt) { + dbTransactionLink.createdAt = transactionLink.createdAt + dbTransactionLink.validUntil = transactionLinkExpireDate(transactionLink.createdAt) + await dbTransactionLink.save() + } + + if (transactionLink.deletedAt) { + dbTransactionLink.deletedAt = new Date() + await dbTransactionLink.save() + } + } } diff --git a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts index 94b14992b..ddc835b33 100644 --- a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts +++ b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts @@ -2,4 +2,6 @@ export interface TransactionLinkInterface { email: string amount: number memo: string + createdAt?: Date + deletedAt?: boolean } diff --git a/backend/src/seeds/transactionLink/index.ts b/backend/src/seeds/transactionLink/index.ts index cd952c47f..25755c0f2 100644 --- a/backend/src/seeds/transactionLink/index.ts +++ b/backend/src/seeds/transactionLink/index.ts @@ -1,10 +1,52 @@ import { TransactionLinkInterface } from './TransactionLinkInterface' export const transactionLinks: TransactionLinkInterface[] = [ + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', + createdAt: new Date(2022, 0, 1), + }, { email: 'bibi@bloxberg.de', amount: 19.99, memo: `Kein Trick, keine Zauberrei, bei Gradidio sei dabei!`, }, + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: `Kein Trick, keine Zauberrei, +bei Gradidio sei dabei!`, + }, + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: `Kein Trick, keine Zauberrei, +bei Gradidio sei dabei!`, + }, + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: `Kein Trick, keine Zauberrei, +bei Gradidio sei dabei!`, + }, + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: `Kein Trick, keine Zauberrei, +bei Gradidio sei dabei!`, + }, + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: `Kein Trick, keine Zauberrei, +bei Gradidio sei dabei!`, + }, + { + email: 'bibi@bloxberg.de', + amount: 19.99, + memo: 'Da habe ich mich wohl etwas übernommen.', + deletedAt: true, + }, ] From 0f97dc60a35cf94a97fdeb152b2f8854aa0f0281 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 22:13:50 +0100 Subject: [PATCH 19/92] Duplicate id app deleted --- frontend/public/index.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/public/index.html b/frontend/public/index.html index a15b46916..b9abe3876 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -52,10 +52,6 @@ -
- -
- From fe733c3f7705a1afd95a969ccd787af5c4838121 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 22:14:20 +0100 Subject: [PATCH 20/92] toast rendering error fixed --- frontend/src/mixins/toaster.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/mixins/toaster.js b/frontend/src/mixins/toaster.js index 68fd78ff9..f6e61e5be 100644 --- a/frontend/src/mixins/toaster.js +++ b/frontend/src/mixins/toaster.js @@ -14,7 +14,7 @@ export const toasters = { }, toast(message, options) { if (message.replace) message = message.replace(/^GraphQL error: /, '') - this.$bvToast.toast(message, { + this.$root.$bvToast.toast(message, { autoHideDelay: 5000, appendToast: true, solid: true, From cf601fc5b31842056f32af426d06d39cdcb8b262 Mon Sep 17 00:00:00 2001 From: ogerly Date: Tue, 15 Mar 2022 22:15:30 +0100 Subject: [PATCH 21/92] toast rendering error fixed in adminarea --- admin/src/mixins/toaster.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/mixins/toaster.js b/admin/src/mixins/toaster.js index 9f79b91e8..2db632a81 100644 --- a/admin/src/mixins/toaster.js +++ b/admin/src/mixins/toaster.js @@ -15,7 +15,7 @@ export const toasters = { toast(message, options) { // for unit tests, check that replace is present if (message.replace) message = message.replace(/^GraphQL error: /, '') - this.$bvToast.toast(message, { + this.$root.$bvToast.toast(message, { autoHideDelay: 5000, appendToast: true, solid: true, From 90ce74a98c1a4d2f75c8ba2d1299b7eec5df7a66 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 16 Mar 2022 11:01:07 +0100 Subject: [PATCH 22/92] add variables pageSize --- frontend/src/graphql/queries.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 0a309284e..141dc8651 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -145,8 +145,8 @@ export const queryTransactionLink = gql` ` export const listTransactionLinks = gql` - query($currentPage: Int = 1, $pageSize: Int = 5, $order: Order = DESC) { - listTransactionLinks(currentPage: $currentPage, pageSize: $pageSize, order: $order) { + query($currentPage: Int = 1, $pageSize: Int = 5) { + listTransactionLinks(currentPage: $currentPage, pageSize: $pageSize) { id amount holdAvailableAmount From 1a89d94bdaa5de8d3345bc09a4db5cb17ed0792b Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 16 Mar 2022 11:02:26 +0100 Subject: [PATCH 23/92] add varibles object, add computed and watch currentPage --- .../Transactions/TransactionLinksSummary.vue | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/Transactions/TransactionLinksSummary.vue b/frontend/src/components/Transactions/TransactionLinksSummary.vue index c4496ed0d..5d5bf3c93 100644 --- a/frontend/src/components/Transactions/TransactionLinksSummary.vue +++ b/frontend/src/components/Transactions/TransactionLinksSummary.vue @@ -25,8 +25,9 @@ @@ -69,26 +70,50 @@ export default { return { visible: false, transactionLinks: [], + variables: { + currentPage: 1, + pending: false, + pageSize: 5, + itemsShown: 0, + }, } }, methods: { async updateListTransactionLinks() { - this.$apollo - .query({ - query: listTransactionLinks, - variables: { - currentPage: 1, - pageSize: 5, - }, - fetchPolicy: 'network-only', - }) - .then((result) => { - this.transactionLinks = result.data.listTransactionLinks - this.$emit('update-transactions') - }) - .catch((err) => { - this.toastError(err.message) - }) + if (this.currentPage === 0) { + this.transactionLinks = [] + this.variables.currentPage = 1 + } else { + this.variables.pending = true + this.$apollo + .query({ + query: listTransactionLinks, + variables: { + currentPage: this.currentPage, + }, + fetchPolicy: 'network-only', + }) + .then((result) => { + this.transactionLinks = [...this.transactionLinks, ...result.data.listTransactionLinks] + this.$emit('update-transactions') + this.variables.pending = false + this.variables.itemsShown = this.transactionLinks.length + }) + .catch((err) => { + this.toastError(err.message) + this.variables.pending = false + }) + } + }, + }, + computed: { + currentPage() { + return this.variables.currentPage + }, + }, + watch: { + currentPage() { + this.updateListTransactionLinks() }, }, created() { From e49543ad5522ca64cda7fca276b2afe45a69ddc4 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 16 Mar 2022 11:03:45 +0100 Subject: [PATCH 24/92] add function resetTransactionLinkList, loadMoreLinks and computed buttonText --- .../DecayInformations/CollapseLinksList.vue | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/DecayInformations/CollapseLinksList.vue b/frontend/src/components/DecayInformations/CollapseLinksList.vue index 275615de1..7492532b6 100644 --- a/frontend/src/components/DecayInformations/CollapseLinksList.vue +++ b/frontend/src/components/DecayInformations/CollapseLinksList.vue @@ -14,8 +14,24 @@ v-for="item in transactionLinks" :key="item.id" v-bind:item="item" - @update-list-transaction-links="updateListTransactionLinks" + @reset-transaction-link-list="resetTransactionLinkList" /> +
+ + {{ buttonText }} + + +
@@ -30,10 +46,27 @@ export default { }, props: { transactionLinks: { type: Array, required: true }, + transactionLinkCount: { + type: Number, + required: true, + }, + value: { type: Object, required: true }, }, methods: { - updateListTransactionLinks() { - this.$emit('update-list-transaction-links') + resetTransactionLinkList() { + this.$emit('input', { ...this.value, currentPage: 0 }) + }, + loadMoreLinks() { + this.$emit('input', { ...this.value, currentPage: this.value.currentPage + 1 }) + }, + }, + computed: { + buttonText() { + if (this.transactionLinkCount - this.value.itemsShown > this.value.pageSize) + return 'weitere ' + this.value.pageSize + ' Links Nachladen' + return ( + 'die letzten ' + (this.transactionLinkCount - this.value.itemsShown) + ' Links nachladen' + ) }, }, } From b976e8441143e89ee8d0c4bc5cccccb7cd46167c Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 16 Mar 2022 11:05:08 +0100 Subject: [PATCH 25/92] refactor modal, deleteLink emit reset-transaction-link-list --- .../TransactionLinks/TransactionLink.vue | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 0ff13a1a0..b8247c7fc 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -1,16 +1,5 @@