Allow switch widgets to display "key: value" instead of the default "key"

This commit is contained in:
cyberic99 2018-01-04 11:09:35 +01:00
parent 532ba56635
commit f36664718d

View file

@ -27,6 +27,7 @@ module.exports = class Switch extends _widgets_base {
_switch:'switch',
horizontal:false,
show_values:false,
values:{"Value 1":1,"Value 2":2},
value:'',
@ -52,7 +53,8 @@ module.exports = class Switch extends _widgets_base {
for (var k in this.getProp('values')) {
this.values.push(this.getProp('values')[k])
$(`<div class="value">${iconify(parseFloat(k) != k ? k : this.getProp("values")[k])}</div>`).data({value:this.getProp('values')[k]}).appendTo(this.widget)
var the_val = (this.getProp('show_values')) ? ': ' + this.getProp('values')[k] : ''
$(`<div class="value">${iconify(parseFloat(k) != k ? k : this.getProp("values")[k]) + the_val}</div>`).data({value:this.getProp('values')[k]}).appendTo(this.widget)
}
this.value = undefined