From 7676e7e7f3be322e3319fc58419d6a3298c08424 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 08:15:24 +0200 Subject: [PATCH 01/91] create page Community.vue --- frontend/src/components/Menu/Sidebar.vue | 4 ++++ frontend/src/pages/Community.vue | 22 ++++++++++++++++++++++ frontend/src/routes/routes.js | 7 +++++++ 3 files changed, 33 insertions(+) create mode 100644 frontend/src/pages/Community.vue diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index 028b7aca6..f1e582356 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -20,6 +20,10 @@ {{ $t('navigation.profile') }} + + + {{ $t('navigation.community') }} +
diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue new file mode 100644 index 000000000..9264df623 --- /dev/null +++ b/frontend/src/pages/Community.vue @@ -0,0 +1,22 @@ + + diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index e68f97502..540ef9d69 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -38,6 +38,13 @@ const routes = [ requiresAuth: true, }, }, + { + path: '/community', + component: () => import('@/pages/Community.vue'), + meta: { + requiresAuth: true, + }, + }, { path: '/login/:code?', component: () => import('@/pages/Login.vue'), From 1664a2070fdb96bcbbfe83d42ef9895d3c16dae9 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 08:16:00 +0200 Subject: [PATCH 02/91] locales for Community.vue Page --- frontend/src/locales/de.json | 7 +++++-- frontend/src/locales/en.json | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index fec24b1dc..74850d556 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -28,7 +28,9 @@ "continue-to-registration": "Weiter zur Registrierung", "current-community": "Aktuelle Gemeinschaft", "other-communities": "Weitere Gemeinschaften", - "switch-to-this-community": "zu dieser Gemeinschaft wechseln" + "switch-to-this-community": "zu dieser Gemeinschaft wechseln", + "writing":"Schreiben", + "myContributions":"Meine Beiträge" }, "contribution-link": { "thanksYouWith": "dankt dir mit" @@ -200,7 +202,8 @@ "profile": "Mein Profil", "send": "Senden", "support": "Support", - "transactions": "Transaktionen" + "transactions": "Transaktionen", + "community":"Gemeinschaft" }, "qrCode": "QR Code", "send_gdd": "GDD versenden", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index a0ef6723d..1312b60b4 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -28,7 +28,9 @@ "continue-to-registration": "Continue to registration", "current-community": "Current community", "other-communities": "Other communities", - "switch-to-this-community": "Switch to this community" + "switch-to-this-community": "Switch to this community", + "writing":"Writing", + "myContributions":"My contributions" }, "contribution-link": { "thanksYouWith": "thanks you with" @@ -200,7 +202,8 @@ "profile": "My profile", "send": "Send", "support": "Support", - "transactions": "Transactions" + "transactions": "Transactions", + "community":"Community" }, "qrCode": "QR Code", "send_gdd": "GDD send", From d8fb3608a2931d380f1902244b9169e70ef1476d Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 12:01:27 +0200 Subject: [PATCH 03/91] add new component ContributionForm.vue --- .../Contributions/ContributionForm.vue | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 frontend/src/components/Contributions/ContributionForm.vue diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue new file mode 100644 index 000000000..a67b4642f --- /dev/null +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -0,0 +1,79 @@ + + From fa0598c75262da33fedd4056ec9defba4f969551 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 12:02:31 +0200 Subject: [PATCH 04/91] add form in ContributionForm.vue --- frontend/src/i18n.js | 18 ++++++++++++++++++ frontend/src/locales/de.json | 10 +++++++++- frontend/src/locales/en.json | 9 ++++++++- frontend/src/pages/Community.vue | 6 +++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index f4f969008..74de46c29 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -75,6 +75,15 @@ const dateTimeFormats = { hour: 'numeric', minute: 'numeric', }, + monthShort: { + month: 'short', + }, + month: { + month: 'long', + }, + year: { + year: 'numeric', + }, }, de: { short: { @@ -90,6 +99,15 @@ const dateTimeFormats = { hour: 'numeric', minute: 'numeric', }, + monthShort: { + month: 'short', + }, + month: { + month: 'long', + }, + year: { + year: 'numeric', + }, }, } diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 74850d556..3af893009 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -32,6 +32,10 @@ "writing":"Schreiben", "myContributions":"Meine Beiträge" }, + "contribution": { + "activity":"Tätigkeit", + "submit":"Einreichen" + }, "contribution-link": { "thanksYouWith": "dankt dir mit" }, @@ -182,7 +186,10 @@ "equal": "=", "exclaim": "!", "minus": "−", - "pipe": "|" + "pipe": "|", + "divide": "/", + "equalTo":"<" + }, "message": { "activateEmail": "Dein Konto wurde noch nicht aktiviert. Bitte überprüfe deine E-Mail und klicke den Aktivierungslink oder fordere einen neuen Aktivierungslink über die Password Reset Seite an.", @@ -275,6 +282,7 @@ "days": "Tage", "hours": "Stunden", "minutes": "Minuten", + "month": "Monat", "months": "Monate", "seconds": "Sekunden", "years": "Jahr" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 1312b60b4..8244eb1fb 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -32,6 +32,10 @@ "writing":"Writing", "myContributions":"My contributions" }, + "contribution": { + "activity":"Activity", + "submit":"Submit" + }, "contribution-link": { "thanksYouWith": "thanks you with" }, @@ -182,7 +186,9 @@ "equal": "=", "exclaim": "!", "minus": "−", - "pipe": "|" + "pipe": "|", + "divide": "/", + "equalTo":"<" }, "message": { "activateEmail": "Your account has not been activated yet. Please check your emails and click the activation link or order a new activation link over the password reset page.", @@ -275,6 +281,7 @@ "days": "Days", "hours": "Hours", "minutes": "Minutes", + "month": "Month", "months": "Months", "seconds": "Seconds", "years": "Year" diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 9264df623..66fdfcae6 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -3,7 +3,7 @@
-

{{ $t('community.writing') }}

+

{{ $t('community.myContributions') }}

@@ -16,7 +16,11 @@
From 50050e138f96bcd7b75890b001737ce419643840 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Jul 2022 12:05:06 +0200 Subject: [PATCH 05/91] change form.text to form.memo --- .../components/Contributions/ContributionForm.vue | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index a67b4642f..9b4f9de1b 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -13,7 +13,7 @@
- {{ form.text.length }} - {{ $t('math.equalTo') }} {{ minlength }} + {{ form.memo.length }} + {{ $t('math.equalTo') }} {{ minlength }} {{ $t('math.divide') }} {{ maxlength }}
@@ -49,8 +49,9 @@ export default { minlength: 50, maxlength: 500, form: { - text: '', selected: this.$moment().format('MMMM'), + memo: '', + amount: 0, }, options: [ @@ -70,7 +71,7 @@ export default { }, computed: { disable() { - if (this.form.text.length < this.minlength) return true + if (this.form.memo.length < this.minlength) return true if (this.form.amount < 1 && this.form.amount < 1000) return true return false }, From c3d62db1e5bdb8d2eeaf7b4eefaca40313d3fded Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 8 Jul 2022 11:34:55 +0200 Subject: [PATCH 06/91] add componente ContributionList.vue --- .../Contributions/ContributionList.vue | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 frontend/src/components/Contributions/ContributionList.vue diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue new file mode 100644 index 000000000..e3dc41b5f --- /dev/null +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -0,0 +1,17 @@ + + From 4cc1642988fb65a0d4f50440f8346bced7f8bff3 Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 8 Jul 2022 21:26:18 +0200 Subject: [PATCH 07/91] add mutations createContribution --- frontend/src/graphql/mutations.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index 9b035cba6..d70eb8c99 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -89,3 +89,12 @@ export const redeemTransactionLink = gql` redeemTransactionLink(code: $code) } ` + +export const createContribution = gql` + mutation($creationDate: String!, $memo: String!, $amount: Decimal!) { + createContribution(creationDate: $creationDate, memo: $memo, amount: $amount) { + amount + memo + } + } +` From a65d680bdaf125f539982d203df2ac033b2eb5cf Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 11 Jul 2022 08:19:29 +0200 Subject: [PATCH 08/91] change form, ,maxlenght 255, add items for list --- .../Contributions/ContributionForm.vue | 40 ++++++------- frontend/src/locales/de.json | 3 +- frontend/src/locales/en.json | 3 +- frontend/src/pages/Community.vue | 60 ++++++++++++++++++- 4 files changed, 79 insertions(+), 27 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 9b4f9de1b..ac59959a1 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -1,15 +1,17 @@ From f79ff13183c946ff1f403749bb5a00d2bb1883f4 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 11 Jul 2022 08:20:23 +0200 Subject: [PATCH 09/91] fix locales --- frontend/src/locales/de.json | 21 ++++++++++----------- frontend/src/locales/en.json | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index d8374a541..14e0d2300 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -27,15 +27,15 @@ "community": "Gemeinschaft", "continue-to-registration": "Weiter zur Registrierung", "current-community": "Aktuelle Gemeinschaft", + "myContributions": "Meine Beiträge", "other-communities": "Weitere Gemeinschaften", "switch-to-this-community": "zu dieser Gemeinschaft wechseln", - "writing":"Schreiben", - "myContributions":"Meine Beiträge" + "writing": "Schreiben" }, "contribution": { - "activity":"Tätigkeit", - "submit":"Einreichen", - "noDateSelected": "Kein Datum ausgewählt" + "activity": "Tätigkeit", + "noDateSelected": "Kein Datum ausgewählt", + "submit": "Einreichen" }, "contribution-link": { "thanksYouWith": "dankt dir mit" @@ -184,13 +184,12 @@ "login": "Anmeldung", "math": { "aprox": "~", + "divide": "/", "equal": "=", + "equalTo": "<", "exclaim": "!", "minus": "−", - "pipe": "|", - "divide": "/", - "equalTo":"<" - + "pipe": "|" }, "message": { "activateEmail": "Dein Konto wurde noch nicht aktiviert. Bitte überprüfe deine E-Mail und klicke den Aktivierungslink oder fordere einen neuen Aktivierungslink über die Password Reset Seite an.", @@ -204,14 +203,14 @@ }, "navigation": { "admin_area": "Adminbereich", + "community": "Gemeinschaft", "logout": "Abmelden", "members_area": "Mitgliederbereich", "overview": "Übersicht", "profile": "Mein Profil", "send": "Senden", "support": "Support", - "transactions": "Transaktionen", - "community":"Gemeinschaft" + "transactions": "Transaktionen" }, "qrCode": "QR Code", "send_gdd": "GDD versenden", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index c10b62508..b06d141d3 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -27,15 +27,15 @@ "community": "Community", "continue-to-registration": "Continue to registration", "current-community": "Current community", + "myContributions": "My contributions", "other-communities": "Other communities", "switch-to-this-community": "Switch to this community", - "writing":"Writing", - "myContributions":"My contributions" + "writing": "Writing" }, "contribution": { - "activity":"Activity", - "submit":"Submit", - "noDateSelected": "No date selected" + "activity": "Activity", + "noDateSelected": "No date selected", + "submit": "Submit" }, "contribution-link": { "thanksYouWith": "thanks you with" @@ -184,12 +184,12 @@ "login": "Login", "math": { "aprox": "~", + "divide": "/", "equal": "=", + "equalTo": "<", "exclaim": "!", "minus": "−", - "pipe": "|", - "divide": "/", - "equalTo":"<" + "pipe": "|" }, "message": { "activateEmail": "Your account has not been activated yet. Please check your emails and click the activation link or order a new activation link over the password reset page.", @@ -203,14 +203,14 @@ }, "navigation": { "admin_area": "Admin Area", + "community": "Community", "logout": "Logout", "members_area": "Members area", "overview": "Overview", "profile": "My profile", "send": "Send", "support": "Support", - "transactions": "Transactions", - "community":"Community" + "transactions": "Transactions" }, "qrCode": "QR Code", "send_gdd": "GDD send", From 0c857417e5bda4581589bd11ce067c3dd9e06f92 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 11 Jul 2022 08:27:45 +0200 Subject: [PATCH 10/91] fix test --- frontend/src/components/Menu/Sidebar.spec.js | 13 ++++++++----- frontend/src/routes/router.test.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index fec7945c8..982192a8f 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -33,7 +33,7 @@ describe('Sidebar', () => { describe('navigation Navbar', () => { it('has seven b-nav-item in the navbar', () => { - expect(wrapper.findAll('.nav-item')).toHaveLength(7) + expect(wrapper.findAll('.nav-item')).toHaveLength(8) }) it('has first nav-item "navigation.overview" in navbar', () => { @@ -50,15 +50,18 @@ describe('Sidebar', () => { it('has first nav-item "navigation.profile" in navbar', () => { expect(wrapper.findAll('.nav-item').at(3).text()).toEqual('navigation.profile') }) + it('has a link to the community area', () => { + expect(wrapper.findAll('.nav-item').at(4).text()).toContain('navigation.community') + }) it('has a link to the members area', () => { - expect(wrapper.findAll('.nav-item').at(4).text()).toContain('navigation.members_area') - expect(wrapper.findAll('.nav-item').at(4).find('a').attributes('href')).toBe('#') + expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area') + expect(wrapper.findAll('.nav-item').at(5).find('a').attributes('href')).toBe('#') }) it('has first nav-item "navigation.admin_area" in navbar', () => { - expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.admin_area') + expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.admin_area') }) it('has first nav-item "navigation.logout" in navbar', () => { - expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.logout') + expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.logout') }) }) }) diff --git a/frontend/src/routes/router.test.js b/frontend/src/routes/router.test.js index 32ab90d4e..1edc6568b 100644 --- a/frontend/src/routes/router.test.js +++ b/frontend/src/routes/router.test.js @@ -50,7 +50,7 @@ describe('router', () => { }) it('has sixteen routes defined', () => { - expect(routes).toHaveLength(16) + expect(routes).toHaveLength(17) }) describe('overview', () => { From 4d622ee52cbaf065f6882359d5ceced1d32c0988 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 11 Jul 2022 14:53:57 +0200 Subject: [PATCH 11/91] add test for Community.vue --- frontend/src/pages/Community.spec.js | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 frontend/src/pages/Community.spec.js diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js new file mode 100644 index 000000000..30bb2acda --- /dev/null +++ b/frontend/src/pages/Community.spec.js @@ -0,0 +1,41 @@ +import { mount } from '@vue/test-utils' +import Community from './Community' +// import { createContribution } from '@/graphql/mutations' + +// import { toastErrorSpy } from '@test/testSetup' + +const localVue = global.localVue + +const apolloMutationMock = jest.fn() +apolloMutationMock.mockResolvedValue('success') + +describe('Community', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + $apollo: { + mutate: apolloMutationMock, + }, + $route: { + query: {}, + }, + } + + const Wrapper = () => { + return mount(Community, { + localVue, + mocks, + }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has a components community-page', () => { + expect(wrapper.find('div.community-page').exists()).toBe(true) + }) + }) +}) From 280f386a35be55150d17e262cfeeb92fbb454052 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 11 Jul 2022 14:54:35 +0200 Subject: [PATCH 12/91] change text for fromular, change disable submit --- .../Contributions/ContributionForm.vue | 25 ++++++++++++++++--- frontend/src/locales/de.json | 9 ++++++- frontend/src/locales/en.json | 9 ++++++- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index ac59959a1..67db69f5b 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -1,6 +1,18 @@ diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 552b7f0a7..12ebc86b3 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -35,10 +35,10 @@ "activity": "Tätigkeit", "formText": { "h3": "Dein Beitrag zum Gemeinwohl", - "lastMonth": "Für Juni 2022 kannst du noch 200 GDD einreichen .", + "lastMonth": "Für {month} {year} kannst du noch {creation} GDD einreichen.", "text1": "Bring dich mit deinen Talenten in die Gemeinschaft ein! Dein freiwilliges Engagement honorieren wir mit 20 GDD pro Stunde bis maximal 1.000 GDD im Monat.", "text2": "Beschreibe deine Gemeinwohl-Tätigkeit mit Angabe der Stunden und trage einen Betrag von 20 GDD pro Stunde ein! Nach Bestätigung durch einen Moderator wird der Betrag deinem Konto gutgeschrieben.", - "thisMonth": "Für Juli 2022 kannst du noch 500 GDD einreichen. " + "thisMonth": "Für {month} {year} kannst du noch {creation} GDD einreichen. " }, "noDateSelected": "Kein Datum ausgewählt", "submit": "Einreichen" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index a25d2da56..1ef7052d5 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -35,10 +35,10 @@ "activity": "Activity", "formText": { "h3": "Your contribution to the common good", - "lastMonth": "For June 2022, you can still submit 200 GDD.", + "lastMonth": "For {month} {year}, you can still submit {creation} GDD.", "text1": "Bring your talents to the community! Your voluntary commitment will be rewarded with 20 GDD per hour up to a maximum of 1,000 GDD per month.", "text2": "Describe your community service activity with hours and enter an amount of 20 GDD per hour! After confirmation by a moderator, the amount will be credited to your account.", - "thisMonth": "For July 2022, you can still submit 500 GDD." + "thisMonth": "For {month} {year}, you can still submit {creation} GDD." }, "noDateSelected": "No date selected", "submit": "Submit" From 910ba6bbdf7630c85db5c1d919ff89d92dc8d722 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 13 Jul 2022 08:54:28 +0200 Subject: [PATCH 24/91] moved from v-html to computed --- .../Contributions/ContributionForm.vue | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index edbaca6de..072f6c04d 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -4,8 +4,8 @@

{{ $t('contribution.formText.h3') }}

{{ $t('contribution.formText.text1') }}
    -
  • -
  • +
  • +
@@ -39,7 +39,6 @@ class="text-right" :class="form.memo.length < minlength ? 'text-danger' : 'text-success'" > - {{ form.memo.length }} {{ $t('math.equalTo') }} {{ minlength }} {{ $t('math.divide') }} {{ maxlength }}
@@ -65,10 +64,10 @@ From 6dd11a961ffbdaba903f3bb4eb6f253e5e768732 Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 13 Jul 2022 09:04:14 +0200 Subject: [PATCH 25/91] resolve merge conflict for ContributionResolver.ts 2 --- backend/src/graphql/resolver/ContributionResolver.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index bfce1ba03..4424b40d0 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,7 +3,6 @@ import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' import { Arg, Args, Authorized, Ctx, Mutation, Query, Resolver } from 'type-graphql' -<<<<<<< HEAD import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' @@ -11,15 +10,6 @@ import { Order } from '@enum/Order' import { Contribution } from '@model/Contribution' import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { User } from '@model/User' -======= -import { IsNull, Not } from '../../../../database/node_modules/typeorm' -import ContributionArgs from '../arg/ContributionArgs' -import Paginated from '../arg/Paginated' -import { Order } from '../enum/Order' -import { Contribution } from '../model/Contribution' -import { UnconfirmedContribution } from '../model/UnconfirmedContribution' -import { User } from '../model/User' ->>>>>>> 193c7927e (resolve conflict) import { validateContribution, getUserCreation } from './util/creations' @Resolver() From b0df5996e0f8f4029a23120855bf04656d357eac Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 13 Jul 2022 11:06:29 +0200 Subject: [PATCH 26/91] change computed lastMonthObject --- .../Contributions/ContributionForm.vue | 14 +---- frontend/src/graphql/queries.js | 22 +++++++ frontend/src/pages/Community.vue | 57 ++++++++++--------- 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 072f6c04d..5eae4718f 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -57,7 +57,6 @@ {{ $t('contribution.submit') }} - {{ form }} @@ -102,19 +101,12 @@ export default { return false }, lastMonthObject() { - let obj = { - month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }), - year: new Date().getFullYear(), - creation: this.$store.state.creation[1], - } - // If the current month is January then the current year must be counted back by -1. - if (new Date().getMonth === 1) { - obj = { + // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month + const obj = { month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }), - year: new Date().getFullYear() - 1, + year: new Date().getMonth === 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(), creation: this.$store.state.creation[1], } - } return this.$t('contribution.formText.lastMonth', obj) }, thisMonthObject() { diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index 27e63d568..a25c4b4f4 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -162,3 +162,25 @@ export const listTransactionLinks = gql` } } ` + +export const listContributions = gql` + query( + $currentPage: Int = 1 + $pageSize: Int = 25 + $order: Order = DESC + $filterConfirmed: Boolean = false + ) { + listContributions( + currentPage: $currentPage + pageSize: $pageSize + order: $order + filterConfirmed: $filterConfirmed + ) { + id + amount + memo + createdAt + deletedAt + } + } +` diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 0559ea3e8..dc7c22aa0 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -20,6 +20,7 @@ import ContributionForm from '@/components/Contributions/ContributionForm.vue' import ContributionList from '@/components/Contributions/ContributionList.vue' import { createContribution } from '@/graphql/mutations' +import { listContributions } from '@/graphql/queries' export default { name: 'Community', @@ -29,39 +30,18 @@ export default { }, data() { return { - items: [ - { - id: '0', - date: '07/06/2022', - memo: 'Ich habe 10 Stunden die Elbwiesen von Müll befreit.', - amount: 200, - status: 'pending', - }, - { - id: '1', - date: '06/22/2022', - memo: 'Ich habe 30 Stunden Frau Müller beim EInkaufen und im Haushalt geholfen.', - amount: 600, - status: 'pending', - }, - { - id: '2', - date: '05/04/2022', - memo: - 'Ich habe 50 Stunden den Nachbarkindern bei ihren Hausaufgaben geholfen und Nachhilfeunterricht gegeben.', - amount: 1000, - status: 'pending', - }, - ], + currentPage: 1, + pageSize: 25, + items: [], } }, methods: { setContribution(data) { // console.log('setContribution', data) this.$apollo - .query({ + .mutate({ fetchPolicy: 'no-cache', - query: createContribution, + mutation: createContribution, variables: { creationDate: data.date, memo: data.memo, @@ -76,6 +56,31 @@ export default { this.toastError(err.message) }) }, + getListContributions(data) { + this.$apollo + .query({ + fetchPolicy: 'no-cache', + query: listContributions, + variables: { + currentPage: this.currentPage, + pageSize: this.pageSize, + }, + }) + .then((result) => { + console.log('result', result.data) + const { + data: { listContributions }, + } = result + this.items = listContributions + // this.toastSuccess(result.data) + }) + .catch((err) => { + this.toastError(err.message) + }) + }, + }, + created() { + this.getListContributions() }, } From 802a629d2684d03647f1dd80b01cd9585a07fa2a Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 13 Jul 2022 11:12:33 +0200 Subject: [PATCH 27/91] remove console statement --- .../src/components/Contributions/ContributionForm.vue | 10 +++++----- frontend/src/pages/Community.vue | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 5eae4718f..a788e1563 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -101,12 +101,12 @@ export default { return false }, lastMonthObject() { - // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month + // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month const obj = { - month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }), - year: new Date().getMonth === 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(), - creation: this.$store.state.creation[1], - } + month: new Date(this.lastMonth).toLocaleString(this.$i18n.locale, { month: 'long' }), + year: new Date().getMonth === 1 ? new Date().getFullYear() - 1 : new Date().getFullYear(), + creation: this.$store.state.creation[1], + } return this.$t('contribution.formText.lastMonth', obj) }, thisMonthObject() { diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index dc7c22aa0..c639ec969 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -67,7 +67,7 @@ export default { }, }) .then((result) => { - console.log('result', result.data) + // console.log('result', result.data) const { data: { listContributions }, } = result From ffe8831d090557efd107e4499cfa29ec6b2567af Mon Sep 17 00:00:00 2001 From: ogerly Date: Wed, 13 Jul 2022 11:28:35 +0200 Subject: [PATCH 28/91] change listContributions query add confirmedBy and confirmedAt --- frontend/src/graphql/queries.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index a25c4b4f4..a523d18a1 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -181,6 +181,8 @@ export const listContributions = gql` memo createdAt deletedAt + confirmedBy + confirmedAt } } ` From 84706e430b0d6fda8f818e18e512f5126b10ea57 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 14 Jul 2022 11:50:17 +0200 Subject: [PATCH 29/91] add slot ContributionListItem.vue, add verifyLogin, update store for creation --- .../Contributions/ContributionForm.vue | 1 + .../Contributions/ContributionList.vue | 52 ++++++++++++- .../Contributions/ContributionListItem.vue | 73 +++++++++++++++++++ frontend/src/pages/Community.vue | 51 ++++++++++--- 4 files changed, 164 insertions(+), 13 deletions(-) create mode 100644 frontend/src/components/Contributions/ContributionListItem.vue diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index a788e1563..20d7ff921 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -57,6 +57,7 @@ {{ $t('contribution.submit') }} + {{ $store.state }} diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue index e3dc41b5f..e7fc930e6 100644 --- a/frontend/src/components/Contributions/ContributionList.vue +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -1,17 +1,65 @@ diff --git a/frontend/src/components/Contributions/ContributionListItem.vue b/frontend/src/components/Contributions/ContributionListItem.vue new file mode 100644 index 000000000..11cb2266e --- /dev/null +++ b/frontend/src/components/Contributions/ContributionListItem.vue @@ -0,0 +1,73 @@ + + diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index c639ec969..6db97b5a0 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -6,12 +6,15 @@ - - - - - + + @@ -20,7 +23,7 @@ import ContributionForm from '@/components/Contributions/ContributionForm.vue' import ContributionList from '@/components/Contributions/ContributionList.vue' import { createContribution } from '@/graphql/mutations' -import { listContributions } from '@/graphql/queries' +import { listContributions, verifyLogin } from '@/graphql/queries' export default { name: 'Community', @@ -30,9 +33,10 @@ export default { }, data() { return { + items: [], currentPage: 1, pageSize: 25, - items: [], + contributionCount: 0, } }, methods: { @@ -51,19 +55,24 @@ export default { .then((result) => { // console.log('result', result.data) this.toastSuccess(result.data) + this.updateListContributions({ + currentPage: this.currentPage, + pageSize: this.pageSize, + }) + this.verifyLogin() }) .catch((err) => { this.toastError(err.message) }) }, - getListContributions(data) { + async updateListContributions(pagination) { this.$apollo .query({ fetchPolicy: 'no-cache', query: listContributions, variables: { - currentPage: this.currentPage, - pageSize: this.pageSize, + currentPage: pagination.currentPage, + pageSize: pagination.pageSize, }, }) .then((result) => { @@ -71,6 +80,7 @@ export default { const { data: { listContributions }, } = result + this.contributionCount = listContributions.length this.items = listContributions // this.toastSuccess(result.data) }) @@ -78,9 +88,28 @@ export default { this.toastError(err.message) }) }, + verifyLogin() { + this.$apollo + .query({ + query: verifyLogin, + fetchPolicy: 'network-only', + }) + .then((result) => { + const { + data: { verifyLogin }, + } = result + this.$store.dispatch('login', verifyLogin) + }) + .catch(() => { + this.$emit('logout') + }) + }, }, created() { - this.getListContributions() + this.updateListContributions({ + currentPage: this.currentPage, + pageSize: this.pageSize, + }) }, } From af0f434d011171ec08c464db8c354624b0ab9d14 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 14 Jul 2022 15:22:38 +0200 Subject: [PATCH 30/91] add updateContribution --- .../Contributions/ContributionForm.vue | 26 ++++++++++++++----- .../Contributions/ContributionList.vue | 5 +++- .../Contributions/ContributionListItem.vue | 21 ++++++++++++--- frontend/src/pages/Community.vue | 18 +++++++++++-- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 20d7ff921..ff74786d6 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -16,7 +16,7 @@ {{ $t('contribution.activity') }} {{ $t('contribution.submit') }} - {{ $store.state }} + {{date}}, {{amount}}, {{ memo}} @@ -70,6 +70,12 @@ */ export default { name: 'ContributionForm', + props: { + id: { type: Number, required: false}, + date: { type: String, required: true}, + memo: { type: String, required: true}, + amount: { type: String, required: true}, + }, data() { return { minlength: 50, @@ -78,9 +84,9 @@ export default { min: new Date(new Date(new Date().setMonth(new Date().getMonth() - 1)).setDate(1)), max: new Date(), form: { - date: '', - memo: '', - amount: 0, + date: this.date, + memo: this.memo, + amount: this.amount, }, } }, @@ -119,5 +125,11 @@ export default { return this.$t('contribution.formText.thisMonth', obj) }, }, + watch: { + id(newId, oldId){ + console.log('eine id kommt mit') + } + + } } diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue index e7fc930e6..c08d22c79 100644 --- a/frontend/src/components/Contributions/ContributionList.vue +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -2,7 +2,7 @@
{{ items.length }}
- +
{{ $d(new Date(date), 'short') }}
{{ memo }}
-
+
-
- -
@@ -69,5 +77,10 @@ export default { return this.createdAt }, }, + methods: { + updateContribution(item) { + this.$emit('update-contribution', item) + }, + }, } diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 6db97b5a0..b5907aefa 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -1,14 +1,15 @@ From c170c48ac4bb41b4e2f8e1621fbf1f348a00547a Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 15 Jul 2022 10:11:07 +0200 Subject: [PATCH 34/91] change for tests --- .../Contributions/ContributionForm.spec.js | 6 ++++++ .../Contributions/ContributionList.spec.js | 19 ++++++++++--------- frontend/src/components/Menu/Sidebar.spec.js | 8 ++++---- frontend/src/pages/Community.spec.js | 8 +++++--- frontend/src/pages/Community.vue | 4 ++++ 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 4d39e2942..633d0e1ae 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -8,6 +8,12 @@ describe('ContributionForm', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), + $store: { + state: { + creation: ["1000","1000","1000"], + }, + }, } const Wrapper = () => { diff --git a/frontend/src/components/Contributions/ContributionList.spec.js b/frontend/src/components/Contributions/ContributionList.spec.js index 7accfcad9..ba6e15786 100644 --- a/frontend/src/components/Contributions/ContributionList.spec.js +++ b/frontend/src/components/Contributions/ContributionList.spec.js @@ -8,31 +8,32 @@ describe('ContributionList', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), } const propsData = { + contributionCount: 3, + showPagination: true, + pageSize: 25, items: [ { - id: '0', + id: 0, date: '07/06/2022', memo: 'Ich habe 10 Stunden die Elbwiesen von Müll befreit.', - amount: 200, - status: 'pending', + amount: '200', }, { - id: '1', + id: 1, date: '06/22/2022', memo: 'Ich habe 30 Stunden Frau Müller beim EInkaufen und im Haushalt geholfen.', - amount: 600, - status: 'pending', + amount: '600', }, { - id: '2', + id: 2, date: '05/04/2022', memo: 'Ich habe 50 Stunden den Nachbarkindern bei ihren Hausaufgaben geholfen und Nachhilfeunterricht gegeben.', - amount: 1000, - status: 'pending', + amount: '1000', }, ], } diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index 982192a8f..afee93def 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -47,11 +47,11 @@ describe('Sidebar', () => { it('has first nav-item "navigation.transactions" in navbar', () => { expect(wrapper.findAll('.nav-item').at(2).text()).toEqual('navigation.transactions') }) - it('has first nav-item "navigation.profile" in navbar', () => { - expect(wrapper.findAll('.nav-item').at(3).text()).toEqual('navigation.profile') - }) it('has a link to the community area', () => { - expect(wrapper.findAll('.nav-item').at(4).text()).toContain('navigation.community') + expect(wrapper.findAll('.nav-item').at(3).text()).toContain('navigation.community') + }) + it('has first nav-item "navigation.profile" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.profile') }) it('has a link to the members area', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area') diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index 7f1540369..a90f035ee 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -1,11 +1,9 @@ import { mount } from '@vue/test-utils' import Community from './Community' -// import { createContribution } from '@/graphql/mutations' - -// import { toastErrorSpy } from '@test/testSetup' const localVue = global.localVue +const mockStoreDispach = jest.fn() const apolloMutationMock = jest.fn() apolloMutationMock.mockResolvedValue('success') @@ -14,9 +12,13 @@ describe('Community', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $apollo: { mutate: apolloMutationMock, }, + $store: { + dispatch: mockStoreDispach, + }, } const Wrapper = () => { diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 4774fc3c0..ddf4333bf 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -118,12 +118,16 @@ export default { this.form.memo = item.memo this.form.amount = item.amount }, + updateTransactions(pagination) { + this.$emit('update-transactions', pagination) + }, }, created() { this.updateListContributions({ currentPage: this.currentPage, pageSize: this.pageSize, }) + this.updateTransactions(0) }, } From 9efb83b2afe953d9e3b63811a65ec500b48de991 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 15 Jul 2022 11:01:36 +0200 Subject: [PATCH 35/91] fix tests --- .../Contributions/ContributionForm.spec.js | 2 +- .../Contributions/ContributionListItem.vue | 16 +++++++------- frontend/src/pages/Community.spec.js | 21 ++++++++++++++++++- frontend/src/pages/Community.vue | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js index 633d0e1ae..44fa170b1 100644 --- a/frontend/src/components/Contributions/ContributionForm.spec.js +++ b/frontend/src/components/Contributions/ContributionForm.spec.js @@ -11,7 +11,7 @@ describe('ContributionForm', () => { $d: jest.fn((d) => d), $store: { state: { - creation: ["1000","1000","1000"], + creation: ['1000', '1000', '1000'], }, }, } diff --git a/frontend/src/components/Contributions/ContributionListItem.vue b/frontend/src/components/Contributions/ContributionListItem.vue index 499c23e63..cbc986326 100644 --- a/frontend/src/components/Contributions/ContributionListItem.vue +++ b/frontend/src/components/Contributions/ContributionListItem.vue @@ -57,23 +57,23 @@ export default { }, computed: { type() { - if (this.deletedAt !== null) return 'deleted' - if (this.confirmedAt !== null) return 'confirmed' + if (this.deletedAt) return 'deleted' + if (this.confirmedAt) return 'confirmed' return 'pending' }, icon() { - if (this.deletedAt !== null) return 'x-circle' - if (this.confirmedAt !== null) return 'check' + if (this.deletedAt) return 'x-circle' + if (this.confirmedAt) return 'check' return 'bell-fill' }, variant() { - if (this.deletedAt !== null) return 'danger' - if (this.confirmedAt !== null) return 'success' + if (this.deletedAt) return 'danger' + if (this.confirmedAt) return 'success' return 'primary' }, date() { - if (this.deletedAt !== null) return this.deletedAt - if (this.confirmedAt !== null) return this.confirmedAt + if (this.deletedAt) return this.deletedAt + if (this.confirmedAt) return this.confirmedAt return this.createdAt }, }, diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index a90f035ee..efb96cc67 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -4,8 +4,23 @@ import Community from './Community' const localVue = global.localVue const mockStoreDispach = jest.fn() +const apolloQueryMock = jest.fn() const apolloMutationMock = jest.fn() -apolloMutationMock.mockResolvedValue('success') +apolloQueryMock.mockResolvedValue({ + data: { + listContributions: [ + { + id: 1555, + amount: '200', + memo: 'Fleisig, fleisig am Arbeiten mein Lieber Freund, 50 Zeichen sind viel', + createdAt: '2022-07-15T08:47:06.000Z', + deletedAt: null, + confirmedBy: null, + confirmedAt: null, + }, + ], + }, +}) describe('Community', () => { let wrapper @@ -14,10 +29,14 @@ describe('Community', () => { $t: jest.fn((t) => t), $d: jest.fn((d) => d), $apollo: { + query: apolloQueryMock, mutate: apolloMutationMock, }, $store: { dispatch: mockStoreDispach, + state: { + creation: ['1000', '1000', '1000'], + }, }, } diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index ddf4333bf..42102a005 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -73,7 +73,7 @@ export default { this.toastError(err.message) }) }, - async updateListContributions(pagination) { + updateListContributions(pagination) { this.$apollo .query({ fetchPolicy: 'no-cache', From 66f10df1d0d656758213eb83ed89b263c77e2ff7 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 15 Jul 2022 11:23:03 +0200 Subject: [PATCH 36/91] improve logic and date handling. use v-model for form --- .../Contributions/ContributionForm.vue | 21 ++++--------------- frontend/src/pages/Community.vue | 5 +++-- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 1a43e87ef..777806c30 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -12,7 +12,6 @@ {{ $t('contribution.formText.text2') }} - {{ id }} diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 42102a005..ee2cc0aff 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -3,7 +3,7 @@
- + Date: Mon, 18 Jul 2022 11:12:21 +0200 Subject: [PATCH 37/91] refactor contribution form --- .../Contributions/ContributionForm.vue | 78 ++++++++++++++----- frontend/src/locales/de.json | 3 +- frontend/src/locales/en.json | 3 +- 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 777806c30..08bfa635e 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -12,14 +12,14 @@ {{ $t('contribution.formText.text2') }}
- +
+ {{ form.memo.length }} {{ $t('math.equalTo') }} {{ minlength }} {{ $t('math.divide') }} {{ maxlength }}
@@ -49,15 +51,39 @@ v-model="form.amount" type="number" min="1" - max="1000" + :max="isThisMonth ? maxGddThisMonth : maxGddLastMonth" > - -
- - {{ $t('contribution.submit') }} - +
+ {{ + isThisMonth && form.amount > maxGddThisMonth + ? $t('contribution.formText.maxGDDforMonth', { amount: maxGddThisMonth }) + : '' + }} + {{ + !isThisMonth && form.amount > maxGddLastMonth + ? $t('contribution.formText.maxGDDforMonth', { amount: maxGddLastMonth }) + : '' + }}
+ + + + {{ $t('form.reset') }} + + + + + {{ id === null ? $t('contribution.submit') : $t('form.edit') }} + + +
@@ -69,36 +95,47 @@ export default { }, data() { return { + maxGddLastMonth: this.$store.state.creation[1], + maxGddThisMonth: this.$store.state.creation[2], minlength: 50, maxlength: 255, - max: new Date(), + maximalDate: new Date(), form: this.value, + id: this.value.id, } }, methods: { submit() { - this.$emit('set-contribution', this.form) + if (this.id === null) { + this.$emit('set-contribution', this.form) + } else { + this.$emit('edit-contribution', this.value) + } + this.reset() + }, + reset() { this.$refs.form.reset() this.form.date = '' + this.id = null + this.form.memo = '' }, }, computed: { /* * lastMonth() = The date set back by one month. - * min() = The date is reset by one month to the 1st of the previous month. + * minimalDate() = The date is reset by one month to the 1st of the previous month. * */ - lastMonth() { - return new Date(this.max.getFullYear(), this.max.getMonth() - 1, 1) - }, - min() { - return new Date(this.max.getFullYear(), this.max.getMonth() - 1, 1) + minimalDate() { + return new Date(this.maximalDate.getFullYear(), this.maximalDate.getMonth() - 1, 1) }, disabled() { if ( this.form.memo.length < this.minlength || this.form.amount <= 0 || - this.form.amount > 1000 + this.form.amount > 1000 || + (this.isThisMonth && this.form.amount > this.maxGddThisMonth) || + (!this.isThisMonth && this.form.amount > this.maxGddlastMonth) ) return true return false @@ -106,7 +143,7 @@ export default { lastMonthObject() { // new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month const obj = { - monthAndYear: this.$d(new Date(this.lastMonth), 'monthAndYear'), + monthAndYear: this.$d(new Date(this.minimalDate), 'monthAndYear'), creation: this.$store.state.creation[1], } return this.$t('contribution.formText.lastMonth', obj) @@ -118,6 +155,9 @@ export default { } return this.$t('contribution.formText.thisMonth', obj) }, + isThisMonth() { + return new Date(this.form.date).getMonth() === new Date().getMonth() + }, }, } diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 5c8b8b366..bc27e4b3e 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -38,7 +38,8 @@ "lastMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen.", "text1": "Bring dich mit deinen Talenten in die Gemeinschaft ein! Dein freiwilliges Engagement honorieren wir mit 20 GDD pro Stunde bis maximal 1.000 GDD im Monat.", "text2": "Beschreibe deine Gemeinwohl-Tätigkeit mit Angabe der Stunden und trage einen Betrag von 20 GDD pro Stunde ein! Nach Bestätigung durch einen Moderator wird der Betrag deinem Konto gutgeschrieben.", - "thisMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen. " + "thisMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen.", + "maxGDDforMonth":"Du kannst für den ausgewählten Monat nur noch maximal {amount} GDD einreichen." }, "noDateSelected": "Kein Datum ausgewählt", "submit": "Einreichen" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 8b0df2595..304cae4c7 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -38,7 +38,8 @@ "lastMonth": "For {monthAndYear}, you can still submit {creation} GDD.", "text1": "Bring your talents to the community! Your voluntary commitment will be rewarded with 20 GDD per hour up to a maximum of 1,000 GDD per month.", "text2": "Describe your community service activity with hours and enter an amount of 20 GDD per hour! After confirmation by a moderator, the amount will be credited to your account.", - "thisMonth": "For {monthAndYear}, you can still submit {creation} GDD." + "thisMonth": "For {monthAndYear}, you can still submit {creation} GDD.", + "maxGDDforMonth":"You can only submit a maximum of {amount} GDD for the selected month." }, "noDateSelected": "No date selected", "submit": "Submit" From 1e4540ef71a23919d99eb5d9335319911f88a29d Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 18 Jul 2022 11:13:11 +0200 Subject: [PATCH 38/91] fix locales --- frontend/src/locales/de.json | 4 ++-- frontend/src/locales/en.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index bc27e4b3e..8676eba9f 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -36,10 +36,10 @@ "formText": { "h3": "Dein Beitrag zum Gemeinwohl", "lastMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen.", + "maxGDDforMonth": "Du kannst für den ausgewählten Monat nur noch maximal {amount} GDD einreichen.", "text1": "Bring dich mit deinen Talenten in die Gemeinschaft ein! Dein freiwilliges Engagement honorieren wir mit 20 GDD pro Stunde bis maximal 1.000 GDD im Monat.", "text2": "Beschreibe deine Gemeinwohl-Tätigkeit mit Angabe der Stunden und trage einen Betrag von 20 GDD pro Stunde ein! Nach Bestätigung durch einen Moderator wird der Betrag deinem Konto gutgeschrieben.", - "thisMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen.", - "maxGDDforMonth":"Du kannst für den ausgewählten Monat nur noch maximal {amount} GDD einreichen." + "thisMonth": "Für {monthAndYear} kannst du noch {creation} GDD einreichen." }, "noDateSelected": "Kein Datum ausgewählt", "submit": "Einreichen" diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 304cae4c7..4282c1086 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -36,10 +36,10 @@ "formText": { "h3": "Your contribution to the common good", "lastMonth": "For {monthAndYear}, you can still submit {creation} GDD.", + "maxGDDforMonth": "You can only submit a maximum of {amount} GDD for the selected month.", "text1": "Bring your talents to the community! Your voluntary commitment will be rewarded with 20 GDD per hour up to a maximum of 1,000 GDD per month.", "text2": "Describe your community service activity with hours and enter an amount of 20 GDD per hour! After confirmation by a moderator, the amount will be credited to your account.", - "thisMonth": "For {monthAndYear}, you can still submit {creation} GDD.", - "maxGDDforMonth":"You can only submit a maximum of {amount} GDD for the selected month." + "thisMonth": "For {monthAndYear}, you can still submit {creation} GDD." }, "noDateSelected": "No date selected", "submit": "Submit" From 951d7f2f884274b5d5ebe4de8285a82a7d76e61a Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 18 Jul 2022 11:27:44 +0200 Subject: [PATCH 39/91] Change the listContribution query to give back ContributionListResult object with linkCount. --- backend/src/graphql/resolver/ContributionResolver.ts | 12 ++++++++---- backend/src/seeds/graphql/queries.ts | 9 ++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index d71ecac59..c834904d6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,6 +2,7 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' +import { User as dbUser } from '@entity/User' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' @@ -39,21 +40,21 @@ export class ContributionResolver { } @Authorized([RIGHTS.LIST_CONTRIBUTIONS]) - @Query(() => [Contribution]) + @Query(() => ContributionListResult) async listContributions( @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, @Arg('filterConfirmed', () => Boolean) filterConfirmed: boolean | null, @Ctx() context: Context, - ): Promise { + ): Promise { const user = getUser(context) const where: { userId: number confirmedBy?: FindOperator | null } = { userId: user.id } if (filterConfirmed) where.confirmedBy = IsNull() - const contributions = await dbContribution.find({ + const [contributions, count] = await dbContribution.findAndCount({ where, order: { createdAt: order, @@ -62,7 +63,10 @@ export class ContributionResolver { skip: (currentPage - 1) * pageSize, take: pageSize, }) - return contributions.map((contribution) => new Contribution(contribution, new User(user))) + return new ContributionListResult( + count, + contributions.map((contribution) => new Contribution(contribution, new User(user))), + ) } @Authorized([RIGHTS.LIST_ALL_CONTRIBUTIONS]) diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index deae5f97b..e18d6b303 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -185,9 +185,12 @@ export const listContributions = gql` order: $order filterConfirmed: $filterConfirmed ) { - id - amount - memo + linkCount + linkList { + id + amount + memo + } } } ` From f1238957f9262b62323341e631d964a302a0c651 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 18 Jul 2022 11:31:04 +0200 Subject: [PATCH 40/91] Change linkCount to contributionCount and linkList to contributionList. --- backend/src/graphql/model/Contribution.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts index 34bffd6d7..13c2d40d7 100644 --- a/backend/src/graphql/model/Contribution.ts +++ b/backend/src/graphql/model/Contribution.ts @@ -48,13 +48,13 @@ export class Contribution { @ObjectType() export class ContributionListResult { constructor(count: number, list: Contribution[]) { - this.linkCount = count - this.linkList = list + this.contributionCount = count + this.contributionList = list } @Field(() => Int) - linkCount: number + contributionCount: number @Field(() => [Contribution]) - linkList: Contribution[] + contributionList: Contribution[] } From b384782e63c83863dcce60540b3fe340e64384a5 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 18 Jul 2022 11:31:39 +0200 Subject: [PATCH 41/91] Change query of listContribution to get contributionCount and contributionList instead of link... --- backend/src/seeds/graphql/queries.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index e18d6b303..0d72c165d 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -185,8 +185,8 @@ export const listContributions = gql` order: $order filterConfirmed: $filterConfirmed ) { - linkCount - linkList { + contributionCount + contributionList { id amount memo From 7d5555c7e40ec621f1f9746a7a155cdecf745de0 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 18 Jul 2022 11:34:30 +0200 Subject: [PATCH 42/91] Change query listAllContributions now gets contributionCount and contributionList instead of linkCount and linkList. --- backend/src/seeds/graphql/queries.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 0d72c165d..9f7a02e70 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -198,8 +198,8 @@ export const listContributions = gql` export const listAllContributions = ` query ($currentPage: Int = 1, $pageSize: Int = 5, $order: Order = DESC) { listAllContributions(currentPage: $currentPage, pageSize: $pageSize, order: $order) { - linkCount - linkList { + contributionCount + contributionList { id firstName lastName From a25d9f73991199607022911f5e450794ad79e2fe Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 18 Jul 2022 11:38:58 +0200 Subject: [PATCH 43/91] Change query fields to new names. --- .../resolver/ContributionResolver.test.ts | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index e6478ffc2..37ff45f25 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -193,18 +193,21 @@ describe('ContributionResolver', () => { ).resolves.toEqual( expect.objectContaining({ data: { - listContributions: expect.arrayContaining([ - expect.objectContaining({ - id: expect.any(Number), - memo: 'Herzlich Willkommen bei Gradido!', - amount: '1000', - }), - expect.objectContaining({ - id: expect.any(Number), - memo: 'Test env contribution', - amount: '100', - }), - ]), + listContributions: { + contributionCount: 2, + contributionList: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, }, }), ) @@ -226,13 +229,16 @@ describe('ContributionResolver', () => { ).resolves.toEqual( expect.objectContaining({ data: { - listContributions: expect.arrayContaining([ - expect.objectContaining({ - id: expect.any(Number), - memo: 'Test env contribution', - amount: '100', - }), - ]), + listContributions: { + contributionCount: 1, + contributionList: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, }, }), ) @@ -496,8 +502,8 @@ describe('ContributionResolver', () => { expect.objectContaining({ data: { listAllContributions: { - linkCount: 2, - linkList: expect.arrayContaining([ + contributionCount: 2, + contributionList: expect.arrayContaining([ expect.objectContaining({ id: expect.any(Number), memo: 'Herzlich Willkommen bei Gradido!', From 93856482853f2f5c00c21ee0857993b7612a8875 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 18 Jul 2022 11:39:17 +0200 Subject: [PATCH 44/91] Remove unused import. --- backend/src/graphql/resolver/ContributionResolver.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index c834904d6..f21c65068 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -2,7 +2,6 @@ import { RIGHTS } from '@/auth/RIGHTS' import { Context, getUser } from '@/server/context' import { backendLogger as logger } from '@/server/logger' import { Contribution as dbContribution } from '@entity/Contribution' -import { User as dbUser } from '@entity/User' import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql' import { FindOperator, IsNull } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' From 70a8f9b0ca06da047b9c645046bb4fff4e75132f Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 18 Jul 2022 11:50:07 +0200 Subject: [PATCH 45/91] change query to get contributionCount and contributionList --- .../Contributions/ContributionList.vue | 2 +- frontend/src/graphql/queries.js | 18 +++++++++++------- frontend/src/pages/Community.vue | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue index c08d22c79..f5aa536ba 100644 --- a/frontend/src/components/Contributions/ContributionList.vue +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -1,6 +1,6 @@