From a7022de9b5ee7633a98daed9bfb01a87d3146d37 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 30 Apr 2021 16:17:57 +0100 Subject: [PATCH] Moving drawers around to be a common component as they are utilised in a few places, keep all the binding work together, as well as some fixing for readable/runtime binding detection and conversion. --- .../builder/src/builderStore/dataBinding.js | 10 +++++- .../SetupPanel/AutomationBlockSetup.svelte | 4 +-- .../automation/SetupPanel/RowSelector.svelte | 4 +-- .../DataTable/modals/CreateEditColumn.svelte | 2 +- .../bindings}/BindingPanel.svelte | 31 ++++++++----------- .../{ => bindings}/DrawerBindableInput.svelte | 4 +-- .../{ => bindings}/ModalBindableInput.svelte | 2 +- .../{ => bindings}/ServerBindingPanel.svelte | 31 +++++++++---------- .../src/components/common/bindings/utils.js | 15 +++++++++ .../EventsEditor/actions/DeleteRow.svelte | 2 +- .../EventsEditor/actions/LogIn.svelte | 2 +- .../EventsEditor/actions/NavigateTo.svelte | 2 +- .../EventsEditor/actions/SaveFields.svelte | 2 +- .../PropertyControls/PropertyControl.svelte | 2 +- .../integration/QueryParameterBuilder.svelte | 2 +- .../string-templates/test/helpers.spec.js | 13 ++++++++ 16 files changed, 79 insertions(+), 49 deletions(-) rename packages/builder/src/components/{design/PropertiesPanel => common/bindings}/BindingPanel.svelte (89%) rename packages/builder/src/components/common/{ => bindings}/DrawerBindableInput.svelte (92%) rename packages/builder/src/components/common/{ => bindings}/ModalBindableInput.svelte (95%) rename packages/builder/src/components/common/{ => bindings}/ServerBindingPanel.svelte (88%) create mode 100644 packages/builder/src/components/common/bindings/utils.js diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index b42e58be3f..c2c1a0ff71 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -340,8 +340,16 @@ function shouldReplaceBinding(currentValue, from, convertTo) { if (convertTo === "readableBinding") { return true } + // remove all the spaces, if the input is surrounded by spaces e.g. [ Auto ID ] then + // this makes sure it is detected const noSpaces = currentValue.replace(/\s+/g, "") - return !noSpaces.includes(`[${from}]`) + const fromNoSpaces = from.replace(/\s+/g, "") + const invalids = [ + `[${fromNoSpaces}]`, + `"${fromNoSpaces}"`, + `'${fromNoSpaces}'`, + ] + return !invalids.find(invalid => noSpaces.includes(invalid)) } /** diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte index ecc2a3a83c..8e1cdc6282 100644 --- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte +++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte @@ -5,8 +5,8 @@ import { Button, Input, Select, Label } from "@budibase/bbui" import { automationStore } from "builderStore" import WebhookDisplay from "../Shared/WebhookDisplay.svelte" - import DrawerBindableInput from "../../common/DrawerBindableInput.svelte" - import AutomationBindingPanel from "../../common/ServerBindingPanel.svelte" + import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" + import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" export let block export let webhookModal diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index 4444a142da..84e5fc823c 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -1,8 +1,8 @@