From e2ae8b8437ec6e9abc4bc0f71bbaa977ff4c7eff Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 12 Oct 2021 17:32:15 +0100 Subject: [PATCH] add ability to copy _rev and _id from data tab --- packages/bbui/src/Table/CellRenderer.svelte | 14 +++++++++- .../bbui/src/Table/InternalRenderer.svelte | 28 +++++++++++++++++++ .../automation/SetupPanel/RowSelector.svelte | 2 -- .../builder/src/constants/backend/index.js | 4 +++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 packages/bbui/src/Table/InternalRenderer.svelte diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte index d6a2f3196d..95aee839e8 100644 --- a/packages/bbui/src/Table/CellRenderer.svelte +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -5,11 +5,13 @@ 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 export let value export let customRenderers = [] + let renderer const typeMap = { boolean: BooleanRenderer, datetime: DateTimeRenderer, @@ -20,10 +22,20 @@ number: StringRenderer, longform: StringRenderer, array: ArrayRenderer, + internal: InternalRenderer, } $: type = schema?.type ?? "string" $: customRenderer = customRenderers?.find(x => x.column === schema?.name) - $: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer + $: { + // this has to be done purely in the front-end due to migration issues + // the schema gets overriden on every tables fetch so we can't just set + // these to be a new type unfortunately + if (schema.name === "_id" || schema.name === "_rev") { + renderer = customRenderer?.component ?? typeMap.internal ?? StringRenderer + } else { + renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer + } + } {#if renderer && (customRenderer || (value != null && value !== ""))} diff --git a/packages/bbui/src/Table/InternalRenderer.svelte b/packages/bbui/src/Table/InternalRenderer.svelte new file mode 100644 index 0000000000..0f894ac853 --- /dev/null +++ b/packages/bbui/src/Table/InternalRenderer.svelte @@ -0,0 +1,28 @@ + + +
+ +
+ + diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index 3821157e51..d1ab19761b 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -43,8 +43,6 @@ function schemaHasOptions(schema) { return !!schema.constraints?.inclusion?.length } - - $: console.log($tables.list)