Commit 43bf4bf6 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#4185 / Detect modified record

save.php, QuickFormQuery.php: fixed malformed array for JSON
Dirty.js, QfqForm.js: replace instance variable 'additionalQueryparameters' against parameter by call: optionalQueryParameters.
parent c6b6f62f
......@@ -69,8 +69,8 @@ try {
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
$answer[API_MESSAGE] = 'save: success';
$answer[API_FORM_UPDATE] = $data;
$answer[API_ELEMENT_UPDATE] = $data[API_ELEMENT_UPDATE];
$answer[API_FORM_UPDATE] = $data[API_FORM_UPDATE];
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
......
......@@ -937,7 +937,7 @@ class QuickFormQuery {
}
if(count($data)>0){
$collect[] = $data;
$collect[API_FORM_UPDATE][] = $data;
}
}
......
......@@ -21,7 +21,6 @@ var QfqNS = QfqNS || {};
this.successTimerId = null;
this.deniedTimerId = null;
this.lockTimeoutInMilliseconds = n.Dirty.NO_LOCK_TIMEOUT;
this.additionalQueryParamters = null;
};
n.Dirty.NO_LOCK_TIMEOUT = -1;
......@@ -67,7 +66,7 @@ var QfqNS = QfqNS || {};
* @param sip {string} sip.
* @public
*/
n.Dirty.prototype.notify = function (sip) {
n.Dirty.prototype.notify = function (sip, optionalQueryParameters) {
var eventData;
if (!this.dirtyUrl) {
......@@ -77,7 +76,7 @@ var QfqNS = QfqNS || {};
eventData = n.EventEmitter.makePayload(this, null);
this.eventEmitter.emitEvent(n.Dirty.EVENTS.STARTED, eventData);
$.ajax({
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.LOCK),
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.LOCK, optionalQueryParameters),
type: 'GET',
cache: false
})
......@@ -109,6 +108,7 @@ var QfqNS = QfqNS || {};
*
* @param ajaxData data received from server
* @param eventData data passed when event is emitted.
* @private
*/
n.Dirty.prototype.setTimeoutIfRequired = function (ajaxData, eventData) {
var timeoutInMilliseconds;
......@@ -140,6 +140,9 @@ var QfqNS = QfqNS || {};
}
};
/**
* @public
*/
n.Dirty.prototype.clearSuccessTimeoutTimerIfSet = function () {
if (this.successTimerId) {
clearTimeout(this.successTimerId);
......@@ -147,6 +150,9 @@ var QfqNS = QfqNS || {};
}
};
/**
* @private
*/
n.Dirty.prototype.clearDeniedTimeoutTimerIfSet = function () {
if (this.deniedTimerId) {
clearTimeout(this.deniedTimerId);
......@@ -180,7 +186,7 @@ var QfqNS = QfqNS || {};
* @param sip {string} sip
* @public
*/
n.Dirty.prototype.release = function (sip) {
n.Dirty.prototype.release = function (sip, optionalQueryParameters) {
var eventData;
if (!this.dirtyUrl) {
......@@ -190,7 +196,7 @@ var QfqNS = QfqNS || {};
eventData = n.EventEmitter.makePayload(this, null);
this.eventEmitter.emitEvent(n.Dirty.EVENTS.RELEASE_STARTED, eventData);
$.ajax({
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.RELEASE),
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.RELEASE, optionalQueryParameters),
type: 'GET',
cache: false
})
......@@ -242,7 +248,7 @@ var QfqNS = QfqNS || {};
* @param sip {string} sip.
* @public
*/
n.Dirty.prototype.renew = function (sip) {
n.Dirty.prototype.renew = function (sip, optionalQueryParameters) {
var eventData;
if (!this.dirtyUrl) {
......@@ -252,7 +258,7 @@ var QfqNS = QfqNS || {};
eventData = n.EventEmitter.makePayload(this, null);
this.eventEmitter.emitEvent(n.Dirty.EVENTS.RENEWAL_STARTED, eventData);
$.ajax({
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.RENEW),
url: this.makeUrl(sip, n.Dirty.ENDPOINT_OPERATIONS.RENEW, optionalQueryParameters),
type: 'GET',
cache: false
})
......@@ -303,12 +309,13 @@ var QfqNS = QfqNS || {};
* @param sip {string} sip of the request
* @param operation {string} operation
* @returns {string} complete url
* @private
*/
n.Dirty.prototype.makeUrl = function (sip, operation) {
n.Dirty.prototype.makeUrl = function (sip, operation, optionalQueryParameters) {
var queryString, mergedQueryParameterObject;
mergedQueryParameterObject = $.extend(
this.additionalQueryParamters,
optionalQueryParameters,
{
s: sip,
action: operation
......
......@@ -75,7 +75,6 @@ var QfqNS = QfqNS || {};
this.eventEmitter = new EventEmitter();
this.dirty = new n.Dirty(this.dirtyUrl);
this.dirty.additionalQueryParamters = this.additionalQueryParameters;
this.dirty.on(n.Dirty.EVENTS.SUCCESS, this.dirtyNotifySuccess.bind(this));
this.dirty.on(n.Dirty.EVENTS.DENIED, this.dirtyNotifyDenied.bind(this));
this.dirty.on(n.Dirty.EVENTS.FAILED, this.dirtyNotifyFailed.bind(this));
......@@ -159,7 +158,7 @@ var QfqNS = QfqNS || {};
return;
}
n.Log.debug("releaseLock(): releasing lock.");
this.dirty.release(this.getSip());
this.dirty.release(this.getSip(), this.getRecordHashMd5AsQueryParameter());
this.resetLockState();
};
......@@ -609,15 +608,22 @@ var QfqNS = QfqNS || {};
{label: "No", eventName: "cancel", focus: true}
]
});
var that = this;
alert.on('alert.ok', function () {
$.post(that.appendQueryParametersToUrl(that.deleteUrl, that.additionalQueryParameters))
$.post(that.appendQueryParametersToUrl(that.deleteUrl, that.getRecordHashMd5AsQueryParameter()))
.done(that.ajaxDeleteSuccessDispatcher.bind(that))
.fail(n.Helper.showAjaxError);
});
alert.show();
};
n.QfqForm.prototype.getRecordHashMd5AsQueryParameter = function () {
return {
'recordHashMd5': this.getRecordHashMd5()
};
};
/**
*
* @param data
......@@ -715,9 +721,9 @@ var QfqNS = QfqNS || {};
}
if (this.lockRenewalPhase) {
this.dirty.renew(this.getSip());
this.dirty.renew(this.getSip(), this.getRecordHashMd5AsQueryParameter());
} else {
this.dirty.notify(this.getSip());
this.dirty.notify(this.getSip(), this.getRecordHashMd5AsQueryParameter());
}
this.dirtyFired = true;
};
......
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