args: remove current_value and remove the need for int parsing for option prop min + max

This commit is contained in:
axolotle 2023-04-24 18:06:32 +02:00
parent 06bb22f45d
commit 60934cf772

View file

@ -120,12 +120,7 @@ function addEvaluationGetter(prop, obj, expr, ctx, nested) {
* @return {Object} an formated argument containing formItem props, validation and base value. * @return {Object} an formated argument containing formItem props, validation and base value.
*/ */
export function formatYunoHostArgument(arg) { export function formatYunoHostArgument(arg) {
let value = let value = arg.value !== undefined ? arg.value : null
arg.value !== undefined
? arg.value
: arg.current_value !== undefined
? arg.current_value
: null
const validation = {} const validation = {}
const error = { message: null } const error = { message: null }
arg.ask = formatI18nField(arg.ask) arg.ask = formatI18nField(arg.ask)
@ -168,11 +163,11 @@ export function formatYunoHostArgument(arg) {
name: 'InputItem', name: 'InputItem',
props: defaultProps.concat(['type', 'min', 'max', 'step']), props: defaultProps.concat(['type', 'min', 'max', 'step']),
callback: function () { callback: function () {
if (!isNaN(parseInt(arg.min))) { if (arg.min !== undefined) {
validation.minValue = validators.minValue(parseInt(arg.min)) validation.minValue = validators.minValue(arg.min)
} }
if (!isNaN(parseInt(arg.max))) { if (arg.max !== undefined) {
validation.maxValue = validators.maxValue(parseInt(arg.max)) validation.maxValue = validators.maxValue(arg.max)
} }
validation.numValue = validators.integer validation.numValue = validators.integer
}, },
@ -277,11 +272,12 @@ export function formatYunoHostArgument(arg) {
] ]
// Default type management if no one is filled // Default type management if no one is filled
if (arg.choices && arg.choices.length) {
arg.type = 'select'
}
if (arg.type === undefined) { if (arg.type === undefined) {
arg.type = 'string' if (arg.choices && arg.choices.length) {
arg.type = 'select'
} else {
arg.type = 'string'
}
} }
// Search the component bind to the type // Search the component bind to the type
@ -328,9 +324,6 @@ export function formatYunoHostArgument(arg) {
} }
// Default value if still `null` // Default value if still `null`
if (value === null && arg.current_value) {
value = arg.current_value
}
if (value === null && arg.default) { if (value === null && arg.default) {
value = arg.default value = arg.default
} }