Values or defaults passed to the picker are parsed to ensure only valid options are marked/added to the component.
This commit is contained in:
parent
51ce51078e
commit
8c62ea9833
|
@ -15,12 +15,28 @@
|
||||||
export let sort = false
|
export let sort = false
|
||||||
export let autoWidth = false
|
export let autoWidth = false
|
||||||
|
|
||||||
|
$: streamed = Array.isArray(value)
|
||||||
|
? value.reduce((acc, ele) => {
|
||||||
|
if (typeof ele === "string") {
|
||||||
|
let temp = ele.trim()
|
||||||
|
if (!temp) {
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let processedOpt = ele.toString()
|
||||||
|
if (options.indexOf(processedOpt) > -1) {
|
||||||
|
acc.push(ele.toString())
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, [])
|
||||||
|
: []
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
$: selectedLookupMap = getSelectedLookupMap(value)
|
$: selectedLookupMap = getSelectedLookupMap(streamed)
|
||||||
$: optionLookupMap = getOptionLookupMap(options)
|
$: optionLookupMap = getOptionLookupMap(options)
|
||||||
$: fieldText = getFieldText(value, optionLookupMap, placeholder)
|
$: fieldText = getFieldText(streamed, optionLookupMap, placeholder)
|
||||||
$: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true
|
$: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true
|
||||||
$: toggleOption = makeToggleOption(selectedLookupMap, value)
|
$: toggleOption = makeToggleOption(selectedLookupMap, streamed)
|
||||||
|
|
||||||
const getFieldText = (value, map, placeholder) => {
|
const getFieldText = (value, map, placeholder) => {
|
||||||
if (Array.isArray(value) && value.length > 0) {
|
if (Array.isArray(value) && value.length > 0) {
|
||||||
|
|
|
@ -247,7 +247,7 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
hoverTarget = {
|
hoverTarget = {
|
||||||
title: binding.display?.name || binding.fieldSchema.name,
|
title: binding.display?.name || binding.fieldSchema?.name,
|
||||||
description: binding.description,
|
description: binding.description,
|
||||||
}
|
}
|
||||||
popover.show()
|
popover.show()
|
||||||
|
|
Loading…
Reference in New Issue