Browse Source

fix(nc-gui): infinite import validation errors

pull/4135/head
Wing-Kam Wong 2 years ago
parent
commit
4f731a8887
  1. 54
      packages/nc-gui/components/template/Editor.vue

54
packages/nc-gui/components/template/Editor.vue

@ -123,30 +123,36 @@ const validators = computed(() =>
const { validate, validateInfos } = useForm(data, validators) const { validate, validateInfos } = useForm(data, validators)
// TODO(import): show error message once const isValid = ref(false)
const isValid = computed(() => {
if (importDataOnly) { watch(
for (const tn of Object.keys(srcDestMapping.value)) { () => srcDestMapping.value,
if (!atLeastOneEnabledValidation(tn)) { () => {
return false let res = true
} if (importDataOnly) {
for (const record of srcDestMapping.value[tn]) { for (const tn of Object.keys(srcDestMapping.value)) {
if (!fieldsValidation(record, tn)) { if (!atLeastOneEnabledValidation(tn)) {
return false res = false
}
for (const record of srcDestMapping.value[tn]) {
if (!fieldsValidation(record, tn)) {
return false
}
} }
} }
} } else {
} else { for (const [_, o] of Object.entries(validateInfos)) {
for (const [_, o] of Object.entries(validateInfos)) { if (o?.validateStatus) {
if (o?.validateStatus) { if (o.validateStatus === 'error') {
if (o.validateStatus === 'error') { res = false
return false }
} }
} }
} }
} isValid.value = res
return true },
}) { deep: true },
)
const prevEditableTn = ref<string[]>([]) const prevEditableTn = ref<string[]>([])
@ -158,6 +164,10 @@ onMounted(() => {
// and updating the key in importData // and updating the key in importData
prevEditableTn.value = data.tables.map((t) => t.table_name) prevEditableTn.value = data.tables.map((t) => t.table_name)
if (importDataOnly) {
mapDefaultColumns()
}
nextTick(() => { nextTick(() => {
inputRefs.value[0]?.focus() inputRefs.value[0]?.focus()
}) })
@ -569,12 +579,6 @@ defineExpose({
isValid, isValid,
}) })
onMounted(() => {
if (importDataOnly) {
mapDefaultColumns()
}
})
function handleEditableTnChange(idx: number) { function handleEditableTnChange(idx: number) {
const oldValue = prevEditableTn.value[idx] const oldValue = prevEditableTn.value[idx]
const newValue = data.tables[idx].table_name const newValue = data.tables[idx].table_name

Loading…
Cancel
Save