diff --git a/CHANGELOG.md b/CHANGELOG.md index 49fdfd07f..63b0c2c90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,55 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.11.0](https://github.com/gradido/gradido/compare/1.10.1...1.11.0) + +- Fix navbar community item [`#2102`](https://github.com/gradido/gradido/pull/2102) +- Add validation date info to copied text after transaction link creation [`#2101`](https://github.com/gradido/gradido/pull/2101) +- Remove member area from menu (desktop and mobile), when user has no elopage account [`#2099`](https://github.com/gradido/gradido/pull/2099) +- fix: Use Inner Join for Contribution and User [`#2100`](https://github.com/gradido/gradido/pull/2100) +- Enable copying the link, username, amount, and memo text after transaction link creation [`#2098`](https://github.com/gradido/gradido/pull/2098) +- feat: Insert Missing Contributions Migration [`#2053`](https://github.com/gradido/gradido/pull/2053) +- [Bug] Wallet improvments for Contributions [`#2090`](https://github.com/gradido/gradido/pull/2090) +- [Fix] Add createdAt & contributionDate to ContributionListItems [`#2093`](https://github.com/gradido/gradido/pull/2093) +- fix: 🍰 Reset Amount In Contribution Form And Write A Test [`#2086`](https://github.com/gradido/gradido/pull/2086) +- [Feat] Replace logic to validation-provider. [`#2088`](https://github.com/gradido/gradido/pull/2088) +- fix: Add Confirm Dialog on Delete Contribution [`#2087`](https://github.com/gradido/gradido/pull/2087) +- fix: Admin Cannot Edit User Contribution [`#2085`](https://github.com/gradido/gradido/pull/2085) +- fix: Update contribution_date when Moved by Seed [`#2083`](https://github.com/gradido/gradido/pull/2083) +- chore: 🍰 Provide Volume For Backend Log-Files In Docker [`#2067`](https://github.com/gradido/gradido/pull/2067) +- feat: 🍰 Community Contribution Site And Form [`#2042`](https://github.com/gradido/gradido/pull/2042) +- [Refactor] Move MEMO_MIN_CHARS and MEMO_MAX_CHARS to const file [`#2082`](https://github.com/gradido/gradido/pull/2082) +- Fix: Test memo length on createContribution & updateContribution [`#2080`](https://github.com/gradido/gradido/pull/2080) +- chore: 🍰 Change `image` Entries In Docker Compose Files And Get Apple M1 Running [`#2050`](https://github.com/gradido/gradido/pull/2050) +- fix: Windows 0D 0A Linebreaks to Unix 0A [`#2064`](https://github.com/gradido/gradido/pull/2064) +- Add contributionDate to the Contribution object. [`#2066`](https://github.com/gradido/gradido/pull/2066) +- fix: Add Contributions to User [`#2062`](https://github.com/gradido/gradido/pull/2062) +- Feat: ContributionResolver - delete mutation [`#2035`](https://github.com/gradido/gradido/pull/2035) +- Fix: Add count to list contributions [`#2061`](https://github.com/gradido/gradido/pull/2061) +- docu: Explain how `.env` Files are Working [`#2022`](https://github.com/gradido/gradido/pull/2022) +- [WIP] 1794 feature event protocol 1 implement the basics of the business event protocol [`#1997`](https://github.com/gradido/gradido/pull/1997) +- docs: 🍰 Document The Setup Of The GraphQL Playground [`#2060`](https://github.com/gradido/gradido/pull/2060) +- Feat: List all contribution [`#2057`](https://github.com/gradido/gradido/pull/2057) +- feat: Do not log IntrospectionQuery from Query Browser [`#2059`](https://github.com/gradido/gradido/pull/2059) +- Feat: Add confirmedBy and confirmedAt for the contribution query. [`#2052`](https://github.com/gradido/gradido/pull/2052) +- Add open creations to webapp [`#2048`](https://github.com/gradido/gradido/pull/2048) +- Prevent session expiration modal from displaying negative seconds, when session is expired for more than 0 seconds [`#2054`](https://github.com/gradido/gradido/pull/2054) +- feat: mutation contribution update [`#2032`](https://github.com/gradido/gradido/pull/2032) +- feat: Login Returns Open Creations for User [`#2046`](https://github.com/gradido/gradido/pull/2046) +- Migrate transaction to valid dataset for gradido node [`#2029`](https://github.com/gradido/gradido/pull/2029) +- feat: implement contribution list query [`#2031`](https://github.com/gradido/gradido/pull/2031) +- add code for moving user creation date if transaction before exist [`#2034`](https://github.com/gradido/gradido/pull/2034) +- change text from page [`#2037`](https://github.com/gradido/gradido/pull/2037) +- Transaction link: copy link, text and more [`#2030`](https://github.com/gradido/gradido/pull/2030) +- change welcome in community text [`#2025`](https://github.com/gradido/gradido/pull/2025) +- changed link color in navbar and language switch [`#2024`](https://github.com/gradido/gradido/pull/2024) +- feat: ContributionResolver - createContribution [`#2009`](https://github.com/gradido/gradido/pull/2009) + #### [1.10.1](https://github.com/gradido/gradido/compare/1.10.0...1.10.1) +> 30 June 2022 + +- release: 1.10.1 [`#2021`](https://github.com/gradido/gradido/pull/2021) - automatic session logout with info modal [`#2001`](https://github.com/gradido/gradido/pull/2001) - 1910 separate text for the slideshow images. [`#1998`](https://github.com/gradido/gradido/pull/1998) - Origin/1921 additional parameter checks for createContributionLinks [`#1996`](https://github.com/gradido/gradido/pull/1996) diff --git a/admin/package.json b/admin/package.json index 50145d44a..5da80bd1f 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "1.10.1", + "version": "1.11.0", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/admin/src/components/Tables/OpenCreationsTable.spec.js b/admin/src/components/Tables/OpenCreationsTable.spec.js index 2b41a9b96..2eb149e4f 100644 --- a/admin/src/components/Tables/OpenCreationsTable.spec.js +++ b/admin/src/components/Tables/OpenCreationsTable.spec.js @@ -28,7 +28,7 @@ const propsData = { amount: 210, memo: 'Aktives Grundeinkommen für Januar 2022', date: '2022-01-01T00:00:00.000Z', - moderator: 1, + moderator: null, creation: [790, 1000, 1000], __typename: 'PendingCreation', }, @@ -66,7 +66,7 @@ const propsData = { }, }, { key: 'moderator', label: 'moderator' }, - { key: 'edit_creation', label: 'edit' }, + { key: 'editCreation', label: 'edit' }, { key: 'confirm', label: 'save' }, ], toggleDetails: false, @@ -113,6 +113,10 @@ describe('OpenCreationsTable', () => { expect(wrapper.findAll('tr').at(1).find('.bi-pencil-square').exists()).toBe(true) }) + it('has no button.bi-pencil-square for user contribution ', () => { + expect(wrapper.findAll('tr').at(2).find('.bi-pencil-square').exists()).toBe(false) + }) + describe('show edit details', () => { beforeEach(async () => { await wrapper.findAll('tr').at(1).find('.bi-pencil-square').trigger('click') diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue index 1e61f00b0..3ebc81fba 100644 --- a/admin/src/components/Tables/OpenCreationsTable.vue +++ b/admin/src/components/Tables/OpenCreationsTable.vue @@ -11,8 +11,14 @@ - diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index fa0ca6903..3d88e0257 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -35,6 +35,7 @@ "creation_form": { "creation_failed": "Ausstehende Schöpfung für {email} konnte nicht erzeugt werden.", "creation_for": "Aktives Grundeinkommen für", + "deleteNow": "Möchtest du diesen Beitrag zur Gemeinschaft wirklich löschen?", "enter_text": "Text eintragen", "form": "Schöpfungsformular", "min_characters": "Mindestens 10 Zeichen eingeben", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 6d19b1732..f23c61e21 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -35,6 +35,7 @@ "creation_form": { "creation_failed": "Could not create pending creation for {email}", "creation_for": "Active Basic Income for", + "deleteNow": "Do you really want to delete this contribution to the community?", "enter_text": "Enter text", "form": "Creation form", "min_characters": "Enter at least 10 characters", diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 9e554ff92..26d44fd3e 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -29,6 +29,7 @@ per-page="perPage" :total-rows="rows" align="center" + :hide-ellipsis="true" > diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 632f19ff9..352eba809 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -18,7 +18,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ amount: 500, memo: 'Danke für alles', date: new Date(), - moderator: 0, + moderator: 2, }, { id: 2, @@ -28,7 +28,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ amount: 1000000, memo: 'Gut Ergattert', date: new Date(), - moderator: 0, + moderator: 2, }, ], }, @@ -80,28 +80,54 @@ describe('CreationConfirm', () => { }) describe('remove creation with success', () => { - beforeEach(async () => { - await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') - }) + let spy - it('calls the adminDeleteContribution mutation', () => { - expect(apolloMutateMock).toBeCalledWith({ - mutation: adminDeleteContribution, - variables: { id: 1 }, + describe('admin confirms deletion', () => { + beforeEach(async () => { + spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm') + spy.mockImplementation(() => Promise.resolve('some value')) + await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') + }) + + it('opens a modal', () => { + expect(spy).toBeCalled() + }) + + it('calls the adminDeleteContribution mutation', () => { + expect(apolloMutateMock).toBeCalledWith({ + mutation: adminDeleteContribution, + variables: { id: 1 }, + }) + }) + + it('commits openCreationsMinus to store', () => { + expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_delete') }) }) - it('commits openCreationsMinus to store', () => { - expect(storeCommitMock).toBeCalledWith('openCreationsMinus', 1) - }) + describe('admin cancels deletion', () => { + beforeEach(async () => { + spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm') + spy.mockImplementation(() => Promise.resolve(false)) + await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') + }) - it('toasts a success message', () => { - expect(toastSuccessSpy).toBeCalledWith('creation_form.toasted_delete') + it('does not call the adminDeleteContribution mutation', () => { + expect(apolloMutateMock).not.toBeCalled() + }) }) }) describe('remove creation with error', () => { + let spy + beforeEach(async () => { + spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm') + spy.mockImplementation(() => Promise.resolve('some value')) apolloMutateMock.mockRejectedValue({ message: 'Ouchhh!' }) await wrapper.findAll('tr').at(1).findAll('button').at(0).trigger('click') }) diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 061556ba1..c07e6b351 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -34,20 +34,23 @@ export default { }, methods: { removeCreation(item) { - this.$apollo - .mutate({ - mutation: adminDeleteContribution, - variables: { - id: item.id, - }, - }) - .then((result) => { - this.updatePendingCreations(item.id) - this.toastSuccess(this.$t('creation_form.toasted_delete')) - }) - .catch((error) => { - this.toastError(error.message) - }) + this.$bvModal.msgBoxConfirm(this.$t('creation_form.deleteNow')).then(async (value) => { + if (value) + await this.$apollo + .mutate({ + mutation: adminDeleteContribution, + variables: { + id: item.id, + }, + }) + .then((result) => { + this.updatePendingCreations(item.id) + this.toastSuccess(this.$t('creation_form.toasted_delete')) + }) + .catch((error) => { + this.toastError(error.message) + }) + }) }, confirmCreation() { this.$apollo @@ -114,7 +117,7 @@ export default { }, }, { key: 'moderator', label: this.$t('moderator') }, - { key: 'edit_creation', label: this.$t('edit') }, + { key: 'editCreation', label: this.$t('edit') }, { key: 'confirm', label: this.$t('save') }, ] }, diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index 8eb1f9c63..df49526d7 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -52,6 +52,7 @@ per-page="perPage" :total-rows="rows" align="center" + :hide-ellipsis="true" >
diff --git a/backend/package.json b/backend/package.json index 50f26351d..c56c8e960 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "gradido-backend", - "version": "1.10.1", + "version": "1.11.0", "description": "Gradido unified backend providing an API-Service for Gradido Transactions", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/backend", diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 313c26149..f44aa584c 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0043-add_event_protocol_table', + DB_VERSION: '0044-insert_missing_contributions', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index a22715fb4..3307252e4 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -3,7 +3,7 @@ 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, Int, Mutation, Query, Resolver } from 'type-graphql' -import { FindOperator, IsNull } from '@dbTools/typeorm' +import { FindOperator, IsNull, getConnection } from '@dbTools/typeorm' import ContributionArgs from '@arg/ContributionArgs' import Paginated from '@arg/Paginated' import { Order } from '@enum/Order' @@ -106,14 +106,15 @@ export class ContributionResolver { @Args() { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, ): Promise { - const [dbContributions, count] = await dbContribution.findAndCount({ - relations: ['user'], - order: { - createdAt: order, - }, - skip: (currentPage - 1) * pageSize, - take: pageSize, - }) + const [dbContributions, count] = await getConnection() + .createQueryBuilder() + .select('c') + .from(dbContribution, 'c') + .innerJoinAndSelect('c.user', 'u') + .orderBy('c.createdAt', order) + .limit(pageSize) + .offset((currentPage - 1) * pageSize) + .getManyAndCount() return new ContributionListResult( count, dbContributions.map( diff --git a/backend/src/seeds/factory/creation.ts b/backend/src/seeds/factory/creation.ts index 75a765fae..d3f0f78ca 100644 --- a/backend/src/seeds/factory/creation.ts +++ b/backend/src/seeds/factory/creation.ts @@ -35,12 +35,17 @@ export const creationFactory = async ( if (creation.confirmed) { await mutate({ mutation: confirmContribution, variables: { id: pendingCreation.id } }) + const confirmedCreation = await Contribution.findOneOrFail({ id: pendingCreation.id }) + if (creation.moveCreationDate) { const transaction = await Transaction.findOneOrFail({ where: { userId: user.id, creationDate: new Date(creation.creationDate) }, order: { balanceDate: 'DESC' }, }) if (transaction.decay.equals(0) && transaction.creationDate) { + confirmedCreation.contributionDate = new Date( + nMonthsBefore(transaction.creationDate, creation.moveCreationDate), + ) transaction.creationDate = new Date( nMonthsBefore(transaction.creationDate, creation.moveCreationDate), ) @@ -48,6 +53,7 @@ export const creationFactory = async ( nMonthsBefore(transaction.balanceDate, creation.moveCreationDate), ) await transaction.save() + await confirmedCreation.save() } } } else { diff --git a/database/migrations/0044-insert_missing_contributions.ts b/database/migrations/0044-insert_missing_contributions.ts new file mode 100644 index 000000000..a14141498 --- /dev/null +++ b/database/migrations/0044-insert_missing_contributions.ts @@ -0,0 +1,34 @@ +/* MIGRATION TO INSERT contributions for all transactions with type creation that do not have a contribution yet */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + `INSERT INTO gradido_community.contributions + (user_id, created_at, contribution_date, memo, amount, moderator_id, confirmed_by, confirmed_at, transaction_id) +SELECT + user_id, + balance_date, + creation_date AS contribution_date, + memo, + amount, + 20 AS moderator_id, + 502 AS confirmed_by, + balance_date AS confirmed_at, + id +FROM + gradido_community.transactions +WHERE + type_id = 1 + AND NOT EXISTS( + SELECT * FROM gradido_community.contributions + WHERE gradido_community.contributions.transaction_id = gradido_community.transactions.id);`, + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'DELETE FROM `contributions` WHERE `contributions`.`moderator_id` = 20 AND `contributions`.`confirmed_by` = 502 AND `contributions`.`created_at` = `contributions`.`confirmed_at`;', + ) +} diff --git a/database/package.json b/database/package.json index 23ab63f2b..05e1c2ac8 100644 --- a/database/package.json +++ b/database/package.json @@ -1,6 +1,6 @@ { "name": "gradido-database", - "version": "1.10.1", + "version": "1.11.0", "description": "Gradido Database Tool to execute database migrations", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/database", diff --git a/frontend/package.json b/frontend/package.json index f51dd8266..71baf4764 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-vue-gradido-wallet", - "version": "1.10.1", + "version": "1.11.0", "private": true, "scripts": { "start": "node run/server.js", diff --git a/frontend/src/components/ClipboardCopy.vue b/frontend/src/components/ClipboardCopy.vue index 7a6cf0ec1..ebab31aad 100644 --- a/frontend/src/components/ClipboardCopy.vue +++ b/frontend/src/components/ClipboardCopy.vue @@ -3,8 +3,11 @@ - - {{ $t('gdd_per_link.copy') }} + + {{ $t('gdd_per_link.copy-link-with-text') }} + + + {{ $t('gdd_per_link.copy-link') }} @@ -18,29 +21,10 @@ diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue index 097452194..cf8606e33 100644 --- a/frontend/src/components/Contributions/ContributionList.vue +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -16,6 +16,7 @@ :per-page="pageSize" :total-rows="contributionCount" align="center" + :hide-ellipsis="true" > diff --git a/frontend/src/components/Contributions/ContributionListItem.spec.js b/frontend/src/components/Contributions/ContributionListItem.spec.js index 20f4db959..59918e762 100644 --- a/frontend/src/components/Contributions/ContributionListItem.spec.js +++ b/frontend/src/components/Contributions/ContributionListItem.spec.js @@ -13,6 +13,7 @@ describe('ContributionListItem', () => { const propsData = { id: 1, + createdAt: '26/07/2022', contributionDate: '07/06/2022', memo: 'Ich habe 10 Stunden die Elbwiesen von Müll befreit.', amount: '200', @@ -84,21 +85,9 @@ describe('ContributionListItem', () => { }) }) - describe('contribution date', () => { - it('is contributionDate by default', () => { - expect(wrapper.vm.date).toBe(wrapper.vm.contributionDate) - }) - - it('is deletedAt when deletedAt is present', async () => { - const now = new Date().toISOString() - await wrapper.setProps({ deletedAt: now }) - expect(wrapper.vm.date).toBe(now) - }) - - it('is confirmedAt at when confirmedAt is present', async () => { - const now = new Date().toISOString() - await wrapper.setProps({ confirmedAt: now }) - expect(wrapper.vm.date).toBe(now) + describe('date', () => { + it('is equal to createdAt', () => { + expect(wrapper.vm.date).toBe(wrapper.vm.createdAt) }) }) diff --git a/frontend/src/components/Contributions/ContributionListItem.vue b/frontend/src/components/Contributions/ContributionListItem.vue index ca766a008..90e98bc4c 100644 --- a/frontend/src/components/Contributions/ContributionListItem.vue +++ b/frontend/src/components/Contributions/ContributionListItem.vue @@ -11,6 +11,12 @@ {{ $t('math.minus') }}
{{ $d(new Date(date), 'short') }}
+
+ {{ $t('contribution.date') }} + + {{ $d(new Date(contributionDate), 'monthAndYear') }} + +
{{ memo }}
{{ $t('gdd_per_link.created') }}
- +
@@ -27,10 +33,10 @@ export default { FigureQrCode, }, props: { - link: { - type: String, - required: true, - }, + link: { type: String, required: true }, + amount: { type: String, required: true }, + memo: { type: String, required: true }, + validUntil: { type: String, required: true }, }, data() { return { diff --git a/frontend/src/components/GddTransactionList.vue b/frontend/src/components/GddTransactionList.vue index 5becfa39e..a74be5187 100644 --- a/frontend/src/components/GddTransactionList.vue +++ b/frontend/src/components/GddTransactionList.vue @@ -69,6 +69,7 @@ :per-page="pageSize" :total-rows="transactionCount" align="center" + :hide-ellipsis="true" >
diff --git a/frontend/src/components/GdtTransactionList.vue b/frontend/src/components/GdtTransactionList.vue index 4934f9fce..f915cd881 100644 --- a/frontend/src/components/GdtTransactionList.vue +++ b/frontend/src/components/GdtTransactionList.vue @@ -36,6 +36,7 @@ :per-page="pageSize" :total-rows="transactionGdtCount" align="center" + :hide-ellipsis="true" >
diff --git a/frontend/src/components/Menu/Navbar.spec.js b/frontend/src/components/Menu/Navbar.spec.js index ebf9abba0..3f12682c0 100644 --- a/frontend/src/components/Menu/Navbar.spec.js +++ b/frontend/src/components/Menu/Navbar.spec.js @@ -17,7 +17,7 @@ const mocks = { $t: jest.fn((t) => t), $store: { state: { - hasElopage: false, + hasElopage: true, isAdmin: true, }, }, @@ -39,15 +39,17 @@ describe('Navbar', () => { expect(wrapper.find('div.component-navbar').exists()).toBeTruthy() }) - describe('navigation Navbar', () => { + describe('navigation Navbar (general elements)', () => { it('has .navbar-brand in the navbar', () => { expect(wrapper.find('.navbar-brand').exists()).toBeTruthy() }) + it('has b-navbar-toggle in the navbar', () => { expect(wrapper.find('.navbar-toggler').exists()).toBeTruthy() }) + it('has ten b-nav-item in the navbar', () => { - expect(wrapper.findAll('.nav-item')).toHaveLength(10) + expect(wrapper.findAll('.nav-item')).toHaveLength(11) }) it('has first nav-item "amount GDD" in navbar', () => { @@ -57,31 +59,57 @@ describe('Navbar', () => { it('has first nav-item "navigation.overview" in navbar', () => { expect(wrapper.findAll('.nav-item').at(3).text()).toEqual('navigation.overview') }) + it('has first nav-item "navigation.send" in navbar', () => { expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.send') }) + it('has first nav-item "navigation.transactions" in navbar', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.transactions') }) - it('has first nav-item "navigation.profile" in navbar', () => { - expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.profile') + + it('has first nav-item "navigation.transactions" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(6).text()).toEqual('navigation.community') }) + it('has first nav-item "navigation.profile" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.profile') + }) + }) + + describe('navigation Navbar (user has an elopage account)', () => { it('has a link to the members area', () => { - expect(wrapper.findAll('.nav-item').at(7).text()).toContain('navigation.members_area') - expect(wrapper.findAll('.nav-item').at(7).find('a').attributes('href')).toBe( + expect(wrapper.findAll('.nav-item').at(8).text()).toContain('navigation.members_area') + expect(wrapper.findAll('.nav-item').at(8).find('a').attributes('href')).toBe( 'https://elopage.com', ) }) + it('has first nav-item "navigation.admin_area" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.admin_area') + }) + + it('has first nav-item "navigation.logout" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(10).text()).toEqual('navigation.logout') + }) + }) + + describe('navigation Navbar (user has no elopage account)', () => { + beforeAll(() => { + mocks.$store.state.hasElopage = false + wrapper = Wrapper() + }) + it('has first nav-item "navigation.admin_area" in navbar', () => { expect(wrapper.findAll('.nav-item').at(8).text()).toEqual('navigation.admin_area') }) + it('has first nav-item "navigation.logout" in navbar', () => { expect(wrapper.findAll('.nav-item').at(9).text()).toEqual('navigation.logout') }) }) }) + describe('check watch visible true', () => { beforeEach(async () => { await wrapper.setProps({ visible: true }) diff --git a/frontend/src/components/Menu/Navbar.vue b/frontend/src/components/Menu/Navbar.vue index 2f26f381e..ef222fdb4 100644 --- a/frontend/src/components/Menu/Navbar.vue +++ b/frontend/src/components/Menu/Navbar.vue @@ -52,17 +52,18 @@ {{ $t('navigation.transactions') }} + + + {{ $t('navigation.community') }} + {{ $t('navigation.profile') }}
- + {{ $t('navigation.members_area') }} - - {{ $t('math.exclaim') }} - diff --git a/frontend/src/components/Menu/Sidebar.spec.js b/frontend/src/components/Menu/Sidebar.spec.js index f6051c733..1593a79a8 100644 --- a/frontend/src/components/Menu/Sidebar.spec.js +++ b/frontend/src/components/Menu/Sidebar.spec.js @@ -27,15 +27,12 @@ describe('Sidebar', () => { beforeEach(() => { wrapper = Wrapper() }) + it('renders the component', () => { expect(wrapper.find('div#component-sidebar').exists()).toBeTruthy() }) - describe('navigation Navbar', () => { - it('has seven b-nav-item in the navbar', () => { - expect(wrapper.findAll('.nav-item')).toHaveLength(8) - }) - + describe('navigation Navbar (general elements)', () => { it('has first nav-item "navigation.overview" in navbar', () => { expect(wrapper.findAll('.nav-item').at(0).text()).toEqual('navigation.overview') }) @@ -55,6 +52,12 @@ describe('Sidebar', () => { it('has first nav-item "navigation.profile" in navbar', () => { expect(wrapper.findAll('.nav-item').at(4).text()).toEqual('navigation.profile') }) + }) + + describe('navigation Navbar (user has an elopage account)', () => { + it('has eight b-nav-item in the navbar', () => { + expect(wrapper.findAll('.nav-item')).toHaveLength(8) + }) it('has a link to the members area', () => { expect(wrapper.findAll('.nav-item').at(5).text()).toEqual('navigation.members_area') @@ -69,5 +72,24 @@ describe('Sidebar', () => { expect(wrapper.findAll('.nav-item').at(7).text()).toEqual('navigation.logout') }) }) + + describe('navigation Navbar (user has no elopage account)', () => { + beforeAll(() => { + mocks.$store.state.hasElopage = false + wrapper = Wrapper() + }) + + it('has seven b-nav-item in the navbar', () => { + expect(wrapper.findAll('.nav-item')).toHaveLength(7) + }) + + it('has first nav-item "navigation.admin_area" in navbar', () => { + expect(wrapper.findAll('.nav-item').at(5).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') + }) + }) }) }) diff --git a/frontend/src/components/Menu/Sidebar.vue b/frontend/src/components/Menu/Sidebar.vue index b54eb541e..00243fa49 100644 --- a/frontend/src/components/Menu/Sidebar.vue +++ b/frontend/src/components/Menu/Sidebar.vue @@ -27,12 +27,14 @@
- + {{ $t('navigation.members_area') }} - - {{ $t('math.exclaim') }} - diff --git a/frontend/src/components/TransactionLinks/TransactionLink.vue b/frontend/src/components/TransactionLinks/TransactionLink.vue index 5618c8696..76f705e35 100644 --- a/frontend/src/components/TransactionLinks/TransactionLink.vue +++ b/frontend/src/components/TransactionLinks/TransactionLink.vue @@ -18,17 +18,17 @@ - + - {{ $t('gdd_per_link.copy') }} + {{ $t('gdd_per_link.copy-link') }} - {{ $t('gdd_per_link.copy-with-text') }} + {{ $t('gdd_per_link.copy-link-with-text') }} { - this.toastSuccess(this.$t('gdd_per_link.link-copied')) - }) - .catch(() => { - this.$bvModal.show('modalPopoverCopyError' + this.id) - this.toastError(this.$t('gdd_per_link.not-copied')) - }) - }, - copyLinkWithText() { - navigator.clipboard - .writeText( - `${this.link} -${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. -"${this.memo}" -${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { - date: this.$d(new Date(this.validUntil), 'short'), - })}`, - ) - .then(() => { - this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) - }) - .catch(() => { - this.$bvModal.show('modalPopoverCopyError' + this.id) - this.toastError(this.$t('gdd_per_link.not-copied')) - }) - }, deleteLink() { this.$bvModal.msgBoxConfirm(this.$t('gdd_per_link.delete-the-link')).then(async (value) => { if (value) diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index ec1f5a410..959bdefc3 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -74,6 +74,9 @@ export const createTransactionLink = gql` mutation($amount: Decimal!, $memo: String!) { createTransactionLink(amount: $amount, memo: $memo) { link + amount + memo + validUntil } } ` diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index ef81d463e..07d8c4dcf 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -26,7 +26,7 @@ "community": "Gemeinschaft", "continue-to-registration": "Weiter zur Registrierung", "current-community": "Aktuelle Gemeinschaft", - "myContributions": "Meine Beiträge", + "myContributions": "Meine Beiträge zum Gemeinwohl", "other-communities": "Weitere Gemeinschaften", "submitContribution": "Beitrag einreichen", "switch-to-this-community": "zu dieser Gemeinschaft wechseln" @@ -36,11 +36,12 @@ "alert": { "communityNoteList": "Hier findest du alle eingereichten und bestätigten Beiträge von allen Mitgliedern aus dieser Gemeinschaft.", "confirm": "bestätigt", - "myContributionNoteList": "Hier findest du chronologisch aufgelistet alle deine eingereichten Beiträge. Es gibt drei Darstellungsarten. Du kannst deine Beiträge, welche noch nicht bestätigt wurden, jederzeit bearbeiten.", + "myContributionNoteList": "Eingereichte Beiträge, die noch nicht bestätigt wurden, kannst du jederzeit bearbeiten oder löschen.", "myContributionNoteSupport": "Es wird bald an dieser Stelle die Möglichkeit geben das ein Dialog zwischen Moderatoren und dir stattfinden kann. Solltest du jetzt Probleme haben bitte nimm Kontakt mit dem Support auf.", "pending": "Eingereicht und wartet auf Bestätigung", "rejected": "abgelehnt" }, + "date": "Beitrag für:", "delete": "Beitrag löschen! Bist du sicher?", "deleted": "Der Beitrag wurde gelöscht! Wird aber sichtbar bleiben.", "formText": { @@ -54,7 +55,8 @@ "selectDate": "Wann war dein Beitrag?", "submit": "Einreichen", "submitted": "Der Beitrag wurde eingereicht.", - "updated": "Der Beitrag wurde geändert." + "updated": "Der Beitrag wurde geändert.", + "yourActivity": "Bitte trage eine Tätigkeit ein!" }, "contribution-link": { "thanksYouWith": "dankt dir mit" @@ -105,17 +107,18 @@ "amount": "Betrag", "at": "am", "cancel": "Abbrechen", + "change": "Ändern", "check_now": "Jetzt prüfen", "close": "Schließen", "current_balance": "Aktueller Kontostand", "date": "Datum", "description": "Beschreibung", - "edit": "Bearbeiten", "email": "E-Mail", "firstname": "Vorname", "from": "Von", "generate_now": "Jetzt generieren", "lastname": "Nachname", + "mandatoryField": "Pflichtfeld", "memo": "Nachricht", "message": "Nachricht", "new_balance": "Neuer Kontostand nach Bestätigung", @@ -150,8 +153,8 @@ "GDD": "GDD", "gdd_per_link": { "choose-amount": "Wähle einen Betrag aus, welchen du per Link versenden möchtest. Du kannst auch noch eine Nachricht eintragen. Beim Klick „Jetzt generieren“ wird ein Link erstellt, den du versenden kannst.", - "copy": "kopieren", - "copy-with-text": "Link und Text kopieren", + "copy-link": "Link kopieren", + "copy-link-with-text": "Link und Text kopieren", "created": "Der Link wurde erstellt!", "credit-your-gradido": "Damit die Gradido gutgeschrieben werden können, klicke auf den Link!", "decay-14-day": "Vergänglichkeit für 14 Tage", @@ -203,10 +206,8 @@ "login": "Anmeldung", "math": { "aprox": "~", - "divide": "/", + "asterisk": "*", "equal": "=", - "exclaim": "!", - "lower": "<", "minus": "−", "pipe": "|" }, diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 47753487d..e7dc8ee38 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -26,7 +26,7 @@ "community": "Community", "continue-to-registration": "Continue to registration", "current-community": "Current community", - "myContributions": "My contributions", + "myContributions": "My contributions to the common good", "other-communities": "Other communities", "submitContribution": "Submit contribution", "switch-to-this-community": "Switch to this community" @@ -36,11 +36,12 @@ "alert": { "communityNoteList": "Here you will find all submitted and confirmed contributions from all members of this community.", "confirm": "confirmed", - "myContributionNoteList": "Here you will find a chronological list of all your submitted contributions. There are three display types. There are three ways of displaying your posts. You can edit your contributions, which have not yet been confirmed, at any time.", + "myContributionNoteList": "You can edit or delete entries that have not yet been confirmed at any time.", "myContributionNoteSupport": "Soon there will be the possibility for a dialogue between moderators and you. If you have any problems now, please contact the support.", "pending": "Submitted and waiting for confirmation", "rejected": "deleted" }, + "date": "Contribution for:", "delete": "Delete Contribution! Are you sure?", "deleted": "The contribution has been deleted! But it will remain visible.", "formText": { @@ -54,7 +55,8 @@ "selectDate": "When was your contribution?", "submit": "Submit", "submitted": "The contribution was submitted.", - "updated": "The contribution was changed." + "updated": "The contribution was changed.", + "yourActivity": "Please enter an activity!" }, "contribution-link": { "thanksYouWith": "thanks you with" @@ -105,17 +107,18 @@ "amount": "Amount", "at": "at", "cancel": "Cancel", + "change": "Change", "check_now": "Check now", "close": "Close", "current_balance": "Current Balance", "date": "Date", "description": "Description", - "edit": "Edit", "email": "Email", "firstname": "Firstname", "from": "from", "generate_now": "Generate now", "lastname": "Lastname", + "mandatoryField": "mandatory field", "memo": "Message", "message": "Message", "new_balance": "Account balance after confirmation", @@ -150,8 +153,8 @@ "GDD": "GDD", "gdd_per_link": { "choose-amount": "Select an amount that you would like to send via link. You can also enter a message. Click 'Generate now' to create a link that you can share.", - "copy": "copy", - "copy-with-text": "Copy link and text", + "copy-link": "Copy link", + "copy-link-with-text": "Copy link and text", "created": "Link was created!", "credit-your-gradido": "For the Gradido to be credited, click on the link!", "decay-14-day": "Decay for 14 days", @@ -203,10 +206,8 @@ "login": "Login", "math": { "aprox": "~", - "divide": "/", + "asterisk": "*", "equal": "=", - "exclaim": "!", - "lower": "<", "minus": "−", "pipe": "|" }, diff --git a/frontend/src/mixins/copyLinks.js b/frontend/src/mixins/copyLinks.js new file mode 100644 index 000000000..415358c9b --- /dev/null +++ b/frontend/src/mixins/copyLinks.js @@ -0,0 +1,44 @@ +export const copyLinks = { + props: { + link: { type: String, required: true }, + amount: { type: String, required: true }, + memo: { type: String, required: true }, + validUntil: { type: String, required: true }, + }, + data() { + return { + canCopyLink: true, + } + }, + methods: { + copyLink() { + navigator.clipboard + .writeText(this.link) + .then(() => { + this.toastSuccess(this.$t('gdd_per_link.link-copied')) + }) + .catch(() => { + this.canCopyLink = false + this.toastError(this.$t('gdd_per_link.not-copied')) + }) + }, + copyLinkWithText() { + navigator.clipboard + .writeText( + `${this.link} +${this.$store.state.firstName} ${this.$t('transaction-link.send_you')} ${this.amount} Gradido. +"${this.memo}" +${this.$t('gdd_per_link.credit-your-gradido')} ${this.$t('gdd_per_link.validUntilDate', { + date: this.$d(new Date(this.validUntil), 'short'), + })}`, + ) + .then(() => { + this.toastSuccess(this.$t('gdd_per_link.link-and-text-copied')) + }) + .catch(() => { + this.canCopyLink = false + this.toastError(this.$t('gdd_per_link.not-copied')) + }) + }, + }, +} diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js index d834ddac1..b4aa43785 100644 --- a/frontend/src/pages/Community.spec.js +++ b/frontend/src/pages/Community.spec.js @@ -26,6 +26,9 @@ describe('Community', () => { creation: ['1000', '1000', '1000'], }, }, + $i18n: { + locale: 'en', + }, } const Wrapper = () => { @@ -190,6 +193,13 @@ describe('Community', () => { fetchPolicy: 'network-only', }) }) + + it('set all data to the default values)', () => { + expect(wrapper.vm.form.id).toBe(null) + expect(wrapper.vm.form.date).toBe('') + expect(wrapper.vm.form.memo).toBe('') + expect(wrapper.vm.form.amount).toBe('') + }) }) describe('with error', () => { @@ -270,6 +280,13 @@ describe('Community', () => { fetchPolicy: 'network-only', }) }) + + it('set all data to the default values)', () => { + expect(wrapper.vm.form.id).toBe(null) + expect(wrapper.vm.form.date).toBe('') + expect(wrapper.vm.form.memo).toBe('') + expect(wrapper.vm.form.amount).toBe('') + }) }) describe('with error', () => { @@ -376,7 +393,7 @@ describe('Community', () => { }) }) - it('sets the form date to the new values', () => { + it('sets the form data to the new values', () => { expect(wrapper.vm.form.id).toBe(2) expect(wrapper.vm.form.date).toBe(now) expect(wrapper.vm.form.memo).toBe('Mein Beitrag zur Gemeinschaft für diesen Monat ...') diff --git a/frontend/src/pages/Send.spec.js b/frontend/src/pages/Send.spec.js index 47a30ff65..0738d9720 100644 --- a/frontend/src/pages/Send.spec.js +++ b/frontend/src/pages/Send.spec.js @@ -25,9 +25,11 @@ describe('Send', () => { const mocks = { $t: jest.fn((t) => t), $n: jest.fn((n) => String(n)), + $d: jest.fn((d) => d), $store: { state: { email: 'sender@example.org', + firstName: 'Testy', }, }, $apollo: { @@ -160,11 +162,15 @@ describe('Send', () => { }) describe('transaction form link', () => { + const now = new Date().toISOString() beforeEach(async () => { apolloMutationMock.mockResolvedValue({ data: { createTransactionLink: { link: 'http://localhost/redeem/0123456789', + amount: '56.78', + memo: 'Make the best of the link!', + validUntil: now, }, }, }) @@ -228,18 +234,64 @@ describe('Send', () => { navigator.clipboard = navigatorClipboard }) - describe('copy with success', () => { + describe('copy link with success', () => { beforeEach(async () => { navigatorClipboardMock.mockResolvedValue() - await wrapper.findAll('button').at(0).trigger('click') + await wrapper.findAll('button').at(1).trigger('click') }) + it('should call clipboard.writeText', () => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith( + 'http://localhost/redeem/0123456789', + ) + }) it('toasts success message', () => { expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-copied') }) }) - describe('copy with error', () => { + describe('copy link with error', () => { + beforeEach(async () => { + navigatorClipboardMock.mockRejectedValue() + await wrapper.findAll('button').at(1).trigger('click') + }) + + it('toasts error message', () => { + expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied') + }) + }) + }) + + describe('copy link and text with success', () => { + const navigatorClipboard = navigator.clipboard + beforeAll(() => { + delete navigator.clipboard + navigator.clipboard = { writeText: navigatorClipboardMock } + }) + afterAll(() => { + navigator.clipboard = navigatorClipboard + }) + + describe('copy link and text with success', () => { + beforeEach(async () => { + navigatorClipboardMock.mockResolvedValue() + await wrapper.findAll('button').at(0).trigger('click') + }) + + it('should call clipboard.writeText', () => { + expect(navigator.clipboard.writeText).toHaveBeenCalledWith( + 'http://localhost/redeem/0123456789\n' + + 'Testy transaction-link.send_you 56.78 Gradido.\n' + + '"Make the best of the link!"\n' + + 'gdd_per_link.credit-your-gradido gdd_per_link.validUntilDate', + ) + }) + it('toasts success message', () => { + expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-and-text-copied') + }) + }) + + describe('copy link and text with error', () => { beforeEach(async () => { navigatorClipboardMock.mockRejectedValue() await wrapper.findAll('button').at(0).trigger('click') @@ -253,7 +305,7 @@ describe('Send', () => { describe('close button click', () => { beforeEach(async () => { - await wrapper.findAll('button').at(2).trigger('click') + await wrapper.findAll('button').at(3).trigger('click') }) it('Shows the TransactionForm', () => { diff --git a/frontend/src/pages/Send.vue b/frontend/src/pages/Send.vue index cd5f8f572..74e2b0270 100644 --- a/frontend/src/pages/Send.vue +++ b/frontend/src/pages/Send.vue @@ -41,7 +41,13 @@ >
@@ -144,7 +150,15 @@ export default { }) .then((result) => { this.$emit('set-tunneled-email', null) - this.link = result.data.createTransactionLink.link + const { + data: { + createTransactionLink: { link, amount, memo, validUntil }, + }, + } = result + this.link = link + this.amount = amount + this.memo = memo + this.validUntil = validUntil this.transactionData = { ...EMPTY_TRANSACTION_DATA } this.currentTransactionStep = TRANSACTION_STEPS.transactionResultLink this.updateTransactions({}) diff --git a/package.json b/package.json index bf8eced01..2bba1b52c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gradido", - "version": "1.10.1", + "version": "1.11.0", "description": "Gradido", "main": "index.js", "repository": "git@github.com:gradido/gradido.git",