From 39b630d36ec13786f7660b0a4bcda92417955351 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 15 Sep 2020 11:23:02 -0600 Subject: [PATCH] Etemplate: Fix some selectAccount bugs when multiple=true --- api/js/etemplate/et2_widget_link.js | 4 +++- api/js/etemplate/et2_widget_link.ts | 5 ++++- api/js/etemplate/et2_widget_selectAccount.js | 6 +++--- api/js/etemplate/et2_widget_selectAccount.ts | 8 ++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/js/etemplate/et2_widget_link.js b/api/js/etemplate/et2_widget_link.js index 3828f899e0..a8add15f53 100644 --- a/api/js/etemplate/et2_widget_link.js +++ b/api/js/etemplate/et2_widget_link.js @@ -619,7 +619,9 @@ var et2_link_entry = /** @class */ (function (_super) { select: function (event, item) { event.data = self; // Correct changed value from server - item.item.value = item.item.value.trim(); + if (item.item.value) { + item.item.value = ("" + item.item.value).trim(); + } self.select(event, item); return false; }, diff --git a/api/js/etemplate/et2_widget_link.ts b/api/js/etemplate/et2_widget_link.ts index 80df9adb15..1c9fd959b0 100644 --- a/api/js/etemplate/et2_widget_link.ts +++ b/api/js/etemplate/et2_widget_link.ts @@ -804,7 +804,10 @@ export class et2_link_entry extends et2_inputWidget { event.data = self; // Correct changed value from server - item.item.value = item.item.value.trim(); + if(item.item.value) + { + item.item.value = (""+item.item.value).trim(); + } self.select(event,item); return false; }, diff --git a/api/js/etemplate/et2_widget_selectAccount.js b/api/js/etemplate/et2_widget_selectAccount.js index 3971e09324..8d537335b2 100644 --- a/api/js/etemplate/et2_widget_selectAccount.js +++ b/api/js/etemplate/et2_widget_selectAccount.js @@ -326,10 +326,10 @@ var et2_selectAccount = /** @class */ (function (_super) { // Add to list ids.push(id); // Make sure option is there - if (!widget.options.multiple && jQuery('input[id$="_opt_' + id + '"]', widget.multiOptions).length == 0) { + if (widget.options.multiple && jQuery('input[id$="_opt_' + id + '"]', widget.multiOptions).length == 0) { widget._appendMultiOption(id, jQuery('label', this).text()); } - else if (widget.options.multiple && jQuery('option[value="' + id + '"]', widget.node).length == 0) { + else if (!widget.options.multiple && jQuery('option[value="' + id + '"]', widget.node).length == 0) { widget._appendOptionElement(id, jQuery('label', this).text()); } }); @@ -395,7 +395,7 @@ var et2_selectAccount = /** @class */ (function (_super) { self._appendOptionElement(selected.item.value, selected.item.label); } self.set_value(selected.item.value); - if (self.dialog) { + if (self.dialog && self.dialog.div) { self.dialog.div.dialog("close"); } // Fire change event diff --git a/api/js/etemplate/et2_widget_selectAccount.ts b/api/js/etemplate/et2_widget_selectAccount.ts index f57d6556ea..13ce0c0434 100644 --- a/api/js/etemplate/et2_widget_selectAccount.ts +++ b/api/js/etemplate/et2_widget_selectAccount.ts @@ -405,11 +405,11 @@ export class et2_selectAccount extends et2_selectbox ids.push(id); // Make sure option is there - if(!widget.options.multiple && jQuery('input[id$="_opt_'+id+'"]',widget.multiOptions).length == 0) + if(widget.options.multiple && jQuery('input[id$="_opt_'+id+'"]',widget.multiOptions).length == 0) { widget._appendMultiOption(id,jQuery('label',this).text()); } - else if (widget.options.multiple && jQuery('option[value="'+id+'"]',widget.node).length == 0) + else if (!widget.options.multiple && jQuery('option[value="'+id+'"]',widget.node).length == 0) { widget._appendOptionElement(id,jQuery('label',this).text()); } @@ -480,7 +480,7 @@ export class et2_selectAccount extends et2_selectbox return true; }, 'select'( e, selected) - { + { // Make sure option is there var already_there = false; var last_key = null; @@ -495,7 +495,7 @@ export class et2_selectAccount extends et2_selectbox self._appendOptionElement(selected.item.value, selected.item.label); } self.set_value(selected.item.value); - if(self.dialog) + if(self.dialog && self.dialog.div) { self.dialog.div.dialog("close"); }