diff --git a/api/js/etemplate/et2_widget_button.js b/api/js/etemplate/et2_widget_button.js index d06f8c5191..707795bc56 100644 --- a/api/js/etemplate/et2_widget_button.js +++ b/api/js/etemplate/et2_widget_button.js @@ -199,6 +199,10 @@ var et2_button = /** @class */ (function (_super) { if (this.options.readonly) return false; this.clicked = true; + // Cancel buttons don't trigger the close confirmation prompt + if (this.btn.hasClass("et2_button_cancel")) { + this.getInstanceManager().skip_close_prompt(); + } if (!_super.prototype.click.apply(this, arguments)) { this.clicked = false; return false; @@ -208,6 +212,7 @@ var et2_button = /** @class */ (function (_super) { this.getInstanceManager().submit(this, false, this.options.novalidate); //TODO: this only needs to be passed if it's in a datagrid } this.clicked = false; + this.getInstanceManager().skip_close_prompt(false); return true; }; et2_button.prototype.set_label = function (_value) { diff --git a/api/js/etemplate/et2_widget_button.ts b/api/js/etemplate/et2_widget_button.ts index 9b6071475b..98e28acef0 100644 --- a/api/js/etemplate/et2_widget_button.ts +++ b/api/js/etemplate/et2_widget_button.ts @@ -310,6 +310,12 @@ export class et2_button extends et2_baseWidget implements et2_IInput, et2_IDetac this.clicked = true; + // Cancel buttons don't trigger the close confirmation prompt + if(this.btn.hasClass("et2_button_cancel")) + { + this.getInstanceManager().skip_close_prompt(); + } + if (!super.click.apply(this, arguments)) { this.clicked = false; @@ -322,6 +328,7 @@ export class et2_button extends et2_baseWidget implements et2_IInput, et2_IDetac this.getInstanceManager().submit(this, false, this.options.novalidate); //TODO: this only needs to be passed if it's in a datagrid } this.clicked = false; + this.getInstanceManager().skip_close_prompt(false); return true; } diff --git a/api/js/etemplate/etemplate2.js b/api/js/etemplate/etemplate2.js index f1960b3947..29039e7c4e 100644 --- a/api/js/etemplate/etemplate2.js +++ b/api/js/etemplate/etemplate2.js @@ -288,7 +288,7 @@ var etemplate2 = /** @class */ (function () { } }; etemplate2.prototype._close_changed_prompt = function (e) { - if (!this.isDirty()) { + if (this._skip_close_prompt || !this.isDirty()) { return; } // Cancel the event @@ -296,6 +296,10 @@ var etemplate2 = /** @class */ (function () { // Chrome requires returnValue to be set e.returnValue = ''; }; + etemplate2.prototype.skip_close_prompt = function (skip) { + if (skip === void 0) { skip = true; } + this._skip_close_prompt = skip; + }; /** * Unbind our unload handler */ diff --git a/api/js/etemplate/etemplate2.ts b/api/js/etemplate/etemplate2.ts index 8136f40a81..5c420465bc 100644 --- a/api/js/etemplate/etemplate2.ts +++ b/api/js/etemplate/etemplate2.ts @@ -108,6 +108,7 @@ export class etemplate2 private resize_timeout: number | boolean; private destroy_session: any; private close_prompt: any; + private _skip_close_prompt: boolean; private app_obj: EgwApp; app: string; @@ -366,7 +367,7 @@ export class etemplate2 private _close_changed_prompt(e : BeforeUnloadEvent) { - if(!this.isDirty()) + if(this._skip_close_prompt || !this.isDirty()) { return; } @@ -378,6 +379,11 @@ export class etemplate2 e.returnValue = ''; } + public skip_close_prompt(skip = true) + { + this._skip_close_prompt = skip; + } + /** * Unbind our unload handler */