From 68ef30b8891a921c542a2e80fb5ebeda6d381a3b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 4 Feb 2023 12:11:24 +0800 Subject: [PATCH 1/2] feat(nc-gui): use the default base id if baseId is not provided --- packages/nc-gui/components/template/Editor.vue | 16 ++++++++++------ packages/nc-gui/composables/useTable.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/template/Editor.vue b/packages/nc-gui/components/template/Editor.vue index 770109fd9a..d2be0064a0 100644 --- a/packages/nc-gui/components/template/Editor.vue +++ b/packages/nc-gui/components/template/Editor.vue @@ -501,12 +501,16 @@ async function importTemplate() { } } } - const createdTable = await $api.base.tableCreate(project?.value?.id as string, baseId as string, { - table_name: table.table_name, - // leave title empty to get a generated one based on table_name - title: '', - columns: table.columns || [], - }) + const createdTable = await $api.base.tableCreate( + project?.value?.id as string, + (baseId || project?.value?.bases?.[0].id)!, + { + table_name: table.table_name, + // leave title empty to get a generated one based on table_name + title: '', + columns: table.columns || [], + }, + ) table.id = createdTable.id table.title = createdTable.title diff --git a/packages/nc-gui/composables/useTable.ts b/packages/nc-gui/composables/useTable.ts index c6638a3b8a..1b90832e07 100644 --- a/packages/nc-gui/composables/useTable.ts +++ b/packages/nc-gui/composables/useTable.ts @@ -49,7 +49,7 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void, baseId? }) try { - const tableMeta = await $api.base.tableCreate(project?.value?.id as string, baseId as string, { + const tableMeta = await $api.base.tableCreate(project?.value?.id as string, (baseId || project?.value?.bases?.[0].id)!, { ...table, columns, }) From a24812c0a2dce2ea14208d02c062ca16f2db1214 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 6 Feb 2023 12:54:10 +0800 Subject: [PATCH 2/2] fix(nc-gui): project?.value -> project.value --- packages/nc-gui/components/template/Editor.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/template/Editor.vue b/packages/nc-gui/components/template/Editor.vue index d2be0064a0..a6be949176 100644 --- a/packages/nc-gui/components/template/Editor.vue +++ b/packages/nc-gui/components/template/Editor.vue @@ -502,8 +502,8 @@ async function importTemplate() { } } const createdTable = await $api.base.tableCreate( - project?.value?.id as string, - (baseId || project?.value?.bases?.[0].id)!, + project.value?.id as string, + (baseId || project.value?.bases?.[0].id)!, { table_name: table.table_name, // leave title empty to get a generated one based on table_name