From 063071443982f1d30ce351edfcb4b8d951ca2c99 Mon Sep 17 00:00:00 2001 From: rmmayo Date: Mon, 1 Jul 2024 15:08:39 +0000 Subject: [PATCH] #2490 - always validate on load when editing --- .../utils/inputForm/SkillsInputFormDialog.vue | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/dashboard-prime/src/components/utils/inputForm/SkillsInputFormDialog.vue b/dashboard-prime/src/components/utils/inputForm/SkillsInputFormDialog.vue index ba39b2de5e..b6c7d60e30 100644 --- a/dashboard-prime/src/components/utils/inputForm/SkillsInputFormDialog.vue +++ b/dashboard-prime/src/components/utils/inputForm/SkillsInputFormDialog.vue @@ -130,6 +130,25 @@ watch(() => errors.value, (newValue) => { emit('errors', newValue) }) +const validateIfEditOrNotEmpty = () => { + const skipAttrs = toRaw(values)['skipTheseAttrsWhenValidatingOnInit'] || [] + if (!props.initialValues) { + console.error(`Initial values for SkillsInputFormDialog id=[${props.id}] not provided.`) + } + if (props.isEdit) { + validate() + } else { + const foundNonEmpty = Object.entries(values) + .find(([key, value]) => + key !== 'skipTheseAttrsWhenValidatingOnInit' + && !skipAttrs.includes(key) + && value && !deepEqual((props.initialValues[key]), (value))) + if (foundNonEmpty) { + validate() + } + } +} + if (props.asyncLoadDataFunction) { isLoadingAsyncData.value = true props.asyncLoadDataFunction().then((res) => { @@ -159,25 +178,6 @@ if (props.asyncLoadDataFunction) { } } -const validateIfEditOrNotEmpty = () => { - const skipAttrs = toRaw(values)['skipTheseAttrsWhenValidatingOnInit'] || [] - if (!props.initialValues) { - console.error(`Initial values for SkillsInputFormDialog id=[${props.id}] not provided.`) - } - if (props.isEdit) { - validate() - } else { - const foundNonEmpty = Object.entries(values) - .find(([key, value]) => - key !== 'skipTheseAttrsWhenValidatingOnInit' - && !skipAttrs.includes(key) - && value && !deepEqual((props.initialValues[key]), (value))) - if (foundNonEmpty) { - validate() - } - } -} -