Commit d1a8148c authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Fix bug: check saveDocument dependencies.

parent 3c4f9683
......@@ -928,6 +928,17 @@ var JIO =
var that = {}, priv = {};
priv.wrongParametersError = function (settings) {
var m = 'Method: '+ settings.method +
', One or some parameters are undefined.';
console.error (m);
settings.callback({status:'fail',
error: {status:0,
statusText:'Undefined Parameter',
message: m}});
return null;
};
//// Getters Setters
that.getID = function () {
return priv.id;
......@@ -1039,7 +1050,7 @@ var JIO =
settings.storage && settings.applicant) {
return priv.queue.createJob ( settings );
}
return null;
return priv.wrongParametersError(settings);
};
that.saveDocument = function ( options ) {
......@@ -1063,15 +1074,16 @@ var JIO =
var settings = extend({
'storage': priv.storage,
'applicant': priv.applicant,
'fileContent': '',
'method':'saveDocument',
'callback': function () {}
},options);
// check dependencies
if (that.isReady() && settings.fileName && settings.fileContent &&
if (that.isReady() && settings.fileName &&
settings.storage && settings.applicant) {
return priv.queue.createJob ( settings );
}
return null;
return priv.wrongParametersError(settings);
};
that.loadDocument = function ( options ) {
......@@ -1108,7 +1120,7 @@ var JIO =
settings.storage && settings.applicant) {
return priv.queue.createJob ( settings );
}
return null;
return priv.wrongParametersError(settings);
};
that.getDocumentList = function ( options ) {
......@@ -1141,7 +1153,7 @@ var JIO =
if (that.isReady() && settings.storage && settings.applicant ) {
return priv.queue.createJob( settings );
}
return null;
return priv.wrongParametersError(settings);
};
that.removeDocument = function ( options ) {
......@@ -1171,7 +1183,7 @@ var JIO =
settings.storage && settings.applicant ) {
return priv.queue.createJob ( settings );
}
return null;
return priv.wrongParametersError(settings);
};
//// end Methods
......
This diff is collapsed.
......@@ -1071,11 +1071,12 @@ var JIO =
var settings = extend({
'storage': priv.storage,
'applicant': priv.applicant,
'fileContent': '',
'method':'saveDocument',
'callback': function () {}
},options);
// check dependencies
if (that.isReady() && settings.fileName && settings.fileContent &&
if (that.isReady() && settings.fileName &&
settings.storage && settings.applicant) {
return priv.queue.createJob ( settings );
}
......
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