From e4900e597becffde042ca8f6c36b9817c1b0c84e Mon Sep 17 00:00:00 2001 From: ezsh <ezsh.junk@gmail.com> Date: Tue, 21 May 2019 20:37:43 +0200 Subject: [PATCH] Show user strings as values in RA Use user strings instead of numeric values when displaying lists in RA options page --- src/js/rulesAssistantOptions.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/js/rulesAssistantOptions.js b/src/js/rulesAssistantOptions.js index b67cf97c392..87d51f80f33 100644 --- a/src/js/rulesAssistantOptions.js +++ b/src/js/rulesAssistantOptions.js @@ -180,7 +180,7 @@ window.rulesAssistantOptions = (function() { * @param {Array} [data] * @param {boolean} [allowNullValue] * @param {boolean} [editor] - * @param {...any} args + * @param {...any} args */ constructor(prefix, data = [], allowNullValue = true, editor = false, ...args) { super(`${prefix}: `, editor, ...args); @@ -274,6 +274,14 @@ window.rulesAssistantOptions = (function() { class List extends EditorWithShortcuts { constructor(prefix, data = [], allowNullValue = true, textinput = false) { super(prefix, data, allowNullValue, textinput); + this.values = new Map(); + data.forEach(d => { + if (Array.isArray(d) && d.length > 1) { + this.values.set(d[1], d[0]); + } else { + this.values.set(d, d); + } + }); } createEditor() { @@ -289,6 +297,14 @@ window.rulesAssistantOptions = (function() { }; return res; } + + setValue(what) { + if (this.values.has(what)) { + super.setValue(this.values.get(what)); + } else { + super.setValue(what); + } + } } class NumberRange extends EditorWithShortcuts { -- GitLab