From 43c296afcf4f069d34ac223c44f5242ebe9338ac Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 30 Apr 2022 18:01:02 +0800 Subject: [PATCH] wip: edit logic before importing --- .../templates/createProjectFromTemplateBtn.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/templates/createProjectFromTemplateBtn.vue b/packages/nc-gui/components/templates/createProjectFromTemplateBtn.vue index d365423e74..dcf345c06e 100644 --- a/packages/nc-gui/components/templates/createProjectFromTemplateBtn.vue +++ b/packages/nc-gui/components/templates/createProjectFromTemplateBtn.vue @@ -147,6 +147,14 @@ export default { .create({client: 'sqlite3'}) .getNewTableColumns() .filter(c => c.column_name != "title") + // mark updated column_name + t.columns.map(c => { + if (c.cn) { + c.column_name = c.cn + c.ref_column_name = c.column_name + } + return c + }) const table = await this.$api.dbTable.create(project.id, { table_name: t.ref_table_name, title: '', @@ -154,6 +162,7 @@ export default { }); console.log(table) t.table_title = table.title + console.log(t) } this.tableCreation = true } catch (e) { @@ -188,8 +197,11 @@ export default { async importDataToProject(projectName, prefix) { let total = 0 let progress = 0 + console.log("projectName = " + projectName) + console.log(this.templateData.tables) await Promise.all(this.templateData.tables.map(v => (async(tableMeta) => { - const table = tableMeta.table_title + console.log(tableMeta) + const tableName = tableMeta.table_title const data = this.importData[tableMeta.ref_table_name] total += data.length for (let i = 0; i < data.length; i += 500) { @@ -199,7 +211,7 @@ export default { await this.$api.dbTableRow.bulkCreate( 'noco', projectName, - table, + tableName, batchData ) progress += batchData.length