From 94956c57eeacd97ac9cc33b821a6bc2da7a674ab Mon Sep 17 00:00:00 2001 From: axolotle Date: Tue, 19 Mar 2024 01:27:09 +0100 Subject: [PATCH] fix: adapt `choices` data structure --- app/src/helpers/yunohostArguments.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/helpers/yunohostArguments.js b/app/src/helpers/yunohostArguments.js index 9cd733ba..c6630ebe 100644 --- a/app/src/helpers/yunohostArguments.js +++ b/app/src/helpers/yunohostArguments.js @@ -221,7 +221,7 @@ export function formatYunoHostArgument(arg) { label: arg.placeholder, }) } - if (typeof value === 'string') { + if (typeof value === 'string' && value) { value = value.split(',') } else if (!value) { value = [] @@ -296,8 +296,15 @@ export function formatYunoHostArgument(arg) { prop = prop.split(':') const propName = prop[0] const argName = prop.slice(-1)[0] + if (argName in arg) { - field.props.props[propName] = arg[argName] + if (propName === 'choices') { + field.props.props[propName] = Object.entries(arg[argName]).map( + ([value, text]) => ({ value, text }), + ) + } else { + field.props.props[propName] = arg[argName] + } } }