1
0
Fork 0
mirror of synced 2024-06-29 11:31:06 +12:00

update automation type coercion

This commit is contained in:
Peter Clement 2022-02-15 13:03:24 +00:00
parent 28ebc65397
commit 77822bbca3
9 changed files with 73 additions and 47 deletions

View file

@ -122,7 +122,7 @@ const automationActions = store => ({
}, },
toggleFieldControl: value => { toggleFieldControl: value => {
store.update(state => { store.update(state => {
state.selectedAutomation.automation.rowControl = value state.selectedBlock.rowControl = value
return state return state
}) })
}, },

View file

@ -3,14 +3,8 @@
import Flowchart from "./FlowChart/FlowChart.svelte" import Flowchart from "./FlowChart/FlowChart.svelte"
$: automation = $automationStore.selectedAutomation?.automation $: automation = $automationStore.selectedAutomation?.automation
function onSelect(block) {
automationStore.update(state => {
state.selectedBlock = block
return state
})
}
</script> </script>
{#if automation} {#if automation}
<Flowchart {automation} {onSelect} /> <Flowchart {automation} />
{/if} {/if}

View file

@ -16,13 +16,11 @@
} from "@budibase/bbui" } from "@budibase/bbui"
export let automation export let automation
export let onSelect
let testDataModal let testDataModal
let blocks let blocks
let confirmDeleteDialog let confirmDeleteDialog
$: rowControl = $automationStore.selectedAutomation.automation.rowControl
$: { $: {
blocks = [] blocks = []
if (automation) { if (automation) {
@ -33,13 +31,6 @@
} }
} }
function toggleFieldControl(evt) {
automationStore.actions.toggleFieldControl(evt.detail)
automationStore.actions.save(
$automationStore.selectedAutomation?.automation
)
}
async function deleteAutomation() { async function deleteAutomation() {
await automationStore.actions.delete( await automationStore.actions.delete(
$automationStore.selectedAutomation?.automation $automationStore.selectedAutomation?.automation
@ -70,11 +61,6 @@
<div class="subtitle"> <div class="subtitle">
<Heading size="S">{automation.name}</Heading> <Heading size="S">{automation.name}</Heading>
<div style="display:flex; align-items: center;"> <div style="display:flex; align-items: center;">
<div class="iconPadding">
<Tooltip direction="left" text="Allow binding to all inputs">
<Toggle bind:value={rowControl} on:change={toggleFieldControl} />
</Tooltip>
</div>
<div class="iconPadding"> <div class="iconPadding">
<div class="icon"> <div class="icon">
<Icon <Icon
@ -101,7 +87,7 @@
animate:flip={{ duration: 500 }} animate:flip={{ duration: 500 }}
in:fly|local={{ x: 500, duration: 1500 }} in:fly|local={{ x: 500, duration: 1500 }}
> >
<FlowItem {testDataModal} {testAutomation} {onSelect} {block} /> <FlowItem {testDataModal} {testAutomation} {block} />
</div> </div>
{/each} {/each}
</div> </div>

View file

@ -10,6 +10,7 @@
Button, Button,
StatusLight, StatusLight,
ActionButton, ActionButton,
Select,
} from "@budibase/bbui" } from "@budibase/bbui"
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte" import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte" import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte"
@ -17,7 +18,6 @@
import ActionModal from "./ActionModal.svelte" import ActionModal from "./ActionModal.svelte"
import { externalActions } from "./ExternalActions" import { externalActions } from "./ExternalActions"
export let onSelect
export let block export let block
export let testDataModal export let testDataModal
let selected let selected
@ -26,6 +26,9 @@
let resultsModal let resultsModal
let setupToggled let setupToggled
let blockComplete let blockComplete
$: rowControl = $automationStore.selectedAutomation.automation.rowControl
$: testResult = $automationStore.selectedAutomation.testResults?.steps.filter( $: testResult = $automationStore.selectedAutomation.testResults?.steps.filter(
step => (block.id ? step.id === block.id : step.stepId === block.stepId) step => (block.id ? step.id === block.id : step.stepId === block.stepId)
) )
@ -42,12 +45,6 @@
$automationStore.selectedAutomation?.automation?.definition?.steps.length + $automationStore.selectedAutomation?.automation?.definition?.steps.length +
1 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( $: hasCompletedInputs = Object.keys(
block.schema?.inputs?.properties || {} block.schema?.inputs?.properties || {}
).every(x => block?.inputs[x]) ).every(x => block?.inputs[x])
@ -58,6 +55,26 @@
$automationStore.selectedAutomation?.automation $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
})
}
</script> </script>
<div <div
@ -120,15 +137,31 @@
<Layout noPadding gap="S"> <Layout noPadding gap="S">
<div class="splitHeader"> <div class="splitHeader">
<ActionButton <ActionButton
on:click={() => (setupToggled = !setupToggled)} on:click={() => {
onSelect(block)
setupToggled = !setupToggled
}}
quiet quiet
icon={setupToggled ? "ChevronDown" : "ChevronRight"} icon={setupToggled ? "ChevronDown" : "ChevronRight"}
> >
<Detail size="S">Setup</Detail> <Detail size="S">Setup</Detail>
</ActionButton> </ActionButton>
{#if !isTrigger} {#if !isTrigger}
<div on:click={() => deleteStep()}> <div class="block-options">
<Icon name="DeleteOutline" /> <div>
<Select
on:change={toggleFieldControl}
quiet
defaultValue="Use values"
autoWidth
value={rowControl ? "Use bindings" : "Use values"}
options={["Use values", "Use bindings"]}
placeholder={null}
/>
</div>
<div class="delete-padding" on:click={() => deleteStep()}>
<Icon name="DeleteOutline" />
</div>
</div> </div>
{/if} {/if}
</div> </div>
@ -174,6 +207,13 @@
{/if} {/if}
<style> <style>
.delete-padding {
padding-left: 30px;
}
.block-options {
display: flex;
align-items: center;
}
.center-items { .center-items {
display: flex; display: flex;
align-items: center; align-items: center;

View file

@ -222,6 +222,7 @@
/> />
{:else if value.customType === "row"} {:else if value.customType === "row"}
<RowSelector <RowSelector
{block}
value={inputData[key]} value={inputData[key]}
on:change={e => onChange(e, key)} on:change={e => onChange(e, key)}
{bindings} {bindings}

View file

@ -11,6 +11,8 @@
export let value export let value
export let bindings export let bindings
export let block
let table let table
let schemaFields let schemaFields
@ -23,7 +25,7 @@
link: "ro_ta_123_456", link: "ro_ta_123_456",
longform: "long form text", longform: "long form text",
} }
$: rowControl = block.rowControl
$: { $: {
table = $tables.list.find(table => table._id === value?.tableId) table = $tables.list.find(table => table._id === value?.tableId)
schemaFields = Object.entries(table?.schema ?? {}) schemaFields = Object.entries(table?.schema ?? {})
@ -97,7 +99,7 @@
{#if !schema.autocolumn} {#if !schema.autocolumn}
{#if schema.type !== "attachment"} {#if schema.type !== "attachment"}
{#if $automationStore.selectedAutomation.automation.testData} {#if $automationStore.selectedAutomation.automation.testData}
{#if !$automationStore.selectedAutomation.automation.rowControl} {#if !rowControl}
<RowSelectorTypes <RowSelectorTypes
{field} {field}
{schema} {schema}
@ -109,28 +111,32 @@
<DrawerBindableInput <DrawerBindableInput
placeholder={placeholders[schema.type]} placeholder={placeholders[schema.type]}
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
value={value[field]} value={Array.isArray(value[field])
? value[field].join(" ")
: value[field]}
on:change={e => onChange(e, field, schema.type)} on:change={e => onChange(e, field, schema.type)}
label={field} label={field}
type="string" type="string"
{bindings} {bindings}
fillWidth={true} fillWidth={true}
allowJS={false} allowJS={true}
/> />
{/if} {/if}
{:else if !$automationStore.selectedAutomation.automation.rowControl} {:else if !rowControl}
<RowSelectorTypes {field} {schema} {bindings} {value} {onChange} /> <RowSelectorTypes {field} {schema} {bindings} {value} {onChange} />
{:else} {:else}
<DrawerBindableInput <DrawerBindableInput
placeholder={placeholders[schema.type]} placeholder={placeholders[schema.type]}
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
value={value[field]} value={Array.isArray(value[field])
? value[field].join(" ")
: value[field]}
on:change={e => onChange(e, field, schema.type)} on:change={e => onChange(e, field, schema.type)}
label={field} label={field}
type="string" type="string"
{bindings} {bindings}
fillWidth={true} fillWidth={true}
allowJS={false} allowJS={true}
/> />
{/if} {/if}
{/if} {/if}

View file

@ -59,6 +59,6 @@
type="string" type="string"
{bindings} {bindings}
fillWidth={true} fillWidth={true}
allowJS={false} allowJS={true}
/> />
{/if} {/if}

View file

@ -26,14 +26,14 @@
export let value = "" export let value = ""
export let valid export let valid
export let allowJS = false export let allowJS = false
$: console.log(value)
let helpers = handlebarsCompletions() let helpers = handlebarsCompletions()
let getCaretPosition let getCaretPosition
let search = "" let search = ""
//let initialValueJS = value?.startsWith("{{ js ") let initialValueJS = value?.startsWith("{{ js ")
let mode = "Handlebars" let mode = initialValueJS ? "JavaScript" : "Handlebars"
let jsValue = null let jsValue = initialValueJS ? value : null
let hbsValue = value let hbsValue = initialValueJS ? null : value
$: usingJS = mode === "JavaScript" $: usingJS = mode === "JavaScript"
$: searchRgx = new RegExp(search, "ig") $: searchRgx = new RegExp(search, "ig")

View file

@ -66,7 +66,6 @@ export function createAppStore() {
} }
async function update(appId, value) { async function update(appId, value) {
console.log({ value })
const response = await api.put(`/api/applications/${appId}`, { ...value }) const response = await api.put(`/api/applications/${appId}`, { ...value })
if (response.status === 200) { if (response.status === 200) {
store.update(state => { store.update(state => {