update how we handle coercion of types
This commit is contained in:
parent
0affc0d0c2
commit
bb5ad1c2bf
|
@ -11,6 +11,8 @@
|
||||||
ActionButton,
|
ActionButton,
|
||||||
notifications,
|
notifications,
|
||||||
Modal,
|
Modal,
|
||||||
|
Toggle,
|
||||||
|
Tooltip,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import ConfigModal from "./ConfigModal.svelte"
|
import ConfigModal from "./ConfigModal.svelte"
|
||||||
|
|
||||||
|
@ -22,6 +24,7 @@
|
||||||
let blocks
|
let blocks
|
||||||
let confirmDeleteDialog
|
let confirmDeleteDialog
|
||||||
|
|
||||||
|
$: rowControl = $automationStore.selectedAutomation.automation.rowControl
|
||||||
$: {
|
$: {
|
||||||
blocks = []
|
blocks = []
|
||||||
if (automation) {
|
if (automation) {
|
||||||
|
@ -32,6 +35,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
@ -61,16 +71,11 @@
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="subtitle">
|
<div class="subtitle">
|
||||||
<Heading size="S">{automation.name}</Heading>
|
<Heading size="S">{automation.name}</Heading>
|
||||||
<div style="display:flex;">
|
<div style="display:flex; align-items: center;">
|
||||||
<div class="iconPadding">
|
<div class="iconPadding">
|
||||||
<div class="icon">
|
<Tooltip direction="left" text="Allow binding to all inputs">
|
||||||
<Icon
|
<Toggle bind:value={rowControl} on:change={toggleFieldControl} />
|
||||||
hoverable
|
</Tooltip>
|
||||||
size="M"
|
|
||||||
on:click={configModal.show}
|
|
||||||
name="Settings"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="iconPadding">
|
<div class="iconPadding">
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
boolean: "true",
|
boolean: "true",
|
||||||
datetime: "2022-02-16T12:00:00.000Z ",
|
datetime: "2022-02-16T12:00:00.000Z ",
|
||||||
options: "1",
|
options: "1",
|
||||||
array: "1,2,3,4",
|
array: "1 2 3 4",
|
||||||
link: "ro_ta_123_456",
|
link: "ro_ta_123_456",
|
||||||
longform: "long form text",
|
longform: "long form text",
|
||||||
}
|
}
|
||||||
|
@ -43,19 +43,32 @@
|
||||||
|
|
||||||
const coerce = (value, type) => {
|
const coerce = (value, type) => {
|
||||||
if (type === "boolean") {
|
if (type === "boolean") {
|
||||||
|
if (typeof value === "boolean") {
|
||||||
|
return value
|
||||||
|
}
|
||||||
return value === "true"
|
return value === "true"
|
||||||
}
|
}
|
||||||
if (type === "number") {
|
if (type === "number") {
|
||||||
|
if (typeof value === "number") {
|
||||||
|
return value
|
||||||
|
}
|
||||||
return Number(value)
|
return Number(value)
|
||||||
}
|
}
|
||||||
if (type === "options") {
|
if (type === "options") {
|
||||||
return [value]
|
return [value]
|
||||||
}
|
}
|
||||||
if (type === "array") {
|
if (type === "array") {
|
||||||
return value.split(",")
|
if (Array.isArray(value)) {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
return value.split(",").map(x => x.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "link") {
|
if (type === "link") {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
return [value]
|
return [value]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +115,7 @@
|
||||||
type={value.customType}
|
type={value.customType}
|
||||||
on:change={e => onChange(e, field, schema.type)}
|
on:change={e => onChange(e, field, schema.type)}
|
||||||
{bindings}
|
{bindings}
|
||||||
|
allowJS={true}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if $automationStore.selectedAutomation.automation.rowControl}
|
{:else if $automationStore.selectedAutomation.automation.rowControl}
|
||||||
|
@ -116,7 +130,7 @@
|
||||||
type="string"
|
type="string"
|
||||||
{bindings}
|
{bindings}
|
||||||
fillWidth={true}
|
fillWidth={true}
|
||||||
allowJS={false}
|
allowJS={true}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -59,6 +59,6 @@
|
||||||
type="string"
|
type="string"
|
||||||
{bindings}
|
{bindings}
|
||||||
fillWidth={true}
|
fillWidth={true}
|
||||||
allowJS={false}
|
allowJS={true}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in New Issue