From 7ef5d8a9b8a10ad3f3a5cd029a00ef6395f3a152 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 16 Sep 2020 13:55:28 +0100 Subject: [PATCH] Update builder to support new block definitions with JSON schema --- .../ParamInputs/ModelSelector.svelte | 11 +--- .../ParamInputs/RecordSelector.svelte | 36 ++++++----- .../SetupPanel/WorkflowBlockSetup.svelte | 60 +++++++++---------- .../WorkflowBuilder/flowchart/FlowItem.svelte | 20 ++++++- 4 files changed, 63 insertions(+), 64 deletions(-) diff --git a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte index 2ea4807d3f..e95306306e 100644 --- a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte @@ -2,19 +2,10 @@ import { backendUiStore } from "builderStore" export let value - $: modelId = value ? value._id : "" - - function onChange(e) { - value = $backendUiStore.models.find(model => model._id === e.target.value) - }
- {#each $backendUiStore.models as model} diff --git a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/RecordSelector.svelte b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/RecordSelector.svelte index 64db828407..809d5847b5 100644 --- a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/RecordSelector.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/RecordSelector.svelte @@ -3,31 +3,24 @@ import { Input, Label } from "@budibase/bbui" export let value - $: modelId = value && value.model ? value.model._id : "" - $: schemaFields = Object.keys(value && value.model ? value.model.schema : {}) - - function onChangeModel(e) { - value.model = $backendUiStore.models.find( - model => model._id === e.target.value - ) - } + $: value = value || {} + $: model = $backendUiStore.models.find(model => model._id === value?.modelId) + $: schemaFields = Object.keys(model?.schema ?? {}) function setParsedValue(evt, field) { - const fieldSchema = value.model.schema[field] - if (fieldSchema.type === "number") { - value[field] = parseInt(evt.target.value) - return + const fieldSchema = model?.schema[field] + if (fieldSchema) { + if (fieldSchema.type === "number") { + value[field] = parseInt(evt.target.value) + return + } } value[field] = evt.target.value }
- {#each $backendUiStore.models as model} @@ -37,9 +30,8 @@ {#if schemaFields.length}
- {#each schemaFields as field} -
+
{/if} + + diff --git a/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte b/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte index 5e889a32d0..79057fd845 100644 --- a/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/WorkflowBlockSetup.svelte @@ -1,41 +1,36 @@
-
{block.name}
- {#each params as [parameter, type]} -
- - {#if Array.isArray(type)} - - {#each type as option} + {#each value.enum as option} {/each} - {:else if type === 'accessLevel'} - - {:else if type === 'password'} - - {:else if type === 'number'} - - {:else if type === 'longText'} -