feat: add preselect first config for app selects

This commit is contained in:
Ruben Fiszel
2023-06-21 13:39:08 +02:00
parent 759f4da2be
commit 11c6ff7481
2 changed files with 17 additions and 2 deletions

View File

@@ -77,7 +77,7 @@
let rawValue
if (resolvedConfig.defaultValue !== undefined) {
rawValue = resolvedConfig.defaultValue
} else if (listItems.length > 0) {
} else if (listItems.length > 0 && resolvedConfig?.preselectFirst) {
rawValue = resolvedConfig.items[0].value
}
if (rawValue !== undefined) {
@@ -117,6 +117,14 @@
}
}
function onClear() {
value = undefined
outputs?.result.set(undefined)
if (iterContext && listInputs) {
listInputs(id, undefined)
}
}
$: css = concatCustomCss($app.css?.selectcomponent, customCss)
function handleFilter(e) {
@@ -168,7 +176,7 @@
--border-color="#999"
bind:filterText
on:filter={handleFilter}
on:clear={onChange}
on:clear={onClear}
on:change={onChange}
items={listItems}
listAutoWidth={resolvedConfig.fullWidth}

View File

@@ -1374,6 +1374,13 @@ Hello \${ctx.username}
value: undefined,
fieldType: 'object'
},
preselectFirst: {
type: 'static',
value: true,
fieldType: 'boolean',
onlyStatic: true,
tooltip: 'Preselect first item in the options if no default value is set'
},
fullWidth: {
type: 'static',
fieldType: 'boolean',