1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

F OpenNebula/one#5469: Add support to object lists inputs (#1382)

This commit is contained in:
Sergio Betanzos 2021-07-27 11:52:58 +02:00 committed by GitHub
parent 15823008b3
commit 7daa2695a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -27,7 +27,7 @@ export const FORM_FIELDS = inputs =>
max_value: max,
options
}) => {
const optionsValue = options?.join(',') ?? `${min}..${max}`
const optionsValue = options ?? `${min}..${max}`
return {
name,

View File

@ -21,13 +21,16 @@ const requiredSchema = (mandatory, name, schema) =>
? schema.required(`${name} field is required`)
: schema.notRequired().nullable()
const getRange = (options) =>
options.split('..').map(option => parseFloat(option))
const getRange = options => options?.split('..').map(option => parseFloat(option))
const getValuesFromArray = (options, separator = ';') => options?.split(separator)
const getOptionsFromList = (options, separator = ',') =>
options?.split(separator).map(value => ({ text: value, value }))
const getOptionsFromList = options => options
?.map(option => typeof option === 'string'
? ({ text: option, value: option })
: option
)
?.filter(({ text, value } = {}) => text && value)
/**
* @typedef {(