commit
754aa82cec
|
@ -654,7 +654,7 @@ export const getSchemaForDatasource = (asset, datasource, options) => {
|
||||||
* Builds a form schema given a form component.
|
* Builds a form schema given a form component.
|
||||||
* A form schema is a schema of all the fields nested anywhere within a form.
|
* A form schema is a schema of all the fields nested anywhere within a form.
|
||||||
*/
|
*/
|
||||||
const buildFormSchema = component => {
|
export const buildFormSchema = component => {
|
||||||
let schema = {}
|
let schema = {}
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return schema
|
return schema
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
<script>
|
||||||
|
import { Select, Label, Combobox } from "@budibase/bbui"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
|
import { currentAsset, store } from "builderStore"
|
||||||
|
import {
|
||||||
|
getActionProviderComponents,
|
||||||
|
buildFormSchema,
|
||||||
|
} from "builderStore/dataBinding"
|
||||||
|
import { findComponent } from "builderStore/componentUtils"
|
||||||
|
|
||||||
|
export let parameters
|
||||||
|
export let bindings = []
|
||||||
|
|
||||||
|
const typeOptions = [
|
||||||
|
{
|
||||||
|
label: "Set value",
|
||||||
|
value: "set",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Reset to default value",
|
||||||
|
value: "reset",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
$: formComponent = findComponent($currentAsset.props, parameters.componentId)
|
||||||
|
$: formSchema = buildFormSchema(formComponent)
|
||||||
|
$: fieldOptions = Object.keys(formSchema || {})
|
||||||
|
$: actionProviders = getActionProviderComponents(
|
||||||
|
$currentAsset,
|
||||||
|
$store.selectedComponentId,
|
||||||
|
"ValidateForm"
|
||||||
|
)
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (!parameters.type) {
|
||||||
|
parameters.type = "set"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="root">
|
||||||
|
<Label small>Form</Label>
|
||||||
|
<Select
|
||||||
|
bind:value={parameters.componentId}
|
||||||
|
options={actionProviders}
|
||||||
|
getOptionLabel={x => x._instanceName}
|
||||||
|
getOptionValue={x => x._id}
|
||||||
|
/>
|
||||||
|
<Label small>Type</Label>
|
||||||
|
<Select
|
||||||
|
placeholder={null}
|
||||||
|
bind:value={parameters.type}
|
||||||
|
options={typeOptions}
|
||||||
|
/>
|
||||||
|
<Label small>Field</Label>
|
||||||
|
<Combobox bind:value={parameters.field} options={fieldOptions} />
|
||||||
|
{#if parameters.type === "set"}
|
||||||
|
<Label small>Value</Label>
|
||||||
|
<DrawerBindableInput
|
||||||
|
{bindings}
|
||||||
|
value={parameters.value}
|
||||||
|
on:change={e => (parameters.value = e.detail)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.root {
|
||||||
|
display: grid;
|
||||||
|
column-gap: var(--spacing-l);
|
||||||
|
row-gap: var(--spacing-s);
|
||||||
|
grid-template-columns: 60px 1fr;
|
||||||
|
align-items: center;
|
||||||
|
max-width: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -14,3 +14,4 @@ export { default as DuplicateRow } from "./DuplicateRow.svelte"
|
||||||
export { default as S3Upload } from "./S3Upload.svelte"
|
export { default as S3Upload } from "./S3Upload.svelte"
|
||||||
export { default as ExportData } from "./ExportData.svelte"
|
export { default as ExportData } from "./ExportData.svelte"
|
||||||
export { default as ContinueIf } from "./ContinueIf.svelte"
|
export { default as ContinueIf } from "./ContinueIf.svelte"
|
||||||
|
export { default as UpdateFieldValue } from "./UpdateFieldValue.svelte"
|
||||||
|
|
|
@ -42,25 +42,29 @@
|
||||||
"name": "Trigger Automation",
|
"name": "Trigger Automation",
|
||||||
"component": "TriggerAutomation"
|
"component": "TriggerAutomation"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "Update Field Value",
|
||||||
|
"component": "UpdateFieldValue"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Validate Form",
|
"name": "Validate Form",
|
||||||
"component": "ValidateForm"
|
"component": "ValidateForm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Log Out",
|
"name": "Change Form Step",
|
||||||
"component": "LogOut"
|
"component": "ChangeFormStep"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Clear Form",
|
"name": "Clear Form",
|
||||||
"component": "ClearForm"
|
"component": "ClearForm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Close Screen Modal",
|
"name": "Log Out",
|
||||||
"component": "CloseScreenModal"
|
"component": "LogOut"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Change Form Step",
|
"name": "Close Screen Modal",
|
||||||
"component": "ChangeFormStep"
|
"component": "CloseScreenModal"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Refresh Data Provider",
|
"name": "Refresh Data Provider",
|
||||||
|
|
|
@ -75,8 +75,8 @@
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="welcome">
|
<div class="welcome">
|
||||||
<Layout noPadding gap="XS">
|
<Layout noPadding gap="XS">
|
||||||
<Heading size="M">{createAppTitle}</Heading>
|
<Heading size="L">{createAppTitle}</Heading>
|
||||||
<Body size="S">
|
<Body size="M">
|
||||||
{welcomeBody}
|
{welcomeBody}
|
||||||
</Body>
|
</Body>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<Button
|
<Button
|
||||||
dataCy="create-app-btn"
|
dataCy="create-app-btn"
|
||||||
size="L"
|
size="M"
|
||||||
icon="Add"
|
icon="Add"
|
||||||
cta
|
cta
|
||||||
on:click={initiateAppCreation}
|
on:click={initiateAppCreation}
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
<Button
|
<Button
|
||||||
dataCy="import-app-btn"
|
dataCy="import-app-btn"
|
||||||
icon="Import"
|
icon="Import"
|
||||||
size="L"
|
size="M"
|
||||||
quiet
|
quiet
|
||||||
secondary
|
secondary
|
||||||
on:click={initiateAppImport}
|
on:click={initiateAppImport}
|
||||||
|
|
|
@ -1834,7 +1834,12 @@
|
||||||
"icon": "Form",
|
"icon": "Form",
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"illegalChildren": ["section", "form"],
|
"illegalChildren": ["section", "form"],
|
||||||
"actions": ["ValidateForm", "ClearForm", "ChangeFormStep"],
|
"actions": [
|
||||||
|
"ValidateForm",
|
||||||
|
"ClearForm",
|
||||||
|
"ChangeFormStep",
|
||||||
|
"UpdateFieldValue"
|
||||||
|
],
|
||||||
"styles": ["size"],
|
"styles": ["size"],
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
|
@ -1975,6 +1980,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2049,6 +2065,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2089,6 +2116,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2125,6 +2163,17 @@
|
||||||
"key": "placeholder",
|
"key": "placeholder",
|
||||||
"placeholder": "Choose an option"
|
"placeholder": "Choose an option"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"label": "Type",
|
"label": "Type",
|
||||||
|
@ -2274,6 +2323,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Autocomplete",
|
"label": "Autocomplete",
|
||||||
|
@ -2399,6 +2459,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2439,6 +2510,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "select",
|
"type": "select",
|
||||||
"label": "Formatting",
|
"label": "Formatting",
|
||||||
|
@ -2512,6 +2594,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2657,6 +2750,17 @@
|
||||||
"label": "Extensions",
|
"label": "Extensions",
|
||||||
"key": "extensions"
|
"key": "extensions"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2697,6 +2801,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Autocomplete",
|
"label": "Autocomplete",
|
||||||
|
@ -2742,6 +2857,17 @@
|
||||||
"label": "Default value",
|
"label": "Default value",
|
||||||
"key": "defaultValue"
|
"key": "defaultValue"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Disabled",
|
"label": "Disabled",
|
||||||
|
@ -2750,6 +2876,62 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"s3upload": {
|
||||||
|
"name": "S3 File Upload",
|
||||||
|
"info": "This component can't be used with S3 datasources that use custom endpoints.",
|
||||||
|
"icon": "UploadToCloud",
|
||||||
|
"styles": ["size"],
|
||||||
|
"editable": true,
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"type": "field/attachment",
|
||||||
|
"label": "Field",
|
||||||
|
"key": "field"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Label",
|
||||||
|
"key": "label"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "dataSource/s3",
|
||||||
|
"label": "S3 Datasource",
|
||||||
|
"key": "datasourceId"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "Bucket",
|
||||||
|
"key": "bucket"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"label": "File Name",
|
||||||
|
"key": "key"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "event",
|
||||||
|
"label": "On Change",
|
||||||
|
"key": "onChange",
|
||||||
|
"context": [
|
||||||
|
{
|
||||||
|
"label": "Field Value",
|
||||||
|
"key": "value"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"label": "Disabled",
|
||||||
|
"key": "disabled",
|
||||||
|
"defaultValue": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "validation/attachment",
|
||||||
|
"label": "Validation",
|
||||||
|
"key": "validation"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"dataprovider": {
|
"dataprovider": {
|
||||||
"name": "Data Provider",
|
"name": "Data Provider",
|
||||||
"info": "Pagination is only available for data stored in tables.",
|
"info": "Pagination is only available for data stored in tables.",
|
||||||
|
@ -3581,51 +3763,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"s3upload": {
|
|
||||||
"name": "S3 File Upload",
|
|
||||||
"info": "This component can't be used with S3 datasources that use custom endpoints.",
|
|
||||||
"icon": "UploadToCloud",
|
|
||||||
"styles": ["size"],
|
|
||||||
"editable": true,
|
|
||||||
"settings": [
|
|
||||||
{
|
|
||||||
"type": "field/attachment",
|
|
||||||
"label": "Field",
|
|
||||||
"key": "field"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"label": "Label",
|
|
||||||
"key": "label"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "dataSource/s3",
|
|
||||||
"label": "S3 Datasource",
|
|
||||||
"key": "datasourceId"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"label": "Bucket",
|
|
||||||
"key": "bucket"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"label": "File Name",
|
|
||||||
"key": "key"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "boolean",
|
|
||||||
"label": "Disabled",
|
|
||||||
"key": "disabled",
|
|
||||||
"defaultValue": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "validation/attachment",
|
|
||||||
"label": "Validation",
|
|
||||||
"key": "validation"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"markdownviewer": {
|
"markdownviewer": {
|
||||||
"name": "Markdown Viewer",
|
"name": "Markdown Viewer",
|
||||||
"icon": "TaskList",
|
"icon": "TaskList",
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let validation
|
export let validation
|
||||||
export let extensions
|
export let extensions
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -38,6 +39,13 @@
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -55,9 +63,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
on:change={e => {
|
on:change={handleChange}
|
||||||
fieldApi.setValue(e.detail)
|
|
||||||
}}
|
|
||||||
{processFiles}
|
{processFiles}
|
||||||
{handleFileTooLarge}
|
{handleFileTooLarge}
|
||||||
{extensions}
|
{extensions}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
export let size
|
export let size
|
||||||
export let validation
|
export let validation
|
||||||
export let defaultValue
|
export let defaultValue
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -25,6 +26,13 @@
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -44,8 +52,8 @@
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{size}
|
{size}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
|
||||||
{text}
|
{text}
|
||||||
|
on:change={handleChange}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -10,9 +10,17 @@
|
||||||
export let timeOnly = false
|
export let timeOnly = false
|
||||||
export let validation
|
export let validation
|
||||||
export let defaultValue
|
export let defaultValue
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -28,7 +36,7 @@
|
||||||
{#if fieldState}
|
{#if fieldState}
|
||||||
<CoreDatePicker
|
<CoreDatePicker
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
|
|
|
@ -219,10 +219,10 @@
|
||||||
})
|
})
|
||||||
return valid
|
return valid
|
||||||
},
|
},
|
||||||
clear: () => {
|
reset: () => {
|
||||||
// Clear the form by clearing each individual field
|
// Reset the form by resetting each individual field
|
||||||
fields.forEach(field => {
|
fields.forEach(field => {
|
||||||
get(field).fieldApi.clearValue()
|
get(field).fieldApi.reset()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
changeStep: ({ type, number }) => {
|
changeStep: ({ type, number }) => {
|
||||||
|
@ -241,6 +241,22 @@
|
||||||
currentStep.set(step)
|
currentStep.set(step)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setFieldValue: (fieldName, value) => {
|
||||||
|
const field = getField(fieldName)
|
||||||
|
if (!field) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const { fieldApi } = get(field)
|
||||||
|
fieldApi.setValue(value)
|
||||||
|
},
|
||||||
|
resetField: fieldName => {
|
||||||
|
const field = getField(fieldName)
|
||||||
|
if (!field) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const { fieldApi } = get(field)
|
||||||
|
fieldApi.reset()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates an API for a specific field
|
// Creates an API for a specific field
|
||||||
|
@ -268,11 +284,11 @@
|
||||||
return !error
|
return !error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clears the value of a certain field back to the initial value
|
// Clears the value of a certain field back to the default value
|
||||||
const clearValue = () => {
|
const reset = () => {
|
||||||
const fieldInfo = getField(field)
|
const fieldInfo = getField(field)
|
||||||
const { fieldState } = get(fieldInfo)
|
const { fieldState } = get(fieldInfo)
|
||||||
const newValue = initialValues[field] ?? fieldState.defaultValue
|
const newValue = fieldState.defaultValue
|
||||||
|
|
||||||
// Update field state
|
// Update field state
|
||||||
fieldInfo.update(state => {
|
fieldInfo.update(state => {
|
||||||
|
@ -329,7 +345,7 @@
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setValue,
|
setValue,
|
||||||
clearValue,
|
reset,
|
||||||
updateValidation,
|
updateValidation,
|
||||||
setDisabled,
|
setDisabled,
|
||||||
validate: () => {
|
validate: () => {
|
||||||
|
@ -354,11 +370,20 @@
|
||||||
// register their fields to step 1
|
// register their fields to step 1
|
||||||
setContext("form-step", writable(1))
|
setContext("form-step", writable(1))
|
||||||
|
|
||||||
|
const handleUpdateFieldValue = ({ type, field, value }) => {
|
||||||
|
if (type === "set") {
|
||||||
|
formApi.setFieldValue(field, value)
|
||||||
|
} else {
|
||||||
|
formApi.resetField(field)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Action context to pass to children
|
// Action context to pass to children
|
||||||
const actions = [
|
const actions = [
|
||||||
{ type: ActionTypes.ValidateForm, callback: formApi.validate },
|
{ type: ActionTypes.ValidateForm, callback: formApi.validate },
|
||||||
{ type: ActionTypes.ClearForm, callback: formApi.clear },
|
{ type: ActionTypes.ClearForm, callback: formApi.reset },
|
||||||
{ type: ActionTypes.ChangeFormStep, callback: formApi.changeStep },
|
{ type: ActionTypes.ChangeFormStep, callback: formApi.changeStep },
|
||||||
|
{ type: ActionTypes.UpdateFieldValue, callback: handleUpdateFieldValue },
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let defaultValue = ""
|
export let defaultValue = ""
|
||||||
|
export let onChange
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
const validation = [
|
const validation = [
|
||||||
|
@ -33,6 +34,14 @@
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
const value = parseValue(e.detail)
|
||||||
|
fieldApi.setValue(value)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -49,7 +58,7 @@
|
||||||
<div style="--height: {height};">
|
<div style="--height: {height};">
|
||||||
<CoreTextArea
|
<CoreTextArea
|
||||||
value={serialiseValue(fieldState.value)}
|
value={serialiseValue(fieldState.value)}
|
||||||
on:change={e => fieldApi.setValue(parseValue(e.detail))}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
export let validation
|
export let validation
|
||||||
export let defaultValue = ""
|
export let defaultValue = ""
|
||||||
export let format = "auto"
|
export let format = "auto"
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -44,6 +45,13 @@
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -61,7 +69,7 @@
|
||||||
{#if useRichText}
|
{#if useRichText}
|
||||||
<CoreRichTextField
|
<CoreRichTextField
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
|
@ -78,7 +86,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<CoreTextArea
|
<CoreTextArea
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
export let valueColumn
|
export let valueColumn
|
||||||
export let customOptions
|
export let customOptions
|
||||||
export let autocomplete = false
|
export let autocomplete = false
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -34,13 +35,18 @@
|
||||||
if (!values) {
|
if (!values) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(values)) {
|
if (Array.isArray(values)) {
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
return values.split(",").map(value => value.trim())
|
return values.split(",").map(value => value.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -62,7 +68,7 @@
|
||||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{options}
|
{options}
|
||||||
{autocomplete}
|
{autocomplete}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
export let customOptions
|
export let customOptions
|
||||||
export let autocomplete = false
|
export let autocomplete = false
|
||||||
export let direction = "vertical"
|
export let direction = "vertical"
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -30,6 +31,13 @@
|
||||||
valueColumn,
|
valueColumn,
|
||||||
customOptions
|
customOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -52,7 +60,7 @@
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
{options}
|
{options}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
getOptionLabel={flatOptions ? x => x : x => x.label}
|
getOptionLabel={flatOptions ? x => x : x => x.label}
|
||||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||||
{autocomplete}
|
{autocomplete}
|
||||||
|
@ -66,7 +74,7 @@
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
{options}
|
{options}
|
||||||
{direction}
|
{direction}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
getOptionLabel={flatOptions ? x => x : x => x.label}
|
getOptionLabel={flatOptions ? x => x : x => x.label}
|
||||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
export let validation
|
export let validation
|
||||||
export let autocomplete = false
|
export let autocomplete = false
|
||||||
export let defaultValue
|
export let defaultValue
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -62,11 +63,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const singleHandler = e => {
|
const singleHandler = e => {
|
||||||
fieldApi.setValue(e.detail == null ? [] : [e.detail])
|
handleChange(e.detail == null ? [] : [e.detail])
|
||||||
}
|
}
|
||||||
|
|
||||||
const multiHandler = e => {
|
const multiHandler = e => {
|
||||||
fieldApi.setValue(e.detail)
|
handleChange(e.detail)
|
||||||
}
|
}
|
||||||
|
|
||||||
const expand = values => {
|
const expand = values => {
|
||||||
|
@ -78,6 +79,13 @@
|
||||||
}
|
}
|
||||||
return values.split(",").map(value => value.trim())
|
return values.split(",").map(value => value.trim())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = value => {
|
||||||
|
fieldApi.setValue(value)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
export let label
|
export let label
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let validation
|
export let validation
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -88,6 +89,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
uploadStore.actions.registerFileUpload($component.id, upload)
|
uploadStore.actions.registerFileUpload($component.id, upload)
|
||||||
})
|
})
|
||||||
|
@ -113,9 +121,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
disabled={loading || fieldState.disabled}
|
disabled={loading || fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
on:change={e => {
|
on:change={handleChange}
|
||||||
fieldApi.setValue(e.detail)
|
|
||||||
}}
|
|
||||||
{processFiles}
|
{processFiles}
|
||||||
{handleFileTooLarge}
|
{handleFileTooLarge}
|
||||||
maximum={1}
|
maximum={1}
|
||||||
|
|
|
@ -10,9 +10,17 @@
|
||||||
export let validation
|
export let validation
|
||||||
export let defaultValue = ""
|
export let defaultValue = ""
|
||||||
export let align
|
export let align
|
||||||
|
export let onChange
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
|
||||||
|
const handleChange = e => {
|
||||||
|
fieldApi.setValue(e.detail)
|
||||||
|
if (onChange) {
|
||||||
|
onChange({ value: e.detail })
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field
|
<Field
|
||||||
|
@ -21,6 +29,7 @@
|
||||||
{disabled}
|
{disabled}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
|
{onChange}
|
||||||
type={type === "number" ? "number" : "string"}
|
type={type === "number" ? "number" : "string"}
|
||||||
bind:fieldState
|
bind:fieldState
|
||||||
bind:fieldApi
|
bind:fieldApi
|
||||||
|
@ -29,7 +38,7 @@
|
||||||
<CoreTextField
|
<CoreTextField
|
||||||
updateOnChange={false}
|
updateOnChange={false}
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={e => fieldApi.setValue(e.detail)}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
|
|
|
@ -21,6 +21,7 @@ export const UnsortableTypes = [
|
||||||
|
|
||||||
export const ActionTypes = {
|
export const ActionTypes = {
|
||||||
ValidateForm: "ValidateForm",
|
ValidateForm: "ValidateForm",
|
||||||
|
UpdateFieldValue: "UpdateFieldValue",
|
||||||
RefreshDatasource: "RefreshDatasource",
|
RefreshDatasource: "RefreshDatasource",
|
||||||
AddDataProviderQueryExtension: "AddDataProviderQueryExtension",
|
AddDataProviderQueryExtension: "AddDataProviderQueryExtension",
|
||||||
RemoveDataProviderQueryExtension: "RemoveDataProviderQueryExtension",
|
RemoveDataProviderQueryExtension: "RemoveDataProviderQueryExtension",
|
||||||
|
|
|
@ -162,6 +162,19 @@ const executeActionHandler = async (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateFieldValueHandler = async (action, context) => {
|
||||||
|
return await executeActionHandler(
|
||||||
|
context,
|
||||||
|
action.parameters.componentId,
|
||||||
|
ActionTypes.UpdateFieldValue,
|
||||||
|
{
|
||||||
|
type: action.parameters.type,
|
||||||
|
field: action.parameters.field,
|
||||||
|
value: action.parameters.value,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const validateFormHandler = async (action, context) => {
|
const validateFormHandler = async (action, context) => {
|
||||||
return await executeActionHandler(
|
return await executeActionHandler(
|
||||||
context,
|
context,
|
||||||
|
@ -295,6 +308,7 @@ const handlerMap = {
|
||||||
["Execute Query"]: queryExecutionHandler,
|
["Execute Query"]: queryExecutionHandler,
|
||||||
["Trigger Automation"]: triggerAutomationHandler,
|
["Trigger Automation"]: triggerAutomationHandler,
|
||||||
["Validate Form"]: validateFormHandler,
|
["Validate Form"]: validateFormHandler,
|
||||||
|
["Update Field Value"]: updateFieldValueHandler,
|
||||||
["Refresh Data Provider"]: refreshDataProviderHandler,
|
["Refresh Data Provider"]: refreshDataProviderHandler,
|
||||||
["Log Out"]: logoutHandler,
|
["Log Out"]: logoutHandler,
|
||||||
["Clear Form"]: clearFormHandler,
|
["Clear Form"]: clearFormHandler,
|
||||||
|
|
Loading…
Reference in New Issue