From 224aef347871001587fea57348ad59424f4a9f9a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 14 Sep 2020 11:51:52 +0100 Subject: [PATCH] Fix workflow select components which use objects as options and take initial state from API --- .../ParamInputs/ModelSelector.svelte | 13 ++++++++++--- .../ParamInputs/RecordSelector.svelte | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte index b600e87dc6..ac09a328c1 100644 --- a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/ModelSelector.svelte @@ -2,12 +2,19 @@ import { backendUiStore } from "builderStore" export let value - let modelId = value ? value._id : "" - $: value = $backendUiStore.models.find(x => x._id === modelId) + $: modelId = value ? value._id : "" + + function onChange(e) { + value = $backendUiStore.models.find(x => x._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 436252be39..0df942c035 100644 --- a/packages/builder/src/components/workflow/SetupPanel/ParamInputs/RecordSelector.svelte +++ b/packages/builder/src/components/workflow/SetupPanel/ParamInputs/RecordSelector.svelte @@ -3,8 +3,12 @@ import { Input, Label } from "@budibase/bbui" export let value - let modelId = value && value.model ? value.model._id : "" - $: value.model = $backendUiStore.models.find(x => x._id === modelId) + $: modelId = value && value.model ? value.model._id : "" + $: schemaFields = Object.keys(value && value.model ? value.model.schema : {}) + + function onChangeModel(e) { + value.model = $backendUiStore.models.find(x => x._id === e.target.value) + } function setParsedValue(evt, field) { const fieldSchema = value.model.schema[field] @@ -17,7 +21,11 @@
- {#each $backendUiStore.models as model} @@ -25,10 +33,10 @@
-{#if value.model} +{#if schemaFields.length}
- {#each Object.keys(value.model.schema) as field} + {#each schemaFields as field}