Fix workflow select components which use objects as options and take initial state from API
This commit is contained in:
parent
9d2f7ed874
commit
55f418bc95
|
@ -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)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="block-field">
|
||||
<select class="budibase__input" bind:value={modelId}>
|
||||
<select
|
||||
class="budibase__input"
|
||||
value={modelId}
|
||||
on:blur={onChange}
|
||||
on:change={onChange}>
|
||||
<option value="">Choose an option</option>
|
||||
{#each $backendUiStore.models as model}
|
||||
<option value={model._id}>{model.name}</option>
|
||||
|
|
|
@ -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 @@
|
|||
</script>
|
||||
|
||||
<div class="block-field">
|
||||
<select class="budibase__input" bind:value={modelId}>
|
||||
<select
|
||||
class="budibase__input"
|
||||
value={modelId}
|
||||
on:blur={onChangeModel}
|
||||
on:change={onChangeModel}>
|
||||
<option value="">Choose an option</option>
|
||||
{#each $backendUiStore.models as model}
|
||||
<option value={model._id}>{model.name}</option>
|
||||
|
@ -25,10 +33,10 @@
|
|||
</select>
|
||||
</div>
|
||||
|
||||
{#if value.model}
|
||||
{#if schemaFields.length}
|
||||
<div class="bb-margin-xl block-field">
|
||||
<Label small forAttr={'fields'}>Fields</Label>
|
||||
{#each Object.keys(value.model.schema) as field}
|
||||
{#each schemaFields as field}
|
||||
<div class="bb-margin-xl">
|
||||
<Input
|
||||
thin
|
||||
|
|
Loading…
Reference in New Issue