@@ -92,6 +95,7 @@
v-if="pagetype === 'PageCreationConfirm'"
type="button"
variant="success"
+ class="test-submit"
@click="submitCreation"
:disabled="radioSelected === '' || value <= 0 || text.length < 10"
>
@@ -102,6 +106,7 @@
v-else
type="button"
variant="success"
+ class="test-submit"
@click="submitCreation"
:disabled="radioSelected === '' || value <= 0 || text.length < 10"
>
@@ -159,7 +164,7 @@ export default {
return {
radioSelected: '',
text: !this.creationUserData.memo ? '' : this.creationUserData.memo,
- value: !this.creationUserData.amount ? 0 : this.creationUserData.amount / 10000,
+ value: !this.creationUserData.amount ? 0 : this.creationUserData.amount,
rangeMin: 0,
rangeMax: 1000,
currentMonth: {
@@ -195,28 +200,12 @@ export default {
}
},
submitCreation() {
- // Formular Prüfen ob ein Zeitraum ausgewählt wurde. Ansonsten abbrechen und Hinweis anzeigen
- if (this.radioSelected === '') {
- return alert('Bitte wähle einen Zeitraum!')
- }
- // Formular Prüfen ob der GDD Betrag grösser 0 ist. Ansonsten abbrechen und Hinweis anzeigen
- if (this.value === 0) {
- return alert('Bitte gib einen GDD Betrag an!')
- }
- // Formular Prüfen ob der Text vorhanden ist. Ansonsten abbrechen und Hinweis anzeigen
- if (this.text === '') {
- return alert('Bitte gib einen Text ein!')
- }
- // Formular Prüfen ob der Text länger als 10 Zeichen hat. Ansonsten abbrechen und Hinweis anzeigen
- if (this.text.length < 10) {
- return alert('Bitte gib einen Text ein der länger als 10 Zeichen ist!')
- }
-
if (this.type === 'massCreation') {
// Die anzahl der Mitglieder aus der Mehrfachschöpfung
const i = Object.keys(this.itemsMassCreation).length
// hinweis das eine Mehrfachschöpfung ausgeführt wird an (Anzahl der MItgleider an die geschöpft wird)
- alert('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder')
+ // eslint-disable-next-line no-console
+ console.log('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder')
this.submitObj = [
{
item: this.itemsMassCreation,
@@ -227,7 +216,8 @@ export default {
moderator: this.$store.state.moderator.id,
},
]
- alert('MehrfachSCHÖPFUNG ABSENDEN FÜR >> ' + i + ' Mitglieder')
+ // eslint-disable-next-line no-console
+ console.log('MehrfachSCHÖPFUNG ABSENDEN FÜR >> ' + i + ' Mitglieder')
// $store - offene Schöpfungen hochzählen
this.$store.commit('openCreationsPlus', i)
diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js
index 61536dab2..50704ed76 100644
--- a/admin/src/components/EditCreationFormular.spec.js
+++ b/admin/src/components/EditCreationFormular.spec.js
@@ -15,6 +15,7 @@ const apolloMutateMock = jest.fn().mockResolvedValue({
})
const stateCommitMock = jest.fn()
+const toastedErrorMock = jest.fn()
const mocks = {
$moment: jest.fn(() => {
@@ -31,14 +32,21 @@ const mocks = {
mutate: apolloMutateMock,
},
$store: {
+ state: {
+ moderator: {
+ id: 0,
+ name: 'test moderator',
+ },
+ },
commit: stateCommitMock,
},
+ $toasted: {
+ error: toastedErrorMock,
+ },
}
const propsData = {
type: '',
- item: {},
- row: [],
creation: [],
itemsMassCreation: {},
}
@@ -69,6 +77,8 @@ describe('EditCreationFormular', () => {
jest.clearAllMocks()
await wrapper.setProps({ type: 'singleCreation', creation: [200, 400, 600] })
await wrapper.setData({ rangeMin: 180 })
+ await wrapper.setData({ text: 'Test create coins' })
+ await wrapper.setData({ value: 90 })
})
describe('first radio button', () => {
@@ -83,6 +93,27 @@ describe('EditCreationFormular', () => {
it('sets rangeMax to 200', () => {
expect(wrapper.vm.rangeMax).toBe(200)
})
+
+ describe('sendForm', () => {
+ beforeEach(async () => {
+ await wrapper.find('.test-submit').trigger('click')
+ })
+
+ it('sends ... to apollo', () => {
+ expect(apolloMutateMock).toBeCalledWith(
+ expect.objectContaining({
+ variables: {
+ amount: 90,
+ creationDate: 'YYYY-MM-01',
+ email: undefined,
+ id: undefined,
+ memo: 'Test create coins',
+ moderator: 0,
+ },
+ }),
+ )
+ })
+ })
})
describe('second radio button', () => {
@@ -97,6 +128,27 @@ describe('EditCreationFormular', () => {
it('sets rangeMax to 400', () => {
expect(wrapper.vm.rangeMax).toBe(400)
})
+
+ describe('sendForm', () => {
+ beforeEach(async () => {
+ await wrapper.find('.test-submit').trigger('click')
+ })
+
+ it('sends ... to apollo', () => {
+ expect(apolloMutateMock).toBeCalledWith(
+ expect.objectContaining({
+ variables: {
+ amount: 90,
+ creationDate: 'YYYY-MM-01',
+ email: undefined,
+ id: undefined,
+ memo: 'Test create coins',
+ moderator: 0,
+ },
+ }),
+ )
+ })
+ })
})
describe('third radio button', () => {
@@ -111,6 +163,27 @@ describe('EditCreationFormular', () => {
it('sets rangeMax to 400', () => {
expect(wrapper.vm.rangeMax).toBe(600)
})
+
+ describe('sendForm', () => {
+ beforeEach(async () => {
+ await wrapper.find('.test-submit').trigger('click')
+ })
+
+ it('sends ... to apollo', () => {
+ expect(apolloMutateMock).toBeCalledWith(
+ expect.objectContaining({
+ variables: {
+ amount: 90,
+ creationDate: 'YYYY-MM-DD',
+ email: undefined,
+ id: undefined,
+ memo: 'Test create coins',
+ moderator: 0,
+ },
+ }),
+ )
+ })
+ })
})
})
})
diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue
index 2b1bb566c..3a1c91a02 100644
--- a/admin/src/components/EditCreationFormular.vue
+++ b/admin/src/components/EditCreationFormular.vue
@@ -6,6 +6,7 @@
@@ -147,10 +151,10 @@ export default {
},
},
row: {
- type: Array,
- required: Object,
+ type: Object,
+ required: false,
default() {
- return []
+ return {}
},
},
creationUserData: {
@@ -165,34 +169,11 @@ export default {
required: true,
},
},
- created() {
- if (this.pagetype === 'PageCreationConfirm' && this.creationUserData.date) {
- switch (this.$moment(this.creationUserData.date).format('MMMM')) {
- case this.currentMonth.short:
- this.createdIndex = 2
- this.radioSelected = this.currentMonth
- break
- case this.lastMonth.short:
- this.createdIndex = 1
- this.radioSelected = this.lastMonth
- break
- case this.beforeLastMonth.short:
- this.createdIndex = 0
- this.radioSelected = this.beforeLastMonth
- break
- default:
- throw new Error('Something went wrong')
- }
- this.selectedOpenCreationAmount[this.createdIndex] =
- this.creation[this.createdIndex] + this.creationUserData.amount / 10000
- this.rangeMax = this.selectedOpenCreationAmount[this.createdIndex]
- }
- },
data() {
return {
radioSelected: '',
text: !this.creationUserData.memo ? '' : this.creationUserData.memo,
- value: !this.creationUserData.amount ? 0 : this.creationUserData.amount / 10000,
+ value: !this.creationUserData.amount ? 0 : this.creationUserData.amount,
rangeMin: 0,
rangeMax: 1000,
currentMonth: {
@@ -221,22 +202,6 @@ export default {
this.rangeMax = this.creation[index]
},
submitCreation() {
- // Formular Prüfen ob ein Zeitraum ausgewählt wurde. Ansonsten abbrechen und Hinweis anzeigen
- if (this.radioSelected === '') {
- return alert('Bitte wähle einen Zeitraum!')
- }
- // Formular Prüfen ob der GDD Betrag grösser 0 ist. Ansonsten abbrechen und Hinweis anzeigen
- if (this.value <= 0) {
- return alert('Bitte gib einen GDD Betrag an!')
- }
- // Formular Prüfen ob der Text vorhanden ist. Ansonsten abbrechen und Hinweis anzeigen
- if (this.text === '') {
- return alert('Bitte gib einen Text ein!')
- }
- // Formular Prüfen ob der Text länger als 10 Zeichen hat. Ansonsten abbrechen und Hinweis anzeigen
- if (this.text.length < 10) {
- return alert('Bitte gib einen Text ein der länger als 10 Zeichen ist!')
- }
this.submitObj = {
id: this.item.id,
email: this.item.email,
@@ -281,5 +246,28 @@ export default {
})
},
},
+ created() {
+ if (this.pagetype === 'PageCreationConfirm' && this.creationUserData.date) {
+ switch (this.$moment(this.creationUserData.date).format('MMMM')) {
+ case this.currentMonth.short:
+ this.createdIndex = 2
+ this.radioSelected = this.currentMonth
+ break
+ case this.lastMonth.short:
+ this.createdIndex = 1
+ this.radioSelected = this.lastMonth
+ break
+ case this.beforeLastMonth.short:
+ this.createdIndex = 0
+ this.radioSelected = this.beforeLastMonth
+ break
+ default:
+ throw new Error('Something went wrong')
+ }
+ this.selectedOpenCreationAmount[this.createdIndex] =
+ this.creation[this.createdIndex] + this.creationUserData.amount
+ this.rangeMax = this.selectedOpenCreationAmount[this.createdIndex]
+ }
+ },
}
diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue
index e47963159..4a8ca8e84 100644
--- a/admin/src/components/UserTable.vue
+++ b/admin/src/components/UserTable.vue
@@ -132,6 +132,7 @@