Normalize array/dict options for values on EnumSwitch

This commit is contained in:
Fabio Manganiello 2023-01-09 01:01:35 +01:00
parent e9c84ff5d4
commit 27b23b7fae
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -32,7 +32,7 @@
:value="value_id"
:selected="value_id == value.value"
:key="value_id"
v-for="text, value_id in value.values"
v-for="text, value_id in displayValues"
v-text="text"
/>
</select>
@ -60,6 +60,16 @@ export default {
computed: {
hasValues() {
return !!Object.values(this?.value?.values || {}).length
},
displayValues() {
if (this.value?.values instanceof Array)
return this.value.values.reduce((obj, value) => {
obj[value] = value
return obj
}, {})
return this.value?.values || {}
}
},