Merge pull request #8283 from Budibase/fix/json-field-in-automation-step

Add JSON field to automation step
This commit is contained in:
deanhannigan 2022-10-24 12:35:19 +01:00 committed by GitHub
commit 348be5bf87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 3 deletions

View File

@ -14,6 +14,12 @@
export let block export let block
export let isTestModal export let isTestModal
$: parsedBindings = bindings.map(binding => {
let clone = Object.assign({}, binding)
clone.icon = "ShareAndroid"
return clone
})
let table let table
let schemaFields let schemaFields
@ -79,6 +85,10 @@
return [value] return [value]
} }
if (type === "json") {
return value.value
}
return value return value
} }
@ -109,7 +119,7 @@
{isTestModal} {isTestModal}
{field} {field}
{schema} {schema}
{bindings} bindings={parsedBindings}
{value} {value}
{onChange} {onChange}
/> />
@ -124,7 +134,7 @@
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={parsedBindings}
fillWidth={true} fillWidth={true}
allowJS={true} allowJS={true}
updateOnChange={false} updateOnChange={false}

View File

@ -5,11 +5,13 @@
DatePicker, DatePicker,
Multiselect, Multiselect,
TextArea, TextArea,
Label,
} from "@budibase/bbui" } from "@budibase/bbui"
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" import LinkedRowSelector from "components/common/LinkedRowSelector.svelte"
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
import ModalBindableInput from "../../common/bindings/ModalBindableInput.svelte" import ModalBindableInput from "../../common/bindings/ModalBindableInput.svelte"
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
import Editor from "components/integration/QueryEditor.svelte"
export let onChange export let onChange
export let field export let field
@ -18,6 +20,12 @@
export let bindings export let bindings
export let isTestModal export let isTestModal
$: parsedBindings = bindings.map(binding => {
let clone = Object.assign({}, binding)
clone.icon = "ShareAndroid"
return clone
})
function schemaHasOptions(schema) { function schemaHasOptions(schema) {
return !!schema.constraints?.inclusion?.length return !!schema.constraints?.inclusion?.length
} }
@ -50,6 +58,20 @@
/> />
{:else if schema.type === "longform"} {:else if schema.type === "longform"}
<TextArea label={field} bind:value={value[field]} /> <TextArea label={field} bind:value={value[field]} />
{:else if schema.type === "json"}
<span>
<Label>{field}</Label>
<Editor
editorHeight="150"
mode="json"
on:change={e => {
if (e.detail?.value !== value[field]) {
onChange(e, field, schema.type)
}
}}
value={value[field]}
/>
</span>
{:else if schema.type === "link"} {:else if schema.type === "link"}
<LinkedRowSelector bind:linkedRows={value[field]} {schema} /> <LinkedRowSelector bind:linkedRows={value[field]} {schema} />
{:else if schema.type === "string" || schema.type === "number"} {:else if schema.type === "string" || schema.type === "number"}
@ -60,7 +82,7 @@
on:change={e => onChange(e, field)} on:change={e => onChange(e, field)}
label={field} label={field}
type="string" type="string"
{bindings} bindings={parsedBindings}
fillWidth={true} fillWidth={true}
allowJS={true} allowJS={true}
updateOnChange={false} updateOnChange={false}