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 = ...@@ -928,6 +928,17 @@ var JIO =
var that = {}, priv = {}; 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 //// Getters Setters
that.getID = function () { that.getID = function () {
return priv.id; return priv.id;
...@@ -1039,7 +1050,7 @@ var JIO = ...@@ -1039,7 +1050,7 @@ var JIO =
settings.storage && settings.applicant) { settings.storage && settings.applicant) {
return priv.queue.createJob ( settings ); return priv.queue.createJob ( settings );
} }
return null; return priv.wrongParametersError(settings);
}; };
that.saveDocument = function ( options ) { that.saveDocument = function ( options ) {
...@@ -1063,15 +1074,16 @@ var JIO = ...@@ -1063,15 +1074,16 @@ var JIO =
var settings = extend({ var settings = extend({
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'fileContent': '',
'method':'saveDocument', 'method':'saveDocument',
'callback': function () {} 'callback': function () {}
},options); },options);
// check dependencies // check dependencies
if (that.isReady() && settings.fileName && settings.fileContent && if (that.isReady() && settings.fileName &&
settings.storage && settings.applicant) { settings.storage && settings.applicant) {
return priv.queue.createJob ( settings ); return priv.queue.createJob ( settings );
} }
return null; return priv.wrongParametersError(settings);
}; };
that.loadDocument = function ( options ) { that.loadDocument = function ( options ) {
...@@ -1108,7 +1120,7 @@ var JIO = ...@@ -1108,7 +1120,7 @@ var JIO =
settings.storage && settings.applicant) { settings.storage && settings.applicant) {
return priv.queue.createJob ( settings ); return priv.queue.createJob ( settings );
} }
return null; return priv.wrongParametersError(settings);
}; };
that.getDocumentList = function ( options ) { that.getDocumentList = function ( options ) {
...@@ -1141,7 +1153,7 @@ var JIO = ...@@ -1141,7 +1153,7 @@ var JIO =
if (that.isReady() && settings.storage && settings.applicant ) { if (that.isReady() && settings.storage && settings.applicant ) {
return priv.queue.createJob( settings ); return priv.queue.createJob( settings );
} }
return null; return priv.wrongParametersError(settings);
}; };
that.removeDocument = function ( options ) { that.removeDocument = function ( options ) {
...@@ -1171,7 +1183,7 @@ var JIO = ...@@ -1171,7 +1183,7 @@ var JIO =
settings.storage && settings.applicant ) { settings.storage && settings.applicant ) {
return priv.queue.createJob ( settings ); return priv.queue.createJob ( settings );
} }
return null; return priv.wrongParametersError(settings);
}; };
//// end Methods //// end Methods
......
This diff is collapsed.
...@@ -1071,11 +1071,12 @@ var JIO = ...@@ -1071,11 +1071,12 @@ var JIO =
var settings = extend({ var settings = extend({
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'fileContent': '',
'method':'saveDocument', 'method':'saveDocument',
'callback': function () {} 'callback': function () {}
},options); },options);
// check dependencies // check dependencies
if (that.isReady() && settings.fileName && settings.fileContent && if (that.isReady() && settings.fileName &&
settings.storage && settings.applicant) { settings.storage && settings.applicant) {
return priv.queue.createJob ( settings ); 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