From 7236ae80e59a56433bdf985a5aea49c8d0132d8f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 21 Feb 2022 13:19:29 +0000 Subject: [PATCH] Allow bindings for table cell values and break out cell settings into its own drawer component --- packages/bbui/package.json | 1 + packages/bbui/src/Table/CellRenderer.svelte | 19 +++++- .../common/bindings/BindingPanel.svelte | 2 +- .../ColumnEditor/CellDrawer.svelte | 66 +++++++++++++++++++ .../ColumnEditor/CellEditor.svelte | 34 ++++++++++ .../ColumnEditor/ColumnDrawer.svelte | 52 +++------------ .../ColumnEditor/ColumnEditor.svelte | 7 +- packages/client/manifest.json | 3 +- 8 files changed, 136 insertions(+), 48 deletions(-) create mode 100644 packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/CellDrawer.svelte create mode 100644 packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/CellEditor.svelte diff --git a/packages/bbui/package.json b/packages/bbui/package.json index a7570b12a0..d2c1d0318f 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -38,6 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", + "@budibase/string-templates": "^1.0.66-alpha.0", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte index 6fefd0f774..fad88d860c 100644 --- a/packages/bbui/src/Table/CellRenderer.svelte +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -6,6 +6,7 @@ import AttachmentRenderer from "./AttachmentRenderer.svelte" import ArrayRenderer from "./ArrayRenderer.svelte" import InternalRenderer from "./InternalRenderer.svelte" + import { processStringSync } from "@budibase/string-templates" export let row export let schema @@ -29,10 +30,24 @@ $: customRenderer = customRenderers?.find(x => x.column === schema?.name) $: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer $: width = schema?.width || "150px" + $: cellValue = getCellValue(value, schema.template) + + const getCellValue = (value, template) => { + if (!template) { + return value + } + return processStringSync(template, { value }) + } -{#if renderer && (customRenderer || (value != null && value !== ""))} - +{#if renderer && (customRenderer || (cellValue != null && cellValue !== ""))} + {/if} diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index 5c12d43ceb..2dfb3fda54 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -58,7 +58,7 @@ const updateValue = val => { valid = isValid(readableToRuntimeBinding(bindings, val)) if (valid) { - dispatch("change", value) + dispatch("change", val) } } diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/CellDrawer.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/CellDrawer.svelte new file mode 100644 index 0000000000..4443ff09ed --- /dev/null +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/CellDrawer.svelte @@ -0,0 +1,66 @@ + + + +
+ + + - - -
- (column.background = e.detail)} - alignRight - spectrumTheme={$store.theme} - /> -
-
- (column.color = e.detail)} - alignRight - spectrumTheme={$store.theme} - /> -
+ .container { width: 100%; - max-width: 1200px; + max-width: 600px; margin: 0 auto; } .columns { @@ -212,7 +178,7 @@ .column { gap: var(--spacing-l); display: grid; - grid-template-columns: 20px 1fr 1fr 1fr 1fr 1fr 72px 72px 20px; + grid-template-columns: 20px 1fr 1fr auto auto; align-items: center; border-radius: var(--border-radius-s); transition: background-color ease-in-out 130ms; diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/ColumnEditor.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/ColumnEditor.svelte index a4dbb4e49a..132f856492 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/ColumnEditor.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ColumnEditor/ColumnEditor.svelte @@ -56,13 +56,18 @@ }) } + const open = () => { + updateBoundValue(sanitisedValue) + drawer.show() + } + const save = () => { dispatch("change", getValidColumns(boundValue, options)) drawer.hide() } -Configure columns +Configure columns Configure the columns in your table. diff --git a/packages/client/manifest.json b/packages/client/manifest.json index c08c4e17d3..ce5baaacf5 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -2679,7 +2679,8 @@ "type": "columns", "label": "Columns", "key": "columns", - "dependsOn": "dataProvider" + "dependsOn": "dataProvider", + "nested": true }, { "type": "select",