From b5c98871adeb7af58ba35d58a3be92aaab306526 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Thu, 25 May 2023 18:05:07 +0100 Subject: [PATCH] Update table data via CSV import (#10313) * Add identifierFields select for import * Update rows on import (Internal DB) * Only allow internal DB to upsert import CSV * Clear identifierFields when turning off update * Passing table instead of tableId * Pass table * Pass tableType --- .../backend/DataTable/DataTable.svelte | 1 + .../DataTable/buttons/ImportButton.svelte | 3 +- .../buttons/grid/GridImportButton.svelte | 3 +- .../DataTable/modals/ImportModal.svelte | 12 ++++++- .../ExistingTableDataImport.svelte | 21 +++++++++++- packages/frontend-core/src/api/tables.js | 6 ++-- .../src/components/grid/layout/Grid.svelte | 2 ++ .../src/api/controllers/table/internal.ts | 8 ++--- .../server/src/api/controllers/table/utils.ts | 33 ++++++++++++++++++- 9 files changed, 76 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index dfe30a3711..83e115ebf2 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -32,6 +32,7 @@ - + diff --git a/packages/builder/src/components/backend/DataTable/buttons/grid/GridImportButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/grid/GridImportButton.svelte index 5aa530b028..5b89d92438 100644 --- a/packages/builder/src/components/backend/DataTable/buttons/grid/GridImportButton.svelte +++ b/packages/builder/src/components/backend/DataTable/buttons/grid/GridImportButton.svelte @@ -4,11 +4,12 @@ export let disabled = false - const { rows, tableId } = getContext("grid") + const { rows, tableId, tableType } = getContext("grid") diff --git a/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte b/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte index 173fb88829..c020d1a7ac 100644 --- a/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/ImportModal.svelte @@ -13,15 +13,18 @@ const dispatch = createEventDispatcher() export let tableId + export let tableType let rows = [] let allValid = false let displayColumn = null + let identifierFields = [] async function importData() { try { await API.importTableData({ tableId, rows, + identifierFields, }) notifications.success("Rows successfully imported") } catch (error) { @@ -45,6 +48,13 @@ - + diff --git a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte index cb150f71fc..eba17e8ab9 100644 --- a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte @@ -1,5 +1,5 @@