Commit 00e4e5cb authored by bbaer's avatar bbaer
Browse files

fixes #9789 with some hiccups.

parent 42ee94bd
Pipeline #3043 passed with stages
in 3 minutes and 29 seconds
......@@ -152,11 +152,6 @@ var QfqNS = QfqNS || {};
this.form.on('form.validation.failed', this.validationError);
this.form.on('form.validation.success', this.validationSuccess);
// Solves problem of leaving the page without releasing locks.
window.onbeforeunload = function (e) {
that.releaseLock();
};
$(".radio-inline").append($("<span>", { class: "checkmark", aria: "hidden"}));
$(".checkbox-inline").append($("<span>", { class: "checkmark", aria: "hidden"}));
$(".radio").append($("<span>", { class: "checkmark", aria: "hidden"}));
......@@ -175,6 +170,32 @@ var QfqNS = QfqNS || {};
this.lockAcquired = true;
};
n.QfqForm.prototype.handleUnload = function(e) {
var that = this;
var alert = new n.Alert({
message: "Do you want to save before leaving?",
type: "info",
buttons: [
{ label: "Yes", eventName: "yes" },
{ label: "No", eventName: "no" },
{ label: "Cancel", eventName: "cancel" }
]
});
alert.on('alert.yes', function() {
that.handleSaveClick();
that.releaseLock();
});
alert.on('alert.no', function() {
that.releaseLock();
});
alert.on('alert.cancel', function() {
return false;
});
e.preventDefault();
return null;
};
/**
* @public
*/
......@@ -575,7 +596,6 @@ var QfqNS = QfqNS || {};
};
n.QfqForm.prototype.callSave = function(uri) {
console.log("target: " + uri);
if(this.isFormChanged()) {
this.handleSaveClick();
this.goToAfterSave = uri;
......
......@@ -81,7 +81,7 @@ var QfqNS = QfqNS || {};
// We have to use 'pagehide'. 'unload' is too late and the ajax request is lost.
window.addEventListener("pagehide", (function (that) {
return function () {
that.qfqForm.releaseLock(false);
that.qfqForm.releaseLock();
};
})(this));
} catch (e) {
......@@ -115,6 +115,8 @@ var QfqNS = QfqNS || {};
/**
* @private
*
* Releaselock has to be handled at the pagehide event, not here
*/
n.QfqPage.prototype.beforeUnloadHandler = function (event) {
var message = "\0/";
......@@ -125,8 +127,6 @@ var QfqNS = QfqNS || {};
event.returnValue = message;
return message;
}
this.qfqForm.releaseLock();
};
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment