From b41287630a4bce05aaf073b4aeccf52140111e08 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 18 Oct 2021 14:53:57 +0100 Subject: [PATCH 1/4] copy table schema and dont mutate directly --- .../src/components/backend/DataTable/DataTable.svelte | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index f1d23e8f3d..63be588931 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -16,22 +16,23 @@ 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 - // Manually add these as we don't want them to be 'real' auto-columns - schema._id = { + copiedSchema._id = { type: "internal", editable: false, displayName: "ID", autocolumn: true, } if (isInternal) { - schema._rev = { + copiedSchema._rev = { type: "internal", editable: false, displayName: "Revision", @@ -85,7 +86,7 @@
Date: Mon, 18 Oct 2021 15:08:57 +0100 Subject: [PATCH 2/4] add internal renderer back --- packages/bbui/src/Table/CellRenderer.svelte | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte index a4345512a3..9a53fd0169 100644 --- a/packages/bbui/src/Table/CellRenderer.svelte +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -5,6 +5,7 @@ import RelationshipRenderer from "./RelationshipRenderer.svelte" import AttachmentRenderer from "./AttachmentRenderer.svelte" import ArrayRenderer from "./ArrayRenderer.svelte" + import InternalRenderer from "./InternalRenderer.svelte" export let row export let schema @@ -22,6 +23,7 @@ number: StringRenderer, longform: StringRenderer, array: ArrayRenderer, + internal: InternalRenderer, } $: type = schema?.type ?? "string" $: customRenderer = customRenderers?.find(x => x.column === schema?.name) From ee77ce7e6bd7b69fb1db04fb766f4685644f7e36 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 18 Oct 2021 15:10:10 +0100 Subject: [PATCH 3/4] fix formula column creation --- .../builder/src/components/backend/DataTable/formula.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/builder/src/components/backend/DataTable/formula.js b/packages/builder/src/components/backend/DataTable/formula.js index 3d03d577e7..42f203ca1c 100644 --- a/packages/builder/src/components/backend/DataTable/formula.js +++ b/packages/builder/src/components/backend/DataTable/formula.js @@ -4,10 +4,15 @@ import { get as svelteGet } from "svelte/store" // currently supported level of relationship depth (server side) const MAX_DEPTH = 1 + +//https://github.com/Budibase/budibase/issues/3030 +const internalType = "internal" + const TYPES_TO_SKIP = [ FIELDS.FORMULA.type, FIELDS.LONGFORM.type, FIELDS.ATTACHMENT.type, + internalType, ] export function getBindings({ @@ -53,6 +58,7 @@ export function getBindings({ const field = Object.values(FIELDS).find( field => field.type === schema.type ) + const label = path == null ? column : `${path}.0.${column}` // only supply a description for relationship paths const description = From 677d80b38b623835a6aedc24adc2c970c4427f57 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 18 Oct 2021 16:03:13 +0100 Subject: [PATCH 4/4] 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 @@