fix: adapt choices data structure

This commit is contained in:
axolotle 2024-03-19 01:27:09 +01:00
parent 4b33e67514
commit 94956c57ee

View file

@ -221,7 +221,7 @@ export function formatYunoHostArgument(arg) {
label: arg.placeholder, label: arg.placeholder,
}) })
} }
if (typeof value === 'string') { if (typeof value === 'string' && value) {
value = value.split(',') value = value.split(',')
} else if (!value) { } else if (!value) {
value = [] value = []
@ -296,10 +296,17 @@ export function formatYunoHostArgument(arg) {
prop = prop.split(':') prop = prop.split(':')
const propName = prop[0] const propName = prop[0]
const argName = prop.slice(-1)[0] const argName = prop.slice(-1)[0]
if (argName in arg) { if (argName in arg) {
if (propName === 'choices') {
field.props.props[propName] = Object.entries(arg[argName]).map(
([value, text]) => ({ value, text }),
)
} else {
field.props.props[propName] = arg[argName] field.props.props[propName] = arg[argName]
} }
} }
}
// Required (no need for checkbox its value can't be null) // Required (no need for checkbox its value can't be null)
if ( if (