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:12:13 +00:00
parent 34536f7e89
commit 3cf6211c95
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

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

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() {
// 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 [];