From d4b98095c21e5e4e9173001c0bfb683ea232a78f Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Fri, 11 Feb 2022 14:20:25 +0000 Subject: [PATCH] update how we handle coercion of types --- .../FlowChart/FlowChart.svelte | 23 +++++++++++-------- .../automation/SetupPanel/RowSelector.svelte | 20 +++++++++++++--- .../SetupPanel/RowSelectorTypes.svelte | 2 +- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte index f39bc2d337..8ee3d3d9bd 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte @@ -11,6 +11,8 @@ ActionButton, notifications, Modal, + Toggle, + Tooltip, } from "@budibase/bbui" import ConfigModal from "./ConfigModal.svelte" @@ -22,6 +24,7 @@ let blocks let confirmDeleteDialog + $: rowControl = $automationStore.selectedAutomation.automation.rowControl $: { blocks = [] if (automation) { @@ -32,6 +35,13 @@ } } + function toggleFieldControl(evt) { + automationStore.actions.toggleFieldControl(evt.detail) + automationStore.actions.save( + $automationStore.selectedAutomation?.automation + ) + } + async function deleteAutomation() { await automationStore.actions.delete( $automationStore.selectedAutomation?.automation @@ -61,16 +71,11 @@
{automation.name} -
+
-
- -
+ + +
diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte index d11e2c5908..5765684be6 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelector.svelte @@ -20,7 +20,7 @@ boolean: "true", datetime: "2022-02-16T12:00:00.000Z ", options: "1", - array: "1,2,3,4", + array: "1 2 3 4", link: "ro_ta_123_456", longform: "long form text", } @@ -43,19 +43,32 @@ const coerce = (value, type) => { if (type === "boolean") { + if (typeof value === "boolean") { + return value + } return value === "true" } if (type === "number") { + if (typeof value === "number") { + return value + } return Number(value) } if (type === "options") { return [value] } if (type === "array") { - return value.split(",") + if (Array.isArray(value)) { + return value + } + return value.split(",").map(x => x.trim()) } if (type === "link") { + if (Array.isArray(value)) { + return value + } + return [value] } @@ -102,6 +115,7 @@ type={value.customType} on:change={e => onChange(e, field, schema.type)} {bindings} + allowJS={true} /> {/if} {:else if $automationStore.selectedAutomation.automation.rowControl} @@ -116,7 +130,7 @@ type="string" {bindings} fillWidth={true} - allowJS={false} + allowJS={true} /> {/if} {/if} diff --git a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte index 8b6318f9e0..2a51e8d200 100644 --- a/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte +++ b/packages/builder/src/components/automation/SetupPanel/RowSelectorTypes.svelte @@ -59,6 +59,6 @@ type="string" {bindings} fillWidth={true} - allowJS={false} + allowJS={true} /> {/if}