From 3cf6211c9546ea95eb374af626f5327e682c0093 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 9 Jul 2015 19:12:13 +0000 Subject: [PATCH] Little fixes to avoid some errors: - Make sure widget is still there before trying to set its select options - Make sure expand button is there before trying to remove it - Only try to set select options if header widget is a select box - Pass appropriate options into getEntry() so it can return null on not existing keys --- etemplate/js/et2_core_valueWidget.js | 2 +- etemplate/js/et2_extension_nextmatch.js | 7 +++++-- etemplate/js/et2_widget_selectbox.js | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_core_valueWidget.js b/etemplate/js/et2_core_valueWidget.js index 3645b069a8..ae0a0fab1b 100644 --- a/etemplate/js/et2_core_valueWidget.js +++ b/etemplate/js/et2_core_valueWidget.js @@ -56,7 +56,7 @@ var et2_valueWidget = et2_baseWidget.extend( // Set the value for this element var contentMgr = this.getArrayMgr("content"); if (contentMgr != null) { - var val = contentMgr.getEntry(this.id); + var val = contentMgr.getEntry(this.id,false,true); if (val !== null) { _attrs["value"] = val; diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 06cff79ff8..babc3ff15c 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -3386,7 +3386,10 @@ var et2_nextmatch_customfilter = et2_nextmatch_filterheader.extend( this.real_node._type = _attrs.widget_type; et2_selectbox.find_select_options(this.real_node, select_options, _attrs); this.real_node._type = correct_type; - this.real_node.set_select_options(select_options); + if(typeof this.real_node.set_select_options === 'function') + { + this.real_node.set_select_options(select_options); + } }, // Just pass the real DOM node through, in case anybody asks @@ -3396,7 +3399,7 @@ var et2_nextmatch_customfilter = et2_nextmatch_filterheader.extend( // Also need to pass through real children getChildren: function() { - return this.real_node.getChildren(); + return this.real_node.getChildren() || []; }, setNextmatch: function(_nextmatch) { diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index 49db06432d..db8d6f3797 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -553,7 +553,7 @@ var et2_selectbox = et2_inputWidget.extend( this.options.expand_multiple_rows = _rows; var surroundings = this.getSurroundings(); - if(_rows <= 1 ) + if(_rows <= 1 && this.expand_button ) { // Remove surroundings.removeDOMNode(this.expand_button.get(0)); @@ -1099,7 +1099,11 @@ jQuery.extend(et2_selectbox, attrs.select_options = egw.window.et2_selectbox.type_cache[this.cache_id]; egw.window.setTimeout(jQuery.proxy(function() { - this.widget.set_select_options(et2_selectbox.find_select_options(this.widget,{}, this.widget.options)); + // Avoid errors if widget is destroyed before the timeout + if(this.widget && typeof this.widget.id !== 'undefined') + { + this.widget.set_select_options(et2_selectbox.find_select_options(this.widget,{}, this.widget.options)); + } },this),1); },{widget:widget,cache_id:cache_id})); return [];