From b9737dca9ddc492ffcc0fe055185b6175fa0fd88 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 21 Jul 2022 11:18:52 +0800 Subject: [PATCH] chore(gui-v2): bypass bulk import if data is not found & reset loading --- packages/nc-gui-v2/components/template/Editor.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui-v2/components/template/Editor.vue b/packages/nc-gui-v2/components/template/Editor.vue index 1987632500..307c0b2e93 100644 --- a/packages/nc-gui-v2/components/template/Editor.vue +++ b/packages/nc-gui-v2/components/template/Editor.vue @@ -214,6 +214,7 @@ const importTemplate = async () => { } catch (errorInfo) { // TODO: handle error message console.log('Failed:', errorInfo) + loading.value = false return } @@ -267,6 +268,7 @@ const importTemplate = async () => { // TODO: retrieve error msg from sdk console.log(e) toast.error(e.message) + loading.value = false return } @@ -280,11 +282,13 @@ const importTemplate = async () => { (async (tableMeta) => { const tableName = tableMeta.table_title const data = importData[tableMeta.ref_table_name] - total += data.length - for (let i = 0; i < data.length; i += 500) { - const batchData = remapColNames(data.slice(i, i + 500), tableMeta.columns) - await $api.dbTableRow.bulkCreate('noco', projectName, tableName, batchData) - progress += batchData.length + if (data) { + total += data.length + for (let i = 0; i < data.length; i += 500) { + const batchData = remapColNames(data.slice(i, i + 500), tableMeta.columns) + await $api.dbTableRow.bulkCreate('noco', projectName, tableName, batchData) + progress += batchData.length + } } })(v), ), @@ -292,6 +296,7 @@ const importTemplate = async () => { } catch (e: any) { // TODO: retrieve error msg from sdk toast.error(e.message) + loading.value = false return } }