commit/galaxy-central: guerler: ToolForm: Improve validation
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/720ea1796c26/ Changeset: 720ea1796c26 User: guerler Date: 2014-10-17 18:11:25+00:00 Summary: ToolForm: Improve validation Affected #: 3 files diff -r d8163f6a8f51ffb44fc8858ae8714f41226d93f8 -r 720ea1796c26574d642e02db3583085c348a4474 client/galaxy/scripts/mvc/tools/tools-jobs.js --- a/client/galaxy/scripts/mvc/tools/tools-jobs.js +++ b/client/galaxy/scripts/mvc/tools/tools-jobs.js @@ -96,7 +96,8 @@ var job_inputs = job_def.inputs; // counter for values declared in batch mode - var n_values = -1; + var batch_n = -1; + var batch_src = null; // validation for (var job_input_id in job_inputs) { @@ -116,12 +117,33 @@ // check if input field is in batch mode if (input_value.batch) { + // get values var n = input_value.values.length; - if (n_values === -1) { - n_values = n; + + // get source + var src = null; + if (n > 0) { + src = input_value.values[0] && input_value.values[0].src; + } + + // check source type + if (src) { + if (batch_src === null) { + batch_src = src; + } else { + if (batch_src !== src) { + this._foundError(input_id, 'Please select either dataset or dataset list fields for all batch mode fields.'); + return false; + } + } + } + + // check number of inputs + if (batch_n === -1) { + batch_n = n; } else { - if (n_values !== n) { - this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); + if (batch_n !== n) { + this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + batch_n + '</b>.'); return false; } } diff -r d8163f6a8f51ffb44fc8858ae8714f41226d93f8 -r 720ea1796c26574d642e02db3583085c348a4474 static/scripts/mvc/tools/tools-jobs.js --- a/static/scripts/mvc/tools/tools-jobs.js +++ b/static/scripts/mvc/tools/tools-jobs.js @@ -96,7 +96,8 @@ var job_inputs = job_def.inputs; // counter for values declared in batch mode - var n_values = -1; + var batch_n = -1; + var batch_src = null; // validation for (var job_input_id in job_inputs) { @@ -116,12 +117,33 @@ // check if input field is in batch mode if (input_value.batch) { + // get values var n = input_value.values.length; - if (n_values === -1) { - n_values = n; + + // get source + var src = null; + if (n > 0) { + src = input_value.values[0] && input_value.values[0].src; + } + + // check source type + if (src) { + if (batch_src === null) { + batch_src = src; + } else { + if (batch_src !== src) { + this._foundError(input_id, 'Please select either dataset or dataset list fields for all batch mode fields.'); + return false; + } + } + } + + // check number of inputs + if (batch_n === -1) { + batch_n = n; } else { - if (n_values !== n) { - this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); + if (batch_n !== n) { + this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + batch_n + '</b>.'); return false; } } diff -r d8163f6a8f51ffb44fc8858ae8714f41226d93f8 -r 720ea1796c26574d642e02db3583085c348a4474 static/scripts/packed/mvc/tools/tools-jobs.js --- a/static/scripts/packed/mvc/tools/tools-jobs.js +++ b/static/scripts/packed/mvc/tools/tools-jobs.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.debug(d);this.app.modal.show({title:"Please wait...",body:"progress",closing_events:true,buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.message(a.success(e));c._refreshHdas()},error:function(e,g){c.app.modal.hide();if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var f in h){c._foundError(f,h[f]);break}}else{console.debug(e);c.app.modal.show({title:"Job submission failed",body:a.error(d),buttons:{Close:function(){c.app.modal.hide()}}})}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(g){var c=g.inputs;var k=-1;for(var i in c){var e=c[i];var j=this.app.tree.match(i);var d=this.app.field_list[j];var h=this.app.input_list[j];if(h&&d&&d.validate&&!d.validate()){this._foundError(j);return false}if(e.batch){var f=e.values.length;if(k===-1){k=f}else{if(k!==f){this._foundError(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+f+"</b> selection(s) while a previous field contains <b>"+k+"</b>.");return false}}}}return true},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})}); \ No newline at end of file +define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.debug(d);this.app.modal.show({title:"Please wait...",body:"progress",closing_events:true,buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.message(a.success(e));c._refreshHdas()},error:function(e,g){c.app.modal.hide();if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var f in h){c._foundError(f,h[f]);break}}else{console.debug(e);c.app.modal.show({title:"Job submission failed",body:a.error(d),buttons:{Close:function(){c.app.modal.hide()}}})}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(h){var d=h.inputs;var m=-1;var i=null;for(var k in d){var f=d[k];var l=this.app.tree.match(k);var e=this.app.field_list[l];var j=this.app.input_list[l];if(j&&e&&e.validate&&!e.validate()){this._foundError(l);return false}if(f.batch){var g=f.values.length;var c=null;if(g>0){c=f.values[0]&&f.values[0].src}if(c){if(i===null){i=c}else{if(i!==c){this._foundError(l,"Please select either dataset or dataset list fields for all batch mode fields.");return false}}}if(m===-1){m=g}else{if(m!==g){this._foundError(l,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+g+"</b> selection(s) while a previous field contains <b>"+m+"</b>.");return false}}}}return true},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org