From c370941c51daea678badd73b7f70a3309c3b7b3e Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 20 Apr 2021 15:30:46 +0200 Subject: [PATCH] Keep private app objects if dialog gets destroyed --- api/js/etemplate/et2_widget_dialog.js | 2 +- api/js/etemplate/et2_widget_dialog.ts | 4 ++-- api/js/etemplate/etemplate2.js | 5 +++-- api/js/etemplate/etemplate2.ts | 5 +++-- api/js/jsapi/egw_global.d.ts | 4 +++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/js/etemplate/et2_widget_dialog.js b/api/js/etemplate/et2_widget_dialog.js index 018ba92ea8..fac648c0d2 100644 --- a/api/js/etemplate/et2_widget_dialog.js +++ b/api/js/etemplate/et2_widget_dialog.js @@ -180,7 +180,7 @@ var et2_dialog = /** @class */ (function (_super) { // Un-dialog the dialog this.div.dialog("destroy"); if (this.template) { - this.template.clear(); + this.template.clear(true); this.template = null; } this.div = null; diff --git a/api/js/etemplate/et2_widget_dialog.ts b/api/js/etemplate/et2_widget_dialog.ts index 3f35a25112..8bc33dff92 100644 --- a/api/js/etemplate/et2_widget_dialog.ts +++ b/api/js/etemplate/et2_widget_dialog.ts @@ -286,7 +286,7 @@ export class et2_dialog extends et2_widget { public static NO_BUTTON: number = 3; div: JQuery = null; - template: any = null; + template: etemplate2 = null; constructor(_parent?, _attrs? : WidgetConfig, _child? : object) { super(_parent, _attrs, ClassWithAttributes.extendAttributes(et2_dialog._attributes, _child || {})); @@ -322,7 +322,7 @@ export class et2_dialog extends et2_widget { this.div.dialog("destroy"); if (this.template) { - this.template.clear(); + this.template.clear(true); this.template = null; } diff --git a/api/js/etemplate/etemplate2.js b/api/js/etemplate/etemplate2.js index c91daed165..ef86d84658 100644 --- a/api/js/etemplate/etemplate2.js +++ b/api/js/etemplate/etemplate2.js @@ -173,8 +173,9 @@ var etemplate2 = /** @class */ (function () { ; /** * Clears the current instance. + * @param _keep_app_object keep app object */ - etemplate2.prototype.clear = function () { + etemplate2.prototype.clear = function (_keep_app_object) { jQuery(this._DOMContainer).trigger('clear'); // Remove any handlers on window (resize) if (this.uniqueId) { @@ -203,7 +204,7 @@ var etemplate2 = /** @class */ (function () { } } // If using a private app object, remove all of them - if (this.app_obj !== window.app) { + if (!_keep_app_object && 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(); diff --git a/api/js/etemplate/etemplate2.ts b/api/js/etemplate/etemplate2.ts index c0ad18cb98..4c2ddca685 100644 --- a/api/js/etemplate/etemplate2.ts +++ b/api/js/etemplate/etemplate2.ts @@ -224,8 +224,9 @@ export class etemplate2 /** * Clears the current instance. + * @param _keep_app_object keep app object */ - public clear() + public clear(_keep_app_object?:boolean) { jQuery(this._DOMContainer).trigger('clear'); @@ -265,7 +266,7 @@ export class etemplate2 } // If using a private app object, remove all of them - if(this.app_obj !== window.app) + if(!_keep_app_object && this.app_obj !== window.app) { for(const app_name in this.app_obj) { diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index 06e3c23f67..f1f7a7848c 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -13,6 +13,8 @@ * @author Andreas Stöckel */ +import {EgwApp} from "./egw_app"; + /** * Global egw object (for now created by the diverse JavaScript files) with a TypeScript interface */ @@ -1297,7 +1299,7 @@ declare interface IegwAppLocal extends IegwWndLocal declare function egw_getFramework() : any; declare var chrome : any; declare var InstallTrigger : any; -declare var app : {classes: any, [propName: string]: any}; +declare var app : {classes: any, [propName: string]: EgwApp}; declare var egw_globalObjectManager : any; declare var framework : any; declare var egw_LAB : any;