From 4f1ea1f5ba48be0d1b6fdbe6a898f4884297c804 Mon Sep 17 00:00:00 2001 From: Einhornimmond Date: Sat, 8 Feb 2025 13:24:09 +0100 Subject: [PATCH] change to using only yup --- .../Contributions/ContributionForm.vue | 16 +++++++- .../src/components/Inputs/InputTextarea.vue | 2 +- .../src/components/Inputs/ValidatedInput.vue | 37 ++++++++++++++++--- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue index 84eb7f31c..37c7b72ec 100644 --- a/frontend/src/components/Contributions/ContributionForm.vue +++ b/frontend/src/components/Contributions/ContributionForm.vue @@ -99,6 +99,7 @@ const props = defineProps({ const emit = defineEmits(['update-contribution', 'set-contribution']) const { t } = useI18n() +let allFieldsValid = ref(false) const form = ref({ ...props.modelValue }) @@ -152,6 +153,17 @@ const updateField = (newValue, name) => { if (name === 'hours') { setFieldValue('amount', (newValue * 20).toFixed(2).toString()) } + /* + validationSchema.value.validateAt(name, formValues) + .then(() => { + allFieldsValid = true + }) + .catch((e) => { + allFieldsValid = false + console.log('validation error') + console.log(JSON.stringify(e, null, 2)) + //errorMessage = e.message + })*/ } const showMessage = computed(() => { @@ -165,11 +177,13 @@ const showMessage = computed(() => { }) const disabled = computed(() => { + return !allFieldsValid + /* return ( !formMeta.value.valid || (props.isThisMonth && parseFloat(form.value.amount) > parseFloat(props.maxGddThisMonth)) || (!props.isThisMonth && parseFloat(form.value.amount) > parseFloat(props.maxGddLastMonth)) - ) + )*/ }) const noOpenCreation = computed(() => { diff --git a/frontend/src/components/Inputs/InputTextarea.vue b/frontend/src/components/Inputs/InputTextarea.vue index 41e649265..a30a6510a 100644 --- a/frontend/src/components/Inputs/InputTextarea.vue +++ b/frontend/src/components/Inputs/InputTextarea.vue @@ -54,7 +54,7 @@ const props = defineProps({ const { value: currentValue, errorMessage, meta } = useField(props.name, props.rules) const { t } = useI18n() const translatedErrorString = computed(() => { - console.log(errorMessage) + // console.log(errorMessage) if (typeof errorMessage.value === 'object') { return t(errorMessage.value.key, errorMessage.value.values) } else if (isLanguageKey(errorMessage.value)) { diff --git a/frontend/src/components/Inputs/ValidatedInput.vue b/frontend/src/components/Inputs/ValidatedInput.vue index 50d869529..3e25bda6e 100644 --- a/frontend/src/components/Inputs/ValidatedInput.vue +++ b/frontend/src/components/Inputs/ValidatedInput.vue @@ -9,7 +9,7 @@ :required="!isOptional" :label="props.label" :name="props.name" - :state="meta.valid" + :state="valid" @input="updateValue($event.target.value)"> {{ $t(translatedErrorString) }} @@ -18,7 +18,7 @@