diff --git a/packages/bbui/src/Form/Core/Multiselect.svelte b/packages/bbui/src/Form/Core/Multiselect.svelte index 2243570cd5..7c1900fe2e 100644 --- a/packages/bbui/src/Form/Core/Multiselect.svelte +++ b/packages/bbui/src/Form/Core/Multiselect.svelte @@ -9,6 +9,8 @@ export let options = [] export let getOptionLabel = option => option export let getOptionValue = option => option + export let getOptionsIcon = () => null + export let getOptionsIconToolip = () => null export let readonly = false export let autocomplete = false export let sort = false @@ -80,6 +82,8 @@ option export let getOptionValue = option => option export let getOptionIcon = () => null + export let getOptionIconTooltip = () => null export let useOptionIconImage = false export let getOptionColour = () => null export let getOptionSubtitle = () => null @@ -202,7 +203,7 @@ > {#if getOptionIcon(option, idx)} - {#if useOptionIconImage} + {#if useoptioniconimage} icon + import { Select } from "@budibase/bbui" + import { + getDatasourceForProvider, + getSchemaForDatasource, + } from "dataBinding" + import { selectedScreen } from "stores/builder" + import { createEventDispatcher } from "svelte" + + export let componentInstance = {} + export let value = "" + export let placeholder + + const dispatch = createEventDispatcher() + $: datasource = getDatasourceForProvider($selectedScreen, componentInstance) + $: schema = getSchemaForDatasource($selectedScreen, datasource).schema + $: options = Object.keys(schema || {}).filter(key => { + return ( + schema[key].type !== "json" && + schema[key].type !== "array" && + schema[key].type !== "attachment" && + schema[key].type !== "barcodeqr" && + schema[key].type !== "link" && + schema[key].type !== "bb_reference" + ); + }); + $: boundValue = getValidValue(value, options) + + const getValidValue = (value, options) => { + // Reset value if there aren't any options + if (!Array.isArray(options)) { + return null + } + + // Reset value if the value isn't found in the options + if (options.indexOf(value) === -1) { + return null + } + + return value + } + + const onChange = value => { + boundValue = getValidValue(value.detail, options) + dispatch("change", boundValue) + } + + $: { + console.log(options, schema); + } + + +