From dfb5eb9bb668518609d1e5c3fd67223f9de6aeec Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 20 Aug 2020 17:04:54 +0100 Subject: [PATCH] renaming bug --- packages/builder/src/builderStore/store/backend.js | 8 +++++++- .../components/database/DataTable/ModelDataTable.svelte | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 80f931686b..6e75323b6d 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -93,7 +93,13 @@ export const getBackendUiStore = () => { saveField: ({ originalName, field }) => { store.update(state => { // delete the original if renaming - delete state.draftModel.schema[originalName] + if (originalName) { + delete state.draftModel.schema[originalName] + state.draftModel._rename = { + old: originalName, + updated: field.name, + } + } state.draftModel.schema[field.name] = cloneDeep(field) diff --git a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte index 6233e8cc19..25340818e2 100644 --- a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte +++ b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte @@ -45,9 +45,9 @@ $: sort = $backendUiStore.sort $: sorted = sort ? fsort(data)[sort.direction](sort.column) : data - $: headers = Object.keys($backendUiStore.selectedModel.schema).filter( - id => !INTERNAL_HEADERS.includes(id) - ) + $: headers = Object.keys($backendUiStore.selectedModel.schema) + .sort() + .filter(id => !INTERNAL_HEADERS.includes(id)) $: schema = $backendUiStore.selectedModel.schema