Etemplate: Cancel buttons do not trigger the change/close prompt

This commit is contained in:
nathangray 2020-06-24 10:37:57 -06:00
parent 74284afc07
commit 143be4dc98
4 changed files with 24 additions and 2 deletions

View File

@ -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) {

View File

@ -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;
}

View File

@ -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
*/

View File

@ -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
*/