From 7dffc1881daeefcf0e6e4237080c2ba09e803d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Keviin=20=C3=85berg=20Kultalahti?= Date: Tue, 9 Feb 2021 13:10:01 +0100 Subject: [PATCH] adds oneToMany property to save table method --- packages/builder/src/builderStore/store/backend.js | 7 ++++++- .../backend/DataTable/modals/CreateEditColumn.svelte | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index faf5b460f1..010e2ecde1 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -232,8 +232,9 @@ export const getBackendUiStore = () => { return state }) }, - saveField: ({ originalName, field, primaryDisplay = false }) => { + saveField: ({ originalName, field, primaryDisplay = false, oneToMany = false }) => { store.update(state => { + console.log(state) // delete the original if renaming // need to handle if the column had no name, empty string if (originalName || originalName === "") { @@ -248,6 +249,10 @@ export const getBackendUiStore = () => { if (primaryDisplay) { state.draftTable.primaryDisplay = field.name } + // Set one-to-many + if (oneToMany) { + state.draftTable.oneToMany = field.name + } state.draftTable.schema[field.name] = cloneDeep(field) store.actions.tables.save(state.draftTable) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 084e28ed3f..ce5abeddce 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -24,6 +24,7 @@ let primaryDisplay = $backendUiStore.selectedTable.primaryDisplay == null || $backendUiStore.selectedTable.primaryDisplay === field.name + let oneToMany = false; let confirmDeleteDialog let deletion @@ -41,6 +42,7 @@ originalName, field, primaryDisplay, + oneToMany, }) return state }) @@ -150,7 +152,7 @@ bind:value={field.constraints.numericality.lessThanOrEqualTo} /> {:else if field.type === 'link'}