Commit c0709268 authored by bbaer's avatar bbaer
Browse files

Lock Release now sent asynchronous. Does not work on Chrome when synchron....

Lock Release now sent asynchronous. Does not work on Chrome when synchron. Still needs changes on Server side to work.
parent 904ab932
......@@ -186,8 +186,11 @@ var QfqNS = QfqNS || {};
* @param sip {string} sip
* @public
*/
n.Dirty.prototype.release = function (sip, optionalQueryParameters) {
n.Dirty.prototype.release = function (sip, optionalQueryParameters, async) {
var eventData;
if (async === undefined) {
async = true;
}
if (!this.dirtyUrl) {
n.Log.debug("release: cannot contact server, no dirtyUrl.");
......@@ -198,7 +201,8 @@ var QfqNS = QfqNS || {};
$.ajax({
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.RELEASE, optionalQueryParameters),
type: 'GET',
cache: false
cache: false,
async: async
})
.done(this.ajaxReleaseSuccessHandler.bind(this))
.fail(this.ajaxReleaseErrorHandler.bind(this));
......@@ -211,6 +215,7 @@ var QfqNS = QfqNS || {};
* @param jqXHR
*/
n.Dirty.prototype.ajaxReleaseSuccessHandler = function (data, textStatus, jqXHR) {
n.Log.debug("Dirty Release: Response received.");
var eventData = n.EventEmitter.makePayload(this, data);
if (data.status && data.status === "success") {
this.eventEmitter.emitEvent(n.Dirty.EVENTS.RELEASE_SUCCESS, eventData);
......
......@@ -152,13 +152,13 @@ var QfqNS = QfqNS || {};
/**
* @public
*/
n.QfqForm.prototype.releaseLock = function () {
n.QfqForm.prototype.releaseLock = function (async) {
if (!this.lockAcquired) {
n.Log.debug("releaseLock(): no lock acquired or already released.");
return;
}
n.Log.debug("releaseLock(): releasing lock.");
this.dirty.release(this.getSip(), this.getRecordHashMd5AsQueryParameter());
this.dirty.release(this.getSip(), this.getRecordHashMd5AsQueryParameter(), async);
this.resetLockState();
};
......
......@@ -80,8 +80,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 () {
n.Log.debug("release lock");
that.qfqForm.releaseLock();
that.qfqForm.releaseLock(false);
};
})(this));
} catch (e) {
......
Supports Markdown
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