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
This commit is contained in:
Nathan Gray 2015-07-09 19:15:24 +00:00
parent c34e665faf
commit 9d5d2944c4
3 changed files with 12 additions and 5 deletions

View File

@ -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;

View File

@ -3362,7 +3362,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
@ -3372,7 +3375,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)
{

View File

@ -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 [];