Unify selectedValue func

This commit is contained in:
Adria Navarro 2023-09-22 10:14:17 +02:00
parent 013f00e90d
commit 06d881aa7f
1 changed files with 4 additions and 3 deletions

View File

@ -39,8 +39,9 @@
$: options = $fetch.rows $: options = $fetch.rows
$: tableDefinition = $fetch.definition $: tableDefinition = $fetch.definition
$: singleValue = flatten(fieldState?.value)?.[0] $: selectedValue = multiselect
$: multiValue = flatten(fieldState?.value) ?? [] ? flatten(fieldState?.value) ?? []
: flatten(fieldState?.value)?.[0]
$: component = multiselect ? CoreMultiselect : CoreSelect $: component = multiselect ? CoreMultiselect : CoreSelect
$: expandedDefaultValue = expand(defaultValue) $: expandedDefaultValue = expand(defaultValue)
$: primaryDisplay = tableDefinition?.primaryDisplay || "_id" $: primaryDisplay = tableDefinition?.primaryDisplay || "_id"
@ -121,7 +122,7 @@
this={component} this={component}
{options} {options}
{autocomplete} {autocomplete}
value={multiselect ? multiValue : singleValue} value={selectedValue}
on:change={multiselect ? multiHandler : singleHandler} on:change={multiselect ? multiHandler : singleHandler}
id={fieldState.fieldId} id={fieldState.fieldId}
disabled={fieldState.disabled} disabled={fieldState.disabled}