+
+
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/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/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/frontend/src/components/Contributions/ContributionForm.spec.js b/frontend/src/components/Contributions/ContributionForm.spec.js
index 5b05957bb..4f3ee6fa6 100644
--- a/frontend/src/components/Contributions/ContributionForm.spec.js
+++ b/frontend/src/components/Contributions/ContributionForm.spec.js
@@ -23,6 +23,9 @@ describe('ContributionForm', () => {
creation: ['1000', '1000', '1000'],
},
},
+ $i18n: {
+ locale: 'en',
+ },
}
const Wrapper = () => {
diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue
index 6b8ef39d0..f345ffff4 100644
--- a/frontend/src/components/Contributions/ContributionForm.vue
+++ b/frontend/src/components/Contributions/ContributionForm.vue
@@ -18,6 +18,7 @@
id="contribution-date"
v-model="form.date"
size="lg"
+ :locale="$i18n.locale"
:max="maximalDate"
:min="minimalDate"
class="mb-4"
@@ -25,25 +26,27 @@
:label-no-date-selected="$t('contribution.noDateSelected')"
required
>
-
-
-
- {{ form.memo.length }}
- {{ $t('math.lower') }} {{ minlength }}
- {{ $t('math.divide') }} {{ maxlength }}
-
+
+
+
+ {{ error }}
+
+
+
diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json
index ef81d463e..62edd9815 100644
--- a/frontend/src/locales/de.json
+++ b/frontend/src/locales/de.json
@@ -203,10 +203,8 @@
"login": "Anmeldung",
"math": {
"aprox": "~",
- "divide": "/",
"equal": "=",
"exclaim": "!",
- "lower": "<",
"minus": "−",
"pipe": "|"
},
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json
index 47753487d..1cbdc5a8a 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/en.json
@@ -203,10 +203,8 @@
"login": "Login",
"math": {
"aprox": "~",
- "divide": "/",
"equal": "=",
"exclaim": "!",
- "lower": "<",
"minus": "−",
"pipe": "|"
},
diff --git a/frontend/src/pages/Community.spec.js b/frontend/src/pages/Community.spec.js
index d834ddac1..deccabbb1 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 = () => {