Browse Source

feat(gui-v2): add importColumns

pull/3051/head
Wing-Kam Wong 2 years ago
parent
commit
1d4756a835
  1. 13
      packages/nc-gui-v2/components/dlg/QuickImport.vue

13
packages/nc-gui-v2/components/dlg/QuickImport.vue

@ -10,7 +10,13 @@ import MdiLinkVariantIcon from '~icons/mdi/link-variant'
import MdiCodeJSONIcon from '~icons/mdi/code-json'
import { fieldRequiredValidator, importCsvUrlValidator, importExcelUrlValidator, importUrlValidator } from '~/utils/validation'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import { ExcelTemplateAdapter, ExcelUrlTemplateAdapter, JSONTemplateAdapter, JSONUrlTemplateAdapter } from '~/utils/parsers'
import {
CSVTemplateAdapter,
ExcelTemplateAdapter,
ExcelUrlTemplateAdapter,
JSONTemplateAdapter,
JSONUrlTemplateAdapter,
} from '~/utils/parsers'
import { useProject } from '#imports'
interface Props {
@ -41,6 +47,8 @@ const templateData = ref()
const importData = ref()
const importColumns = ref([])
const templateEditorModal = ref(false)
const useForm = Form.useForm
@ -157,6 +165,7 @@ async function parseAndExtractData(val: any, name: string) {
try {
templateData.value = null
importData.value = null
importColumns.value = []
const templateGenerator: any = getAdapter(name, val)
if (!templateGenerator) {
toast.error('Template Generator cannot be found!')
@ -167,6 +176,7 @@ async function parseAndExtractData(val: any, name: string) {
templateData.value = templateGenerator.getTemplate()
templateData.value.tables[0].table_name = populateUniqueTableName()
importData.value = templateGenerator.getData()
if (importOnly) importColumns.value = templateGenerator.getColumns()
templateEditorModal.value = true
} catch (e: any) {
console.log(e)
@ -266,6 +276,7 @@ function getAdapter(name: string, val: any) {
ref="templateEditorRef"
:project-template="templateData"
:import-data="importData"
:import-columns="importColumns"
:import-only="importOnly"
:quick-import-type="importType"
@import="handleImport"

Loading…
Cancel
Save