From 0921bcf3334e6a77a67b8771005587e2f37a3af4 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 1 Nov 2023 11:40:27 +0000 Subject: [PATCH 01/15] Add button setting to grid and allow removing all buttons --- .../ButtonConfiguration/ButtonConfiguration.svelte | 13 ++++++++----- packages/client/manifest.json | 10 ++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonConfiguration.svelte b/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonConfiguration.svelte index 324418511b..6fed8abdba 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonConfiguration.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonConfiguration.svelte @@ -19,7 +19,7 @@ componentBindings: componentBindings || [], bindings, removeButton, - canRemove: buttonCount > 1, + canRemove: true, } const sanitizeValue = val => { @@ -86,11 +86,11 @@ focus={focusItem} draggable={buttonCount > 1} /> - - {/if} + + diff --git a/packages/frontend-core/src/components/grid/layout/Grid.svelte b/packages/frontend-core/src/components/grid/layout/Grid.svelte index e2ecd0f968..285282ddf7 100644 --- a/packages/frontend-core/src/components/grid/layout/Grid.svelte +++ b/packages/frontend-core/src/components/grid/layout/Grid.svelte @@ -48,6 +48,7 @@ export let fixedRowHeight = null export let notifySuccess = null export let notifyError = null + export let buttons = null // Unique identifier for DOM nodes inside this instance const rand = Math.random() @@ -99,6 +100,7 @@ fixedRowHeight, notifySuccess, notifyError, + buttons, }) // Set context for children to consume diff --git a/packages/frontend-core/src/components/grid/layout/GridBody.svelte b/packages/frontend-core/src/components/grid/layout/GridBody.svelte index 0bb2a51fb4..559c465b86 100644 --- a/packages/frontend-core/src/components/grid/layout/GridBody.svelte +++ b/packages/frontend-core/src/components/grid/layout/GridBody.svelte @@ -3,6 +3,7 @@ import GridScrollWrapper from "./GridScrollWrapper.svelte" import GridRow from "./GridRow.svelte" import { BlankRowID } from "../lib/constants" + import ButtonColumn from "./ButtonColumn.svelte" const { bounds, @@ -13,6 +14,7 @@ dispatch, isDragging, config, + props, } = getContext("grid") let body @@ -54,6 +56,9 @@ /> {/if} + {#if $props.buttons?.length} + + {/if} diff --git a/packages/client/manifest.json b/packages/client/manifest.json index d131cda8c3..378d8c3493 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -6348,6 +6348,7 @@ "type": "buttonConfiguration", "key": "buttons", "nested": true, + "max": 3, "context": [ { "label": "Clicked row", From d92df57daa35ce814b224495b056d21b098976ae Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 16:20:05 +0000 Subject: [PATCH 13/15] Remove nested flag from buttongroup component since it isn't needed --- packages/client/manifest.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 378d8c3493..5979d177f4 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -270,7 +270,6 @@ { "type": "buttonConfiguration", "key": "buttons", - "nested": true, "defaultValue": [ { "type": "cta", From bb47b91064e17dd1a6ff2b4ddd1c71ff367b832b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 9 Nov 2023 16:20:44 +0000 Subject: [PATCH 14/15] Add new disableBindings property to prevent a text field from being bindable when required --- .../common/bindings/DrawerBindableInput.svelte | 3 ++- .../ButtonConfiguration/ButtonSetting.svelte | 18 ++++++++++++------ .../settings/controls/PropertyControl.svelte | 2 ++ .../Component/ComponentSettingsSection.svelte | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte b/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte index 5c4f90606d..09732ce4f2 100644 --- a/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte +++ b/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte @@ -21,6 +21,7 @@ export let allowHelpers = true export let updateOnChange = true export let drawerLeft + export let disableBindings = false const dispatch = createEventDispatcher() let bindingDrawer @@ -62,7 +63,7 @@ {placeholder} {updateOnChange} /> - {#if !disabled} + {#if !disabled && !disableBindings}
{ diff --git a/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonSetting.svelte b/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonSetting.svelte index 8e8c89ac14..56b5deace4 100644 --- a/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonSetting.svelte +++ b/packages/builder/src/components/design/settings/controls/ButtonConfiguration/ButtonSetting.svelte @@ -17,18 +17,24 @@ // If this is a nested setting (for example inside a grid or form block) then // we need to mark all the settings of the actual buttons as nested too, to - // allow us to reference context provided by the block + // allow us to reference context provided by the block. + // We will need to update this in future if the normal button component + // gets broken into multiple settings sections, as we assume a flat array. const updatedNestedFlags = settings => { - if (!nested) { + if (!nested || !settings?.length) { return settings } - // Buttons do not currently have any sections, so this works. - // We will need to update this in future if the normal button component - // gets broken into multiple settings sections - return settings?.map(setting => ({ + let newSettings = settings.map(setting => ({ ...setting, nested: true, })) + // We need to prevent bindings for the button names because of how grid + // blocks work. This is an edge case but unavoidable. + let name = newSettings.find(x => x.key === "text") + if (name) { + name.disableBindings = true + } + return newSettings } diff --git a/packages/builder/src/components/design/settings/controls/PropertyControl.svelte b/packages/builder/src/components/design/settings/controls/PropertyControl.svelte index c8135b4f61..a6f3d1b218 100644 --- a/packages/builder/src/components/design/settings/controls/PropertyControl.svelte +++ b/packages/builder/src/components/design/settings/controls/PropertyControl.svelte @@ -23,6 +23,7 @@ export let highlighted = false export let propertyFocus = false export let info = null + export let disableBindings = false $: nullishValue = value == null || value === "" $: allBindings = getAllBindings(bindings, componentBindings, nested) @@ -99,6 +100,7 @@ {nested} {key} {type} + {disableBindings} {...props} on:drawerHide on:drawerShow diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte index 65f010e4ec..6093d2a45e 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ComponentSettingsSection.svelte @@ -179,6 +179,7 @@ highlighted={$store.highlightedSettingKey === setting.key} propertyFocus={$store.propertyFocus === setting.key} info={setting.info} + disableBindings={setting.disableBindings} props={{ // Generic settings placeholder: setting.placeholder || null, From e04ea1a620ca5878b8affa043ff72fd3b70dbb5a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 20 Nov 2023 08:30:42 +0000 Subject: [PATCH 15/15] Add makePropSafe to client SDK --- packages/client/src/sdk.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/client/src/sdk.js b/packages/client/src/sdk.js index b83039df2a..69c2cc9fd4 100644 --- a/packages/client/src/sdk.js +++ b/packages/client/src/sdk.js @@ -26,7 +26,7 @@ import { ActionTypes } from "./constants" import { fetchDatasourceSchema } from "./utils/schema.js" import { getAPIKey } from "./utils/api.js" import { enrichButtonActions } from "./utils/buttonActions.js" -import { processStringSync } from "@budibase/string-templates" +import { processStringSync, makePropSafe } from "@budibase/string-templates" export default { API, @@ -56,6 +56,7 @@ export default { getAPIKey, enrichButtonActions, processStringSync, + makePropSafe, // Components Provider,