mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Api: Take care of private app.js instances, make sure they're included in iteration.
Iterate over all app.js instances (public & private) using: for (var app_obj of window.EgwApp) {...}
This commit is contained in:
parent
16e3b2cd05
commit
444babdbc8
@ -39,8 +39,8 @@ var et2_core_valueWidget_1 = require("./et2_core_valueWidget");
|
|||||||
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
var et2_core_inputWidget_1 = require("./et2_core_inputWidget");
|
||||||
var et2_widget_selectbox_1 = require("./et2_widget_selectbox");
|
var et2_widget_selectbox_1 = require("./et2_widget_selectbox");
|
||||||
/**
|
/**
|
||||||
* UI widgets for Egroupware linking system
|
* UI widgets for Egroupware linking system
|
||||||
*/
|
*/
|
||||||
var et2_link_to = /** @class */ (function (_super) {
|
var et2_link_to = /** @class */ (function (_super) {
|
||||||
__extends(et2_link_to, _super);
|
__extends(et2_link_to, _super);
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,6 @@ var et2_core_widget_1 = require("./et2_core_widget");
|
|||||||
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
var et2_core_inheritance_1 = require("./et2_core_inheritance");
|
||||||
var et2_widget_link_1 = require("./et2_widget_link");
|
var et2_widget_link_1 = require("./et2_widget_link");
|
||||||
var et2_widget_dialog_1 = require("./et2_widget_dialog");
|
var et2_widget_dialog_1 = require("./et2_widget_dialog");
|
||||||
var et2_widget_link_2 = require("./et2_widget_link");
|
|
||||||
/**
|
/**
|
||||||
* Account selection widget
|
* Account selection widget
|
||||||
* Changes according to the user's account_selection preference
|
* Changes according to the user's account_selection preference
|
||||||
@ -721,7 +720,7 @@ var et2_selectAccount_ro = /** @class */ (function (_super) {
|
|||||||
};
|
};
|
||||||
et2_selectAccount_ro.legacyOptions = ["empty_label"];
|
et2_selectAccount_ro.legacyOptions = ["empty_label"];
|
||||||
return et2_selectAccount_ro;
|
return et2_selectAccount_ro;
|
||||||
}(et2_widget_link_2.et2_link_string));
|
}(et2_widget_link_1.et2_link_string));
|
||||||
exports.et2_selectAccount_ro = et2_selectAccount_ro;
|
exports.et2_selectAccount_ro = et2_selectAccount_ro;
|
||||||
et2_core_widget_1.et2_register_widget(et2_selectAccount_ro, ["select-account_ro"]);
|
et2_core_widget_1.et2_register_widget(et2_selectAccount_ro, ["select-account_ro"]);
|
||||||
//# sourceMappingURL=et2_widget_selectAccount.js.map
|
//# sourceMappingURL=et2_widget_selectAccount.js.map
|
@ -74,6 +74,7 @@
|
|||||||
*/
|
*/
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
var et2_core_baseWidget_1 = require("./et2_core_baseWidget");
|
||||||
|
var egw_app_1 = require("../jsapi/egw_app");
|
||||||
/**
|
/**
|
||||||
* The etemplate2 class manages a certain etemplate2 instance.
|
* The etemplate2 class manages a certain etemplate2 instance.
|
||||||
*
|
*
|
||||||
@ -196,6 +197,14 @@ var etemplate2 = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If using a private app object, remove all of them
|
||||||
|
if (this.app_obj !== window.app) {
|
||||||
|
for (var app_name in this.app_obj) {
|
||||||
|
if (this.app_obj[app_name] instanceof egw_app_1.EgwApp) {
|
||||||
|
this.app_obj[app_name].destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Object.defineProperty(etemplate2.prototype, "widgetContainer", {
|
Object.defineProperty(etemplate2.prototype, "widgetContainer", {
|
||||||
get: function () {
|
get: function () {
|
||||||
@ -383,8 +392,6 @@ var etemplate2 = /** @class */ (function () {
|
|||||||
app[appname].et2_ready(_et2, _name);
|
app[appname].et2_ready(_et2, _name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Clear any existing instance
|
|
||||||
this.clear();
|
|
||||||
// Create the basic widget container and attach it to the DOM
|
// Create the basic widget container and attach it to the DOM
|
||||||
this._widgetContainer = new et2_core_baseWidget_1.et2_container(null);
|
this._widgetContainer = new et2_core_baseWidget_1.et2_container(null);
|
||||||
this._widgetContainer.setApiInstance(egw(currentapp, egw.elemWindow(this._DOMContainer)));
|
this._widgetContainer.setApiInstance(egw(currentapp, egw.elemWindow(this._DOMContainer)));
|
||||||
|
@ -256,6 +256,18 @@ export class etemplate2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If using a private app object, remove all of them
|
||||||
|
if(this.app_obj !== window.app)
|
||||||
|
{
|
||||||
|
for(const app_name in this.app_obj)
|
||||||
|
{
|
||||||
|
if(this.app_obj[app_name] instanceof EgwApp)
|
||||||
|
{
|
||||||
|
this.app_obj[app_name].destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get widgetContainer(): et2_container
|
get widgetContainer(): et2_container
|
||||||
@ -486,9 +498,6 @@ export class etemplate2
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear any existing instance
|
|
||||||
this.clear();
|
|
||||||
|
|
||||||
// Create the basic widget container and attach it to the DOM
|
// Create the basic widget container and attach it to the DOM
|
||||||
this._widgetContainer = new et2_container(null);
|
this._widgetContainer = new et2_container(null);
|
||||||
this._widgetContainer.setApiInstance(egw(currentapp, egw.elemWindow(this._DOMContainer)));
|
this._widgetContainer.setApiInstance(egw(currentapp, egw.elemWindow(this._DOMContainer)));
|
||||||
|
@ -76,6 +76,8 @@ var EgwApp = /** @class */ (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mailvelopeSyncHandlerObj = this.mailvelopeSyncHandler();
|
this.mailvelopeSyncHandlerObj = this.mailvelopeSyncHandler();
|
||||||
|
// Keep track of this instance
|
||||||
|
EgwApp._register_instance(this);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Clean up any created objects & references
|
* Clean up any created objects & references
|
||||||
@ -88,6 +90,10 @@ var EgwApp = /** @class */ (function () {
|
|||||||
delete this.sidebox;
|
delete this.sidebox;
|
||||||
if (!_app)
|
if (!_app)
|
||||||
delete app[this.appname];
|
delete app[this.appname];
|
||||||
|
var index = -1;
|
||||||
|
if ((index = EgwApp._instances.indexOf(this)) >= 0) {
|
||||||
|
EgwApp._instances.splice(index, 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* This function is called when the etemplate2 object is loaded
|
* This function is called when the etemplate2 object is loaded
|
||||||
@ -1668,6 +1674,34 @@ var EgwApp = /** @class */ (function () {
|
|||||||
value: { content: { "share_link": _data.share_link } }
|
value: { content: { "share_link": _data.share_link } }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Keep a list of all EgwApp instances
|
||||||
|
*
|
||||||
|
* This is not just the globals available in window.app, it also includes private instances as well
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param app_obj
|
||||||
|
*/
|
||||||
|
EgwApp._register_instance = function (app_obj) {
|
||||||
|
// Reject improper objects
|
||||||
|
if (!app_obj.appname)
|
||||||
|
return;
|
||||||
|
EgwApp._instances.push(app_obj);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Iterator over all app instances
|
||||||
|
*
|
||||||
|
* Use for(const app of EgwApp) {...} to iterate over all app objects.
|
||||||
|
*/
|
||||||
|
EgwApp[Symbol.iterator] = function () {
|
||||||
|
return EgwApp._instances[Symbol.iterator]();
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* In some cases (CRM) a private, disconnected app instance is created instead of
|
||||||
|
* using the global. We want to be able to access them for observer() & push(), so
|
||||||
|
* we track all instances.
|
||||||
|
*/
|
||||||
|
EgwApp._instances = [];
|
||||||
return EgwApp;
|
return EgwApp;
|
||||||
}());
|
}());
|
||||||
exports.EgwApp = EgwApp;
|
exports.EgwApp = EgwApp;
|
||||||
|
@ -120,6 +120,13 @@ export abstract class EgwApp
|
|||||||
|
|
||||||
mailvelopeSyncHandlerObj : any;
|
mailvelopeSyncHandlerObj : any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In some cases (CRM) a private, disconnected app instance is created instead of
|
||||||
|
* using the global. We want to be able to access them for observer() & push(), so
|
||||||
|
* we track all instances.
|
||||||
|
*/
|
||||||
|
static _instances: EgwApp[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialization and setup goes here, but the etemplate2 object
|
* Initialization and setup goes here, but the etemplate2 object
|
||||||
* is not yet ready.
|
* is not yet ready.
|
||||||
@ -152,6 +159,9 @@ export abstract class EgwApp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.mailvelopeSyncHandlerObj = this.mailvelopeSyncHandler();
|
this.mailvelopeSyncHandlerObj = this.mailvelopeSyncHandler();
|
||||||
|
|
||||||
|
// Keep track of this instance
|
||||||
|
EgwApp._register_instance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,6 +175,11 @@ export abstract class EgwApp
|
|||||||
this.sidebox.off();
|
this.sidebox.off();
|
||||||
delete this.sidebox;
|
delete this.sidebox;
|
||||||
if (!_app) delete app[this.appname];
|
if (!_app) delete app[this.appname];
|
||||||
|
let index = -1;
|
||||||
|
if((index = EgwApp._instances.indexOf(this)) >= 0)
|
||||||
|
{
|
||||||
|
EgwApp._instances.splice(index,1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2084,4 +2099,30 @@ export abstract class EgwApp
|
|||||||
value: {content:{ "share_link": _data.share_link }}
|
value: {content:{ "share_link": _data.share_link }}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep a list of all EgwApp instances
|
||||||
|
*
|
||||||
|
* This is not just the globals available in window.app, it also includes private instances as well
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param app_obj
|
||||||
|
*/
|
||||||
|
private static _register_instance(app_obj: EgwApp)
|
||||||
|
{
|
||||||
|
// Reject improper objects
|
||||||
|
if(!app_obj.appname) return;
|
||||||
|
|
||||||
|
EgwApp._instances.push(app_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterator over all app instances
|
||||||
|
*
|
||||||
|
* Use for(const app of EgwApp) {...} to iterate over all app objects.
|
||||||
|
*/
|
||||||
|
static [Symbol.iterator]()
|
||||||
|
{
|
||||||
|
return EgwApp._instances[Symbol.iterator]();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,9 +337,8 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
// notify app observers: if observer for _app itself returns false, no regular refresh will take place
|
// notify app observers: if observer for _app itself returns false, no regular refresh will take place
|
||||||
// app's own observer can replace current app_refresh functionality
|
// app's own observer can replace current app_refresh functionality
|
||||||
var no_regular_refresh = false;
|
var no_regular_refresh = false;
|
||||||
for(var app in _wnd.egw.window.app) // run observers in main window (eg. not iframe, which might be opener!)
|
for(var app_obj of _wnd.egw.window.EgwApp) // run observers in main window (eg. not iframe, which might be opener!)
|
||||||
{
|
{
|
||||||
var app_obj = _wnd.egw.window.app[app];
|
|
||||||
if (typeof app_obj.observer == 'function' &&
|
if (typeof app_obj.observer == 'function' &&
|
||||||
app_obj.observer(_msg, _app, _id, _type, _msg_type, _links) === false && app === _app)
|
app_obj.observer(_msg, _app, _id, _type, _msg_type, _links) === false && app === _app)
|
||||||
{
|
{
|
||||||
@ -425,9 +424,8 @@ egw.extend('message', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// notify app observers
|
// notify app observers
|
||||||
for (var app in _wnd.egw.window.app) // run observers in main window (eg. not iframe, which might be opener!)
|
for (var app_obj of _wnd.egw.window.EgwApp) // run observers in main window (eg. not iframe, which might be opener!)
|
||||||
{
|
{
|
||||||
var app_obj = _wnd.egw.window.app[app];
|
|
||||||
if (typeof app_obj.push == 'function')
|
if (typeof app_obj.push == 'function')
|
||||||
{
|
{
|
||||||
app_obj.push(pushData);
|
app_obj.push(pushData);
|
||||||
|
Loading…
Reference in New Issue
Block a user