mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 12:21:26 +02:00
- Clean up some link sub-widgets to make them operate a little nicer / more consistently
- Check attrs for already existing select_options too, should speed up selectboxes a little more
This commit is contained in:
parent
5b7f804877
commit
a2faa9bd00
@ -428,28 +428,7 @@ var et2_link_apps = et2_selectbox.extend(
|
|||||||
init: function() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
var select_options = {};
|
if (this.options.select_options != null)
|
||||||
|
|
||||||
// Limit to one app
|
|
||||||
if(this.options.only_app) {
|
|
||||||
select_options[_attrs.only_app] = this.egw().lang(_attrs.only_app);
|
|
||||||
} else {
|
|
||||||
select_options = this.options.application_list ? this.options.application_list : this.egw().link_app_list('query');
|
|
||||||
|
|
||||||
// Check whether the options entry was found, if not read it from the
|
|
||||||
// content array.
|
|
||||||
if (select_options == null)
|
|
||||||
{
|
|
||||||
select_options = this.getArrayMgr('content')
|
|
||||||
.getEntry("options-" + this.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to an empty object
|
|
||||||
if (select_options == null)
|
|
||||||
{
|
|
||||||
select_options = {};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Preset to last application
|
// Preset to last application
|
||||||
if(!this.options.value)
|
if(!this.options.value)
|
||||||
@ -461,8 +440,22 @@ var et2_link_apps = et2_selectbox.extend(
|
|||||||
egw.set_preference(this.options.value.to_app || window.egw_appName,'link_app',this.getValue());
|
egw.set_preference(this.options.value.to_app || window.egw_appName,'link_app',this.getValue());
|
||||||
}),this);
|
}),this);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We get some minor speedups by overriding parent searching and directly setting select options
|
||||||
|
*/
|
||||||
|
transformAttributes: function(_attrs) {
|
||||||
|
var select_options = {};
|
||||||
|
|
||||||
|
// Limit to one app
|
||||||
|
if(_attrs.only_app) {
|
||||||
|
select_options[_attrs.only_app] = this.egw().lang(_attrs.only_app);
|
||||||
|
} else {
|
||||||
|
select_options = _attrs.application_list ? _attrs.application_list : egw.link_app_list('query');
|
||||||
}
|
}
|
||||||
this.set_select_options(select_options);
|
_attrs.select_options = select_options;
|
||||||
|
this._super.apply(this, arguments);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
et2_register_widget(et2_link_apps, ["link-apps"]);
|
et2_register_widget(et2_link_apps, ["link-apps"]);
|
||||||
@ -1487,7 +1480,10 @@ var et2_link_add = et2_inputWidget.extend(
|
|||||||
// Already done
|
// Already done
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.app_select = et2_createWidget("link-apps", jQuery.extend({},this.options,{'id': this.options.id + 'app'}) ,this);
|
this.app_select = et2_createWidget("link-apps", jQuery.extend({},this.options,{
|
||||||
|
'id': this.options.id + 'app',
|
||||||
|
value: this.options.application ? this.options.application : this.options.value && this.options.value.add_app ? this.options.value.add_app : null
|
||||||
|
}) ,this);
|
||||||
this.div.append(this.app_select.getDOMNode());
|
this.div.append(this.app_select.getDOMNode());
|
||||||
this.button = et2_createWidget("button", {label: this.egw().lang("add")}, this);
|
this.button = et2_createWidget("button", {label: this.egw().lang("add")}, this);
|
||||||
this.button.set_label(this.egw().lang("add"));
|
this.button.set_label(this.egw().lang("add"));
|
||||||
@ -1496,6 +1492,8 @@ var et2_link_add = et2_inputWidget.extend(
|
|||||||
self.egw().open(self.options.value.to_app + ":" + self.options.value.to_id, self.app_select.get_value(), 'add');
|
self.egw().open(self.options.value.to_app + ":" + self.options.value.to_id, self.app_select.get_value(), 'add');
|
||||||
};
|
};
|
||||||
this.div.append(this.button.getDOMNode());
|
this.div.append(this.button.getDOMNode());
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Should be handled client side.
|
* Should be handled client side.
|
||||||
|
@ -145,7 +145,9 @@ var et2_selectbox = et2_inputWidget.extend(
|
|||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
// If select_options are already known, skip the rest
|
// If select_options are already known, skip the rest
|
||||||
if(this.options && this.options.select_options && !jQuery.isEmptyObject(this.options.select_options))
|
if(this.options && this.options.select_options && !jQuery.isEmptyObject(this.options.select_options) ||
|
||||||
|
_attrs.select_options && !jQuery.isEmptyObject(_attrs.select_options)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user