mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 22:27:55 +01:00
Avoid overlapping saves ...
This commit is contained in:
parent
90b584569b
commit
8de31d9edc
@ -46,22 +46,37 @@ mindplot.RESTPersistenceManager = new Class({
|
|||||||
query = query + (this.timestamp ? "×tamp=" + this.timestamp : "");
|
query = query + (this.timestamp ? "×tamp=" + this.timestamp : "");
|
||||||
query = query + (this.session ? "&session=" + this.session : "");
|
query = query + (this.session ? "&session=" + this.session : "");
|
||||||
|
|
||||||
|
if (!persistence.onSave) {
|
||||||
|
|
||||||
|
// Mark save in process and fire a event unlocking the save ...
|
||||||
|
persistence.onSave = true;
|
||||||
|
persistence.clearTimeout = setTimeout(function () {
|
||||||
|
persistence.clearTimeout = null;
|
||||||
|
persistence.onSave = false;
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
var request = new Request({
|
var request = new Request({
|
||||||
url:this.saveUrl.replace("{id}", mapId) + "?" + query,
|
url:this.saveUrl.replace("{id}", mapId) + "?" + query,
|
||||||
method:'put',
|
method:'put',
|
||||||
async:!sync,
|
async:!sync,
|
||||||
|
|
||||||
onSuccess:function (responseText, responseXML) {
|
onSuccess:function (responseText, responseXML) {
|
||||||
events.onSuccess();
|
|
||||||
persistence.timestamp = responseText;
|
persistence.timestamp = responseText;
|
||||||
|
events.onSuccess();
|
||||||
},
|
},
|
||||||
|
|
||||||
onException:function (headerName, value) {
|
onException:function (headerName, value) {
|
||||||
console.log("onException....");
|
|
||||||
|
|
||||||
events.onError(persistence._buildError());
|
events.onError(persistence._buildError());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onComplete:function () {
|
||||||
|
// Clear event timeout ...
|
||||||
|
if (persistence.clearTimeout) {
|
||||||
|
clearTimeout(persistence.clearTimeout);
|
||||||
|
}
|
||||||
|
persistence.onSave = false;
|
||||||
|
},
|
||||||
|
|
||||||
onFailure:function (xhr) {
|
onFailure:function (xhr) {
|
||||||
|
|
||||||
var responseText = xhr.responseText;
|
var responseText = xhr.responseText;
|
||||||
@ -85,7 +100,8 @@ mindplot.RESTPersistenceManager = new Class({
|
|||||||
}
|
}
|
||||||
events.onError(userMsg);
|
events.onError(userMsg);
|
||||||
|
|
||||||
// Only for debug. Remove.
|
// @Todo: Only for debug. Remove.
|
||||||
|
persistence.onSave = false;
|
||||||
throw new Error("responseText:" + responseText + ",status:" + this.status);
|
throw new Error("responseText:" + responseText + ",status:" + this.status);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -94,6 +110,7 @@ mindplot.RESTPersistenceManager = new Class({
|
|||||||
urlEncoded:false
|
urlEncoded:false
|
||||||
});
|
});
|
||||||
request.put(JSON.encode(data));
|
request.put(JSON.encode(data));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
discardChanges:function (mapId) {
|
discardChanges:function (mapId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user