Skip to content

Commit

Permalink
#2490 - always validate on load when editing
Browse files Browse the repository at this point in the history
  • Loading branch information
rmmayo committed Jul 1, 2024
1 parent 6b19469 commit 0630714
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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()
}
}
}
</script>

<template>
Expand Down Expand Up @@ -216,7 +216,7 @@ const validateIfEditOrNotEmpty = () => {
z-index: 999;
height: 2em;
width: 2em;
overflow: show;
overflow: visible;
margin: auto;
top: 0;
left: 0;
Expand Down

0 comments on commit 0630714

Please sign in to comment.