From 650d76bd5cb0b25bc0daf365e98a5c7c33f0b435 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 7 Feb 2022 13:49:50 -0700 Subject: [PATCH] Common cleaning of r/o select value --- .../etemplate/Et2Select/Et2SelectReadonly.ts | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2SelectReadonly.ts b/api/js/etemplate/Et2Select/Et2SelectReadonly.ts index d06c8b0e57..38350a20d8 100644 --- a/api/js/etemplate/Et2Select/Et2SelectReadonly.ts +++ b/api/js/etemplate/Et2Select/Et2SelectReadonly.ts @@ -89,13 +89,30 @@ li { set_value(value) { - if(typeof value == "string") - { - value = value.split(","); - } this.value = value; } + set value(new_value) + { + // Split anything that is still a CSV + if(typeof new_value == "string" && new_value.indexOf(",") > 0) + { + new_value = new_value.split(","); + } + // Wrap any single value into an array for consistent rendering + if(typeof new_value == "string" || typeof new_value == "number") + { + new_value = ["" + new_value]; + } + + super.value = new_value; + } + + get value() + { + return super.value; + } + /** * Set the select options * @@ -183,14 +200,6 @@ export class Et2SelectAccountReadonly extends Et2SelectReadonly return; } - if(typeof new_value == "string" && new_value.indexOf(",") > 0) - { - new_value = new_value.split(","); - } - if(typeof new_value == "string" || typeof new_value == "number") - { - new_value = ["" + new_value]; - } for(let id of new_value) { let account_name = null;