Browse Source

feat(nc-gui): validate each table after pre-import

pull/4135/head
Wing-Kam Wong 2 years ago
parent
commit
5e412f15a5
  1. 9
      packages/nc-gui/components/template/Editor.vue

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

@ -290,8 +290,6 @@ function fieldsValidation(record: Record<string, any>) {
return true return true
} }
const tableName = meta.value?.title || ''
if (!record.destCn) { if (!record.destCn) {
message.error(`${t('msg.error.columnDescriptionNotFound')} ${record.srcCn}`) message.error(`${t('msg.error.columnDescriptionNotFound')} ${record.srcCn}`)
return false return false
@ -304,6 +302,7 @@ function fieldsValidation(record: Record<string, any>) {
const v = columns.value.find((c) => c.title === record.destCn) as Record<string, any> const v = columns.value.find((c) => c.title === record.destCn) as Record<string, any>
for (const tableName of Object.keys(importData)) {
// check if the input contains null value for a required column // check if the input contains null value for a required column
if (v.pk ? !v.ai && !v.cdf : !v.cdf && v.rqd) { if (v.pk ? !v.ai && !v.cdf : !v.cdf && v.rqd) {
if ( if (
@ -350,17 +349,15 @@ function fieldsValidation(record: Record<string, any>) {
return input !== 1 && input !== 0 && input !== true && input !== false return input !== 1 && input !== 0 && input !== true && input !== false
} }
return false return false
}) })
) { ) {
message.error(t('msg.error.sourceHasInvalidBoolean')) message.error(t('msg.error.sourceHasInvalidBoolean'))
return false return false
} }
break break
} }
}
return true return true
} }
@ -541,7 +538,7 @@ function mapDefaultColumns() {
for (const col of importColumns[0]) { for (const col of importColumns[0]) {
const o = { srcCn: col.column_name, destCn: '', enabled: true } const o = { srcCn: col.column_name, destCn: '', enabled: true }
if (columns.value) { if (columns.value) {
const tableColumn = columns.value.find((c: Record<string, any>) => c.title === col.column_name) const tableColumn = columns.value.find((c) => c.column_name === col.column_name)
if (tableColumn) { if (tableColumn) {
o.destCn = tableColumn.title as string o.destCn = tableColumn.title as string
} else { } else {

Loading…
Cancel
Save