From 71a67cdb642f432efdd1bd5da084d6bf4950ae5c Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 23 Mar 2020 13:19:58 +0100 Subject: [PATCH] menu: value display fix --- src/client/widgets/basics/menu.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/client/widgets/basics/menu.js b/src/client/widgets/basics/menu.js index fe88a688..9791c96c 100644 --- a/src/client/widgets/basics/menu.js +++ b/src/client/widgets/basics/menu.js @@ -61,7 +61,7 @@ class Menu extends Widget { this.opened = false this.values = [] - this.stringValues = [] + this.keys = [] this.selected = -1 this.value = undefined @@ -201,6 +201,8 @@ class Menu extends Widget { if (this.opened) this.widget.removeChild(this.menu) this.menu.innerHTML = '' + this.keys = !Array.isArray(values) ? Object.keys(values) : values + this.values = !Array.isArray(values) ? Object.values(values) : values nval = Array.isArray(values) ? values.length : Object.keys(values).length weights = Array.isArray(weights) ? weights.slice(0, nval) : Array(nval).fill(1) @@ -211,12 +213,7 @@ class Menu extends Widget { for (let k in values) { let angle = Math.min(360 * weights[i] / totalWeight, 120), skew = 90 - angle - this.values.push(values[k]) - if (typeof values[k] == 'object') { - this.stringValues.push(JSON.stringify(values[k])) - } else { - this.stringValues.push(0) - } + this.menu.appendChild(html`
${raw(iconify(parseFloat(k) != k ? k : values[k]))}
@@ -278,7 +275,7 @@ class Menu extends Widget { DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')}) if (i > -1) DOM.get(this.menu, '.item')[i].classList.add('on') - this.text.textContent = this.stringValues[i] || this.value + this.text.textContent = this.keys[i] if (options.send) this.sendValue() if (options.sync) this.changed(options)