-
- {{ $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