Add onChange to linked rows, longform text area, and multi select arrays in automations (#11874)

* Add onChange to LinkedRowSelector

* Add onChange to Multiselect array

* Add onChange to TextArea

* lint
This commit is contained in:
melohagan 2023-09-25 11:50:01 +01:00 committed by GitHub
parent 799f62d218
commit f3309a742c
3 changed files with 21 additions and 6 deletions

View File

@ -83,8 +83,7 @@
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value return value
} }
return value.split(",").map(x => x.trim())
return [value]
} }
if (type === "json") { if (type === "json") {
@ -146,7 +145,7 @@
placeholder={placeholders[schema.type]} placeholder={placeholders[schema.type]}
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
value={Array.isArray(value[field]) value={Array.isArray(value[field])
? value[field].join(" ") ? value[field].join(",")
: value[field]} : value[field]}
on:change={e => onChange(e, field, schema.type)} on:change={e => onChange(e, field, schema.type)}
label={field} label={field}

View File

@ -55,9 +55,14 @@
bind:value={value[field]} bind:value={value[field]}
label={field} label={field}
options={schema.constraints.inclusion} options={schema.constraints.inclusion}
on:change={e => onChange(e, field)}
/> />
{:else if schema.type === "longform"} {:else if schema.type === "longform"}
<TextArea label={field} bind:value={value[field]} /> <TextArea
label={field}
bind:value={value[field]}
on:change={e => onChange(e, field)}
/>
{:else if schema.type === "json"} {:else if schema.type === "json"}
<span> <span>
<Label>{field}</Label> <Label>{field}</Label>
@ -73,7 +78,11 @@
/> />
</span> </span>
{:else if schema.type === "link"} {:else if schema.type === "link"}
<LinkedRowSelector bind:linkedRows={value[field]} {schema} /> <LinkedRowSelector
bind:linkedRows={value[field]}
{schema}
on:change={e => onChange(e, field)}
/>
{:else if schema.type === "string" || schema.type === "number"} {:else if schema.type === "string" || schema.type === "number"}
<svelte:component <svelte:component
this={isTestModal ? ModalBindableInput : DrawerBindableInput} this={isTestModal ? ModalBindableInput : DrawerBindableInput}

View File

@ -3,10 +3,13 @@
import { API } from "api" import { API } from "api"
import { Select, Label, Multiselect } from "@budibase/bbui" import { Select, Label, Multiselect } from "@budibase/bbui"
import { capitalise } from "../../helpers" import { capitalise } from "../../helpers"
import { createEventDispatcher } from "svelte"
export let schema export let schema
export let linkedRows = [] export let linkedRows = []
const dispatch = createEventDispatcher()
let rows = [] let rows = []
let linkedIds = (Array.isArray(linkedRows) ? linkedRows : [])?.map( let linkedIds = (Array.isArray(linkedRows) ? linkedRows : [])?.map(
row => row?._id || row row => row?._id || row
@ -44,7 +47,10 @@
options={rows} options={rows}
getOptionLabel={getPrettyName} getOptionLabel={getPrettyName}
getOptionValue={row => row._id} getOptionValue={row => row._id}
on:change={e => (linkedIds = e.detail ? [e.detail] : [])} on:change={e => {
linkedIds = e.detail ? [e.detail] : []
dispatch("change", linkedIds)
}}
{label} {label}
sort sort
/> />
@ -56,5 +62,6 @@
getOptionLabel={getPrettyName} getOptionLabel={getPrettyName}
getOptionValue={row => row._id} getOptionValue={row => row._id}
sort sort
on:change={() => dispatch("change", linkedIds)}
/> />
{/if} {/if}