Clean calculation of openCreation when updating an open creation

This commit is contained in:
Hannes Heine 2021-11-29 14:39:24 +01:00 committed by ogerly
parent f9113abc75
commit 5f7e502f05
3 changed files with 45 additions and 121 deletions

View File

@ -154,21 +154,6 @@ export default {
required: true,
},
},
created() {
console.log(' created this.pagetype', this.pagetype)
if (this.pagetype === 'PageCreationConfirm' && this.creationUserData.date) {
console.log('if created CreationFormular.vue', this.creationUserData.date)
console.log(
'this.$moment(this.creationUserData.date).format("MMMM")',
this.$moment(this.creationUserData.date).format('MMMM'),
)
console.log(
'this.$moment(this.creationUserData.date).format("YYYY-MM-DD")',
this.$moment(this.creationUserData.date).format('YYYY-MM-DD'),
)
// const id = this.$moment(this.creationUserData.date).format('MMMM')
}
},
data() {
return {
radioSelected: '',
@ -198,7 +183,6 @@ export default {
// Auswählen eines Zeitraumes
updateRadioSelected(name, index, openCreation) {
this.createdIndex = index
console.log('radioSelected', this.radioSelected)
// Wenn Mehrfachschöpfung
if (this.type === 'massCreation') {
// An Creation.vue emitten und radioSelectedMass aktualisieren
@ -209,23 +193,6 @@ export default {
this.rangeMax = openCreation
}
},
/*
checkFormForUpdate(input) {
console.log('checkFormForUpdate', input)
console.log('checkFormForUpdate creationUserData', this.creationUserData)
switch (input) {
case 'text':
this.text = this.creationUserData.text
break
case 'range':
this.value = this.creationUserData.creationGdd
break
default:
// TODO: Toast
alert("I don't know such values")
}
},
*/
submitCreation() {
// Formular Prüfen ob ein Zeitraum ausgewählt wurde. Ansonsten abbrechen und Hinweis anzeigen
if (this.radioSelected === '') {
@ -243,31 +210,6 @@ export default {
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')
this.submitObj = [
{
item: this.itemsMassCreation,
email: this.item.email,
creationDate: this.radioSelected.long,
amount: this.value,
note: this.text,
moderator: this.$store.state.moderator.id,
},
]
alert('MehrfachSCHÖPFUNG ABSENDEN FÜR >> ' + i + ' Mitglieder')
// $store - offene Schöpfungen hochzählen
this.$store.commit('openCreationsPlus', i)
// lösche alle Mitglieder aus der MehrfachSchöpfungsListe nach dem alle Mehrfachschpfungen zum bestätigen gesendet wurden.
this.$emit('remove-all-bookmark')
}
*/
if (this.type === 'singleCreation') {
this.submitObj = {
email: this.item.email,
@ -277,43 +219,32 @@ export default {
moderator: Number(this.$store.state.moderator.id),
}
if (this.pagetype === 'PageCreationConfirm') {
// hinweis das eine ein einzelne Schöpfung abgesendet wird an (email)
alert('UPDATE EINZEL SCHÖPFUNG ABSENDEN FÜR >> ')
// umschreiben, update eine bestehende Schöpfung eine
this.$emit('update-creation-data', {
datum: this.radioSelected.long,
creationGdd: this.value,
text: this.text,
this.$apollo
.query({
query: createPendingCreation,
variables: this.submitObj,
})
.then((result) => {
this.$emit('update-user-data', this.item, result.data.createPendingCreation)
this.$toasted.success(
`Offene schöpfung (${this.value} GDD) für ${this.item.email} wurde gespeichert, liegen zur bestätigung bereit`,
)
this.$store.commit('openCreationsPlus', 1)
this.submitObj = null
this.createdIndex = null
// das creation Formular reseten
this.$refs.creationForm.reset()
// Den geschöpften Wert auf o setzen
this.value = 0
})
.catch((error) => {
this.$toasted.error(error.message)
this.submitObj = null
// das creation Formular reseten
this.$refs.creationForm.reset()
// Den geschöpften Wert auf o setzen
this.value = 0
})
} else {
this.$apollo
.query({
query: createPendingCreation,
variables: this.submitObj,
})
.then((result) => {
this.$emit('update-user-data', this.item, result.data.createPendingCreation)
this.$toasted.success(
`Offene schöpfung (${this.value} GDD) für ${this.item.email} wurde gespeichert, liegen zur bestätigung bereit`,
)
this.$store.commit('openCreationsPlus', 1)
this.submitObj = null
this.createdIndex = null
// das creation Formular reseten
this.$refs.creationForm.reset()
// Den geschöpften Wert auf o setzen
this.value = 0
})
.catch((error) => {
this.$toasted.error(error.message)
this.submitObj = null
// das creation Formular reseten
this.$refs.creationForm.reset()
// Den geschöpften Wert auf o setzen
this.value = 0
})
}
}
},
},

View File

@ -13,7 +13,12 @@
@change="updateRadioSelected(beforeLastMonth, 0, selectedOpenCreationAmount[0])"
>
<label for="beforeLastMonth">
{{ beforeLastMonth.short }} {{ selectedOpenCreationAmount[0] != null ? selectedOpenCreationAmount[0] + ' GDD' : '' }}
{{ beforeLastMonth.short }}
{{
selectedOpenCreationAmount[0] != null
? selectedOpenCreationAmount[0] + ' GDD'
: ''
}}
</label>
</b-form-radio>
</b-col>
@ -26,7 +31,12 @@
@change="updateRadioSelected(lastMonth, 1, selectedOpenCreationAmount[1])"
>
<label for="lastMonth">
{{ lastMonth.short }} {{ selectedOpenCreationAmount[1] != null ? selectedOpenCreationAmount[1] + ' GDD' : '' }}
{{ lastMonth.short }}
{{
selectedOpenCreationAmount[1] != null
? selectedOpenCreationAmount[1] + ' GDD'
: ''
}}
</label>
</b-form-radio>
</b-col>
@ -39,7 +49,12 @@
@change="updateRadioSelected(currentMonth, 2, selectedOpenCreationAmount[2])"
>
<label for="currentMonth">
{{ currentMonth.short }} {{ selectedOpenCreationAmount[2] != null ? selectedOpenCreationAmount[2] + ' GDD' : '' }}
{{ currentMonth.short }}
{{
selectedOpenCreationAmount[2] != null
? selectedOpenCreationAmount[2] + ' GDD'
: ''
}}
</label>
</b-form-radio>
</b-col>
@ -144,17 +159,7 @@ export default {
},
},
created() {
console.log(' created this.pagetype', this.pagetype)
if (this.pagetype === 'PageCreationConfirm' && this.creationUserData.date) {
console.log('if created CreationFormular.vue', this.creationUserData.date)
console.log(
'this.$moment(this.creationUserData.date).format("MMMM")',
this.$moment(this.creationUserData.date).format('MMMM'),
)
console.log(
'this.$moment(this.creationUserData.date).format("YYYY-MM")',
this.$moment(this.creationUserData.date).format('YYYY-MM'),
)
switch (this.$moment(this.creationUserData.date).format('MMMM')) {
case this.currentMonth.short:
this.createdIndex = 2
@ -171,10 +176,8 @@ export default {
default:
throw new Error('Something went wrong')
}
console.log(this.creation)
const openCreations = this.creationUserData.creation
this.selectedOpenCreationAmount = openCreations
this.selectedOpenCreationAmount[this.createdIndex] = this.selectedOpenCreationAmount[this.createdIndex] + this.creationUserData.amount / 10000
this.selectedOpenCreationAmount[this.createdIndex] =
this.creation[this.createdIndex] + this.creationUserData.amount / 10000
this.rangeMax = this.selectedOpenCreationAmount[this.createdIndex]
}
},
@ -206,11 +209,7 @@ export default {
methods: {
updateRadioSelected(name, index, openCreation) {
console.log('createdIndex before update', this.createdIndex)
this.createdIndex = index
console.log('radioSelected', this.radioSelected)
console.log('openCreation', openCreation)
this.rangeMin = 0
this.rangeMax = this.creation[index]
},
@ -242,8 +241,6 @@ export default {
if (this.pagetype === 'PageCreationConfirm') {
// hinweis das eine ein einzelne Schöpfung abgesendet wird an (email)
alert('UPDATE EINZELSCHÖPFUNG ABSENDEN FÜR >> ' + JSON.stringify(this.submitObj))
this.$apollo
.query({
query: updatePendingCreation,

View File

@ -232,12 +232,8 @@ export default {
this.$emit('remove-confirm-result', item, 'remove')
},
editCreationUserTable(row, rowItem) {
alert('editCreationUserTable')
if (!row.detailsShowing) {
alert('offen edit loslegen')
// this.item = rowItem
this.creationUserData = rowItem
console.log('editCreationUserTable creationUserData', this.creationUserData)
} else {
this.creationUserData = {}
}