From a20af34a031fb4b613ca531a582374b2aaafbef5 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 18 Oct 2021 16:03:13 +0100 Subject: [PATCH] refactor to remove object reference --- .../backend/DataTable/DataTable.svelte | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index 63be588931..336bb51670 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -16,34 +16,34 @@ import { Pagination } from "@budibase/bbui" let hideAutocolumns = true - let copiedSchema - let schema $: isUsersTable = $tables.selected?._id === TableNames.USERS $: type = $tables.selected?.type $: isInternal = type !== "external" - $: { - schema = $tables.selected?.schema - copiedSchema = schema + $: schema = $tables.selected?.schema + $: enrichedSchema = enrichSchema($tables.selected?.schema) + $: id = $tables.selected?._id + $: search = searchTable(id) + $: columnOptions = Object.keys($search.schema || {}) - copiedSchema._id = { + const enrichSchema = schema => { + let tempSchema = { ...schema } + tempSchema._id = { type: "internal", editable: false, displayName: "ID", autocolumn: true, } if (isInternal) { - copiedSchema._rev = { + tempSchema._rev = { type: "internal", editable: false, displayName: "Revision", autocolumn: true, } } - } - $: id = $tables.selected?._id - $: search = searchTable(id) - $: columnOptions = Object.keys($search.schema || {}) + return tempSchema + } // Fetches new data whenever the table changes const searchTable = tableId => { return fetchTableData({ @@ -86,7 +86,7 @@