From 1d4756a835280a3ca071a4ac01a4c82a88d53645 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 10 Aug 2022 13:15:29 +0800 Subject: [PATCH] feat(gui-v2): add importColumns --- packages/nc-gui-v2/components/dlg/QuickImport.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/components/dlg/QuickImport.vue b/packages/nc-gui-v2/components/dlg/QuickImport.vue index 78c4354f26..27f5045660 100644 --- a/packages/nc-gui-v2/components/dlg/QuickImport.vue +++ b/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"