Fix methods in hidden app objects could not be used as action handlers

Now nextmatch sets the etemplate's EgwApp object as context for the action manager.  Actions now check and will use the set context instead of global when binding to handlers
This commit is contained in:
nathangray 2020-10-08 14:57:45 -06:00
parent 4b9d561bbe
commit 20a48d2fe4
3 changed files with 20 additions and 9 deletions

View File

@ -381,15 +381,24 @@ egwFnct.prototype.setValue = function(_value)
}
// egw application specific function
else if (typeof _value == "string" &&
_value.substr(0,15) == "javaScript:app." && app)
else if (typeof _value === "string" &&
_value.substr(0,15) === "javaScript:app." && app)
{
var parts = _value.split(".");
if(parts.length == 3 && typeof app[parts[1]] == "object" &&
typeof app[parts[1]][parts[2]] == "function")
{
this.fnct = app[parts[1]][parts[2]];
this.context = app[parts[1]];
var existing_func = parts.pop();
var parent = this.context.getManager().data.context || window.app;
for (var i = 1; i < parts.length; ++i) {
if (typeof parent[parts[i]] !== "undefined") {
parent = parent[parts[i]];
}
// Nope
else {
break;
}
}
if (typeof parent[existing_func] === "function") {
this.fnct = parent[existing_func];
this.context = parent;
}
}

View File

@ -236,13 +236,14 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
if (this._actionManager == null) {
this._actionManager = gam.addAction("actionManager", uid);
}
this._actionManager.updateActions(_actions, this.egw.appName);
var data = this._actionManager.data;
if (data == 'undefined' || !data) {
data = {};
}
data.nextmatch = this._widget;
data.context = this._widget.getInstanceManager().app_obj;
this._actionManager.set_data(data);
this._actionManager.updateActions(_actions, this.egw.appName);
// Set the default execute handler
var self = this;
this._actionManager.setDefaultExecute(function (_action, _senders, _target) {

View File

@ -278,14 +278,15 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
{
this._actionManager = gam.addAction("actionManager", uid);
}
this._actionManager.updateActions(_actions, this.egw.appName);
var data = this._actionManager.data;
if (data == 'undefined' || !data)
{
data = {};
}
data.nextmatch = this._widget;
data.context = this._widget.getInstanceManager().app_obj;
this._actionManager.set_data(data);
this._actionManager.updateActions(_actions, this.egw.appName);
// Set the default execute handler
var self = this;