From c0d929fd2fc5c9827f7f9a04fd50805da66b09e1 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Tue, 15 Feb 2022 13:03:24 +0000 Subject: [PATCH] update automation type coercion --- .../builderStore/store/automation/index.js | 2 +- .../AutomationBuilder.svelte | 8 +-- .../FlowChart/FlowChart.svelte | 16 +---- .../FlowChart/FlowItem.svelte | 60 +++++++++++++++---- .../SetupPanel/AutomationBlockSetup.svelte | 1 + .../automation/SetupPanel/RowSelector.svelte | 20 ++++--- .../SetupPanel/RowSelectorTypes.svelte | 2 +- .../common/bindings/BindingPanel.svelte | 10 ++-- packages/builder/src/stores/portal/apps.js | 1 - 9 files changed, 73 insertions(+), 47 deletions(-) diff --git a/packages/builder/src/builderStore/store/automation/index.js b/packages/builder/src/builderStore/store/automation/index.js index 148fe4fdd2..e6ac8d19d8 100644 --- a/packages/builder/src/builderStore/store/automation/index.js +++ b/packages/builder/src/builderStore/store/automation/index.js @@ -122,7 +122,7 @@ const automationActions = store => ({ }, toggleFieldControl: value => { store.update(state => { - state.selectedAutomation.automation.rowControl = value + state.selectedBlock.rowControl = value return state }) }, diff --git a/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte b/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte index 7ce77a58e3..e852ee1a0d 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/AutomationBuilder.svelte @@ -3,14 +3,8 @@ import Flowchart from "./FlowChart/FlowChart.svelte" $: automation = $automationStore.selectedAutomation?.automation - function onSelect(block) { - automationStore.update(state => { - state.selectedBlock = block - return state - }) - } {#if automation} - + {/if} diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte index ea4ddfb61d..ecdfc27e8b 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowChart.svelte @@ -16,13 +16,11 @@ } from "@budibase/bbui" export let automation - export let onSelect let testDataModal let blocks let confirmDeleteDialog - $: rowControl = $automationStore.selectedAutomation.automation.rowControl $: { blocks = [] if (automation) { @@ -33,13 +31,6 @@ } } - function toggleFieldControl(evt) { - automationStore.actions.toggleFieldControl(evt.detail) - automationStore.actions.save( - $automationStore.selectedAutomation?.automation - ) - } - async function deleteAutomation() { await automationStore.actions.delete( $automationStore.selectedAutomation?.automation @@ -70,11 +61,6 @@
{automation.name}
-
- - - -
- +
{/each}
diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 0c5ec6e438..71e43a3fa6 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -10,6 +10,7 @@ Button, StatusLight, ActionButton, + Select, } from "@budibase/bbui" import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" @@ -17,7 +18,6 @@ import ActionModal from "./ActionModal.svelte" import { externalActions } from "./ExternalActions" - export let onSelect export let block export let testDataModal let selected @@ -26,6 +26,9 @@ let resultsModal let setupToggled let blockComplete + + $: rowControl = $automationStore.selectedAutomation.automation.rowControl + $: testResult = $automationStore.selectedAutomation.testResults?.steps.filter( step => (block.id ? step.id === block.id : step.stepId === block.stepId) ) @@ -42,12 +45,6 @@ $automationStore.selectedAutomation?.automation?.definition?.steps.length + 1 - // Logic for hiding / showing the add button.first we check if it has a child - // then we check to see whether its inputs have been commpleted - $: disableAddButton = isTrigger - ? $automationStore.selectedAutomation?.automation?.definition?.steps - .length > 0 - : !isTrigger && steps.length - blockIdx > 1 $: hasCompletedInputs = Object.keys( block.schema?.inputs?.properties || {} ).every(x => block?.inputs[x]) @@ -58,6 +55,26 @@ $automationStore.selectedAutomation?.automation ) } + function toggleFieldControl(evt) { + onSelect(block) + let rowControl + if (evt.detail === "Use values") { + rowControl = false + } else { + rowControl = true + } + automationStore.actions.toggleFieldControl(rowControl) + automationStore.actions.save( + $automationStore.selectedAutomation?.automation + ) + } + + async function onSelect(block) { + await automationStore.update(state => { + state.selectedBlock = block + return state + }) + }
(setupToggled = !setupToggled)} + on:click={() => { + onSelect(block) + setupToggled = !setupToggled + }} quiet icon={setupToggled ? "ChevronDown" : "ChevronRight"} > Setup {#if !isTrigger} -
deleteStep()}> - +
+
+