forked from platypush/platypush
Normalize array/dict options for values on EnumSwitch
This commit is contained in:
parent
e9c84ff5d4
commit
27b23b7fae
1 changed files with 11 additions and 1 deletions
|
@ -32,7 +32,7 @@
|
||||||
:value="value_id"
|
:value="value_id"
|
||||||
:selected="value_id == value.value"
|
:selected="value_id == value.value"
|
||||||
:key="value_id"
|
:key="value_id"
|
||||||
v-for="text, value_id in value.values"
|
v-for="text, value_id in displayValues"
|
||||||
v-text="text"
|
v-text="text"
|
||||||
/>
|
/>
|
||||||
</select>
|
</select>
|
||||||
|
@ -60,6 +60,16 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
hasValues() {
|
hasValues() {
|
||||||
return !!Object.values(this?.value?.values || {}).length
|
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 || {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue