This commit is contained in:
Adria Navarro 2024-04-25 13:58:56 +02:00
parent 5c93ee3e06
commit 5f0a7c5aac
1 changed files with 11 additions and 14 deletions

View File

@ -51,7 +51,6 @@
? flatten(fieldState?.value) ?? []
: flatten(fieldState?.value)?.[0]
$: component = multiselect ? CoreMultiselect : CoreSelect
$: expandedDefaultValue = expand(defaultValue)
$: primaryDisplay = primaryDisplay || tableDefinition?.primaryDisplay
let optionsObj
@ -115,7 +114,6 @@
const forceFetchRows = async () => {
fieldApi?.setValue([])
selectedValue = []
debouncedFetchRows(searchTerm, primaryDisplay, defaultValue)
}
const fetchRows = async (searchTerm, primaryDisplay, defaultVal) => {
@ -157,6 +155,7 @@
if (!values) {
return []
}
if (!Array.isArray(values)) {
values = [values]
}
@ -170,22 +169,20 @@
return row?.[primaryDisplay] || "-"
}
const expand = values => {
if (!values) {
return []
}
if (Array.isArray(values)) {
return values
}
return values.split(",").map(value => value.trim())
}
const handleChange = e => {
let value = e.detail
if (!multiselect && type !== FieldType.BB_REFERENCE_SINGLE) {
if (!multiselect) {
value = value == null ? [] : [value]
}
if (
type === FieldType.BB_REFERENCE_SINGLE &&
value &&
Array.isArray(value)
) {
value = value[0]
}
const changed = fieldApi.setValue(value)
if (onChange && changed) {
onChange({
@ -207,7 +204,7 @@
{disabled}
{readonly}
{validation}
defaultValue={expandedDefaultValue}
{defaultValue}
{type}
{span}
{helpText}