From ff2ecd5363679ac9cba56ed2ed242941a3ae116c Mon Sep 17 00:00:00 2001 From: ogerly Date: Fri, 5 Aug 2022 16:47:08 +0200 Subject: [PATCH 1/4] add formatter on input amount replace point and comma --- frontend/src/components/Contributions/ContributionForm.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index d0de061d3..890ffe363 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -58,6 +58,7 @@ type="number" min="1" :max="isThisMonth ? maxGddThisMonth : maxGddLastMonth" + :formatter="numberFormat" >
Date: Mon, 8 Aug 2022 15:24:50 +0200 Subject: [PATCH 2/4] Update ContributionForm.vue --- frontend/src/components/Contributions/ContributionForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 03fc08a92..3dda5ea41 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -106,7 +106,7 @@ export default { }, methods: { numberFormat(value) { - return (this.form.amount = value.replace(/\.|,/, '')) + return (this.form.amount = value.replace(/\.|,, '')) }, submit() { this.numberFormat(this.form.amount) From 1fbea40c4dca6da4776f5493c7357f69a9946914 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 8 Aug 2022 15:27:42 +0200 Subject: [PATCH 3/4] remove regex --- frontend/src/components/Contributions/ContributionForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 3dda5ea41..03fc08a92 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -106,7 +106,7 @@ export default { }, methods: { numberFormat(value) { - return (this.form.amount = value.replace(/\.|,, '')) + return (this.form.amount = value.replace(/\.|,/, '')) }, submit() { this.numberFormat(this.form.amount) From 3a2f27f519fbdd0b5e865674c96d66042e9ed436 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 8 Aug 2022 16:57:14 +0200 Subject: [PATCH 4/4] refactor amount to string in ContributionForm, fix thousand error --- .../components/Contributions/ContributionForm.vue | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 03fc08a92..5fad059fb 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -51,13 +51,11 @@ - + @@ -106,10 +104,10 @@ export default { }, methods: { numberFormat(value) { - return (this.form.amount = value.replace(/\.|,/, '')) + return value.replace(/\D/g, '') }, submit() { - this.numberFormat(this.form.amount) + this.form.amount = this.numberFormat(this.form.amount) if (this.form.id) { this.$emit('update-contribution', this.form) } else { @@ -137,8 +135,8 @@ export default { if ( this.form.date === '' || this.form.memo.length < this.minlength || - this.form.amount <= 0 || - this.form.amount > 1000 || + parseInt(this.form.amount) <= 0 || + parseInt(this.form.amount) > 1000 || (this.isThisMonth && parseInt(this.form.amount) > parseInt(this.maxGddThisMonth)) || (!this.isThisMonth && parseInt(this.form.amount) > parseInt(this.maxGddLastMonth)) )