From 7721b2d2dfc18fd634ecfac234692474a9ab65e5 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 25 Jul 2022 19:55:58 +0800 Subject: [PATCH] feat(gui-v2): TemplateEditor integration --- .../nc-gui-v2/components/dlg/QuickImport.vue | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/nc-gui-v2/components/dlg/QuickImport.vue b/packages/nc-gui-v2/components/dlg/QuickImport.vue index d82d449199..1a442f65ed 100644 --- a/packages/nc-gui-v2/components/dlg/QuickImport.vue +++ b/packages/nc-gui-v2/components/dlg/QuickImport.vue @@ -27,6 +27,7 @@ const { tables } = useProject() const toast = useToast() const activeKey = ref('uploadTab') const jsonEditorRef = ref() +const templateEditorRef = ref() const loading = ref(false) const templateData = ref() const importData = ref() @@ -89,7 +90,8 @@ const dialogShow = computed({ const { resetFields, validate, validateInfos } = useForm(importState, validators) -async function handleImport() { +async function handlePreImport() { + loading.value = true if (activeKey.value === 'uploadTab') { // FIXME: importState.fileList.map(async (file: any) => { @@ -105,6 +107,14 @@ async function handleImport() { } else if (activeKey.value === 'jsonEditorTab') { await parseAndExtractData(JSON.stringify(importState.jsonEditor), '') } + loading.value = false +} + +async function handleImport() { + loading.value = true + await templateEditorRef.value.importTemplate() + loading.value = false + dialogShow.value = false } async function parseAndExtractData(val: any, name: string) { @@ -119,7 +129,6 @@ async function parseAndExtractData(val: any, name: string) { templateData.value.tables[0].table_name = populateUniqueTableName() importData.value = templateGenerator.getData() templateEditorModal.value = true - dialogShow.value = false } catch (e: any) { console.log(e) toast.error(await extractSdkResponseErrorMsg(e)) @@ -156,7 +165,9 @@ function handleChange(info: UploadChangeParam) { } function formatJson() { + loading.value = true jsonEditorRef.value.format() + loading.value = false } function populateUniqueTableName() { @@ -193,9 +204,19 @@ function getAdapter(name: string, val: any) { - + + + \ No newline at end of file