1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0929371e5023/ Changeset: 0929371e5023 User: guerler Date: 2014-12-12 22:26:50+00:00 Summary: ToolForm: Update error handling Affected #: 10 files diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d client/galaxy/scripts/mvc/tools/tools-form.js --- a/client/galaxy/scripts/mvc/tools/tools-form.js +++ b/client/galaxy/scripts/mvc/tools/tools-form.js @@ -491,6 +491,32 @@ message : options.message }); } + + // show errors + if (options.errors) { + this.tree.finalize(); + var error_messages = this.tree.matchResponse(options.errors); + for (var input_id in error_messages) { + this._foundError(input_id, error_messages[input_id], true); + } + } + }, + + /** Highlight and scroll to error + */ + _foundError: function (input_id, message, silent) { + // get input field + var input_element = this.element_list[input_id]; + + // mark error + input_element.error(message || 'Please verify this parameter.'); + + // scroll to first input element + if (!silent) { + $(this.container).animate({ + scrollTop: input_element.$el.offset().top - 20 + }, 500); + } } }); diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d 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 @@ -51,7 +51,7 @@ if (response && response.message && response.message.data) { var error_messages = self.app.tree.matchResponse(response.message.data); for (var input_id in error_messages) { - self._foundError(input_id, error_messages[input_id]); + self.app._foundError(input_id, error_messages[input_id]); break; } } else { @@ -71,21 +71,6 @@ }); }, - /** Highlight and scroll to error - */ - _foundError: function (input_id, message) { - // get input field - var input_element = this.app.element_list[input_id]; - - // mark error - input_element.error(message || 'Please verify this parameter.'); - - // scroll to first input element - $(this.app.container).animate({ - scrollTop: input_element.$el.offset().top - 20 - }, 500); - }, - /** Validate job definition */ _validation: function(job_def) { @@ -114,7 +99,7 @@ // validate non-optional fields if (!input_def.optional && input_field.validate && !input_field.validate()) { - this._foundError(input_id); + this.app._foundError(input_id); return false; } @@ -135,7 +120,7 @@ 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.'); + this.app._foundError(input_id, 'Please select either dataset or dataset list fields for all batch mode fields.'); return false; } } @@ -146,7 +131,7 @@ batch_n = n; } else { 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>.'); + this.app._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 b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d client/galaxy/scripts/mvc/tools/tools-tree.js --- a/client/galaxy/scripts/mvc/tools/tools-tree.js +++ b/client/galaxy/scripts/mvc/tools/tools-tree.js @@ -201,7 +201,7 @@ } break; default: - var input_id = self.app.tree.job_ids[index]; + var input_id = self.job_ids[index]; if (input_id) { callback(input_id, node); } @@ -228,7 +228,7 @@ // search throughout response function search (id, head) { if (typeof head === 'string') { - var input_id = self.app.tree.job_ids[id]; + var input_id = self.job_ids[id]; if (input_id) { result[input_id] = head; } diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d lib/galaxy/webapps/galaxy/api/tools.py --- a/lib/galaxy/webapps/galaxy/api/tools.py +++ b/lib/galaxy/webapps/galaxy/api/tools.py @@ -610,14 +610,12 @@ return [value, error] # populates state with incoming url parameters - def populate_state(trans, inputs, state, incoming, prefix="", context=None ): - errors = dict() + def populate_state(trans, inputs, state, errors, incoming, prefix="", context=None ): context = ExpressionContext(state, context) for input in inputs.itervalues(): key = prefix + input.name if input.type == 'repeat': group_state = state[input.name] - group_errors = [] rep_index = 0 del group_state[:] while True: @@ -629,12 +627,7 @@ new_state['__index__'] = rep_index initialize_state(trans, input.inputs, new_state, context) group_state.append(new_state) - group_errors.append({}) - rep_errors = populate_state(trans, input.inputs, new_state, incoming, prefix=rep_name + "|", context=context) - if rep_errors: - group_errors[rep_index].update( rep_errors ) - else: - group_errors[-1] = { '__index__': 'Cannot add repeat (max size=%i).' % input.max } + populate_state(trans, input.inputs, new_state, errors, incoming, prefix=rep_name + "|", context=context) rep_index += 1 elif input.type == 'conditional': group_state = state[input.name] @@ -643,26 +636,23 @@ default_value = incoming.get(test_param_key, group_state.get(input.test_param.name, None)) value, error = check_state(trans, input.test_param, default_value, context) if error: - errors[input.name] = [error] + errors[test_param_key] = error else: current_case = input.get_current_case(value, trans) group_state = state[input.name] = {} initialize_state(trans, input.cases[current_case].inputs, group_state, context) - group_errors = populate_state( trans, input.cases[current_case].inputs, group_state, incoming, prefix=group_prefix, context=context) - if group_errors: - errors[input.name] = group_errors + populate_state( trans, input.cases[current_case].inputs, group_state, errors, incoming, prefix=group_prefix, context=context) group_state['__current_case__'] = current_case group_state[input.test_param.name] = value else: default_value = incoming.get(key, state.get(input.name, None)) value, error = check_state(trans, input, default_value, context) if error: - errors[input.name] = error + errors[key] = error state[input.name] = value - return errors # builds tool model including all attributes - def iterate(group_inputs, inputs, tool_state, errors, other_values=None): + def iterate(group_inputs, inputs, tool_state, other_values=None): other_values = ExpressionContext( tool_state, other_values ) for input_index, input in enumerate( inputs.itervalues() ): # create model dictionary @@ -678,8 +668,7 @@ group_cache = group_inputs[input_index]['cache'] = {} for i in range( len( group_state ) ): group_cache[i] = {} - group_errors = errors[input.name][i] if input.name in errors else dict() - iterate( group_cache[i], input.inputs, group_state[i], group_errors, other_values ) + iterate( group_cache[i], input.inputs, group_state[i], other_values ) elif input.type == 'conditional': try: test_param = group_inputs[input_index]['test_param'] @@ -687,8 +676,7 @@ except Exception: pass i = group_state['__current_case__'] - group_errors = errors.get( input.name, {} ) - iterate(group_inputs[input_index]['cases'][i]['inputs'], input.cases[i].inputs, group_state, group_errors, other_values) + iterate(group_inputs[input_index]['cases'][i]['inputs'], input.cases[i].inputs, group_state, other_values) else: # create input dictionary, try to pass other_values if to_dict function supports it e.g. dynamic options try: @@ -712,15 +700,16 @@ # create tool state state_inputs = {} + state_errors = {} initialize_state(trans, tool.inputs, state_inputs) - errors = populate_state(trans, tool.inputs, state_inputs, params.__dict__) + populate_state(trans, tool.inputs, state_inputs, state_errors, params.__dict__) # create basic tool model tool_model = tool.to_dict(trans) tool_model['inputs'] = {} # build tool model - iterate(tool_model['inputs'], tool.inputs, state_inputs, errors, '') + iterate(tool_model['inputs'], tool.inputs, state_inputs, '') # load tool help tool_help = '' @@ -757,7 +746,8 @@ 'biostar_url' : trans.app.config.biostar_url, 'message' : tool_message, 'versions' : tool_versions, - 'requirements' : tool_requirements + 'requirements' : tool_requirements, + 'errors' : state_errors }) # check for errors diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d static/scripts/mvc/tools/tools-form.js --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -491,6 +491,32 @@ message : options.message }); } + + // show errors + if (options.errors) { + this.tree.finalize(); + var error_messages = this.tree.matchResponse(options.errors); + for (var input_id in error_messages) { + this._foundError(input_id, error_messages[input_id], true); + } + } + }, + + /** Highlight and scroll to error + */ + _foundError: function (input_id, message, silent) { + // get input field + var input_element = this.element_list[input_id]; + + // mark error + input_element.error(message || 'Please verify this parameter.'); + + // scroll to first input element + if (!silent) { + $(this.container).animate({ + scrollTop: input_element.$el.offset().top - 20 + }, 500); + } } }); diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d static/scripts/mvc/tools/tools-jobs.js --- a/static/scripts/mvc/tools/tools-jobs.js +++ b/static/scripts/mvc/tools/tools-jobs.js @@ -51,7 +51,7 @@ if (response && response.message && response.message.data) { var error_messages = self.app.tree.matchResponse(response.message.data); for (var input_id in error_messages) { - self._foundError(input_id, error_messages[input_id]); + self.app._foundError(input_id, error_messages[input_id]); break; } } else { @@ -71,21 +71,6 @@ }); }, - /** Highlight and scroll to error - */ - _foundError: function (input_id, message) { - // get input field - var input_element = this.app.element_list[input_id]; - - // mark error - input_element.error(message || 'Please verify this parameter.'); - - // scroll to first input element - $(this.app.container).animate({ - scrollTop: input_element.$el.offset().top - 20 - }, 500); - }, - /** Validate job definition */ _validation: function(job_def) { @@ -114,7 +99,7 @@ // validate non-optional fields if (!input_def.optional && input_field.validate && !input_field.validate()) { - this._foundError(input_id); + this.app._foundError(input_id); return false; } @@ -135,7 +120,7 @@ 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.'); + this.app._foundError(input_id, 'Please select either dataset or dataset list fields for all batch mode fields.'); return false; } } @@ -146,7 +131,7 @@ batch_n = n; } else { 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>.'); + this.app._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 b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d static/scripts/mvc/tools/tools-tree.js --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -201,7 +201,7 @@ } break; default: - var input_id = self.app.tree.job_ids[index]; + var input_id = self.job_ids[index]; if (input_id) { callback(input_id, node); } @@ -228,7 +228,7 @@ // search throughout response function search (id, head) { if (typeof head === 'string') { - var input_id = self.app.tree.job_ids[id]; + var input_id = self.job_ids[id]; if (input_id) { result[input_id] = head; } diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d static/scripts/packed/mvc/tools/tools-form.js --- a/static/scripts/packed/mvc/tools/tools-form.js +++ b/static/scripts/packed/mvc/tools/tools-form.js @@ -1,1 +1,1 @@ -define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,j,h,m,k,a,e,d,f,l,c,g){var b=Backbone.View.extend({container:"body",initialize:function(o){console.debug(o);var n=this;var p=parent.Galaxy;if(p&&p.modal){this.modal=p.modal}else{this.modal=new m.Modal.View()}if(p&&p.currUser){this.is_admin=p.currUser.get("is_admin")}else{this.is_admin=false}this.options=o;this.deferred=new j();this.setElement("<div/>");$(this.container).append(this.$el);this._buildForm()},reciept:function(n){$(this.container).empty();$(this.container).append(n)},reset:function(){for(var n in this.element_list){this.element_list[n].reset()}},rebuild:function(){this.tree.refresh();console.debug("tools-form::rebuild() - Rebuilding data structures.")},refresh:function(){if(this.is_dynamic){var n=this;this.deferred.reset();this.deferred.execute(function(){n._updateModel()})}},_buildModel:function(){var n=this;var o=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){o+="job_id="+this.options.job_id}else{if(this.options.dataset_id){o+="dataset_id="+this.options.dataset_id}else{o+="tool_version="+this.options.version+"&";var q=top.location.href;var r=q.indexOf("?");if(q.indexOf("tool_id=")!=-1&&r!==-1){o+=q.slice(r+1)}}}var p=this.deferred.register();i.request({type:"GET",url:o,success:function(s){n.options=s;n._buildForm();n.message.update({status:"success",message:"Now you are using '"+n.options.name+"' version "+n.options.version+".",persistent:false});n.deferred.done(p);console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(s)},error:function(s){n.deferred.done(p);console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(s);var t=s.error||"Uncaught error.";n.modal.show({title:"Tool cannot be executed",body:t,buttons:{Close:function(){n.modal.hide()}}})}})},_updateModel:function(){var n=this;var o=this.tree.finalize({data:function(s){if(s.values.length>0&&s.values[0]&&s.values[0].src==="hda"){return n.content.get({id:s.values[0].id,src:"hda"}).id_uncoded}return null}});console.debug("tools-form::_refreshForm() - Refreshing states.");console.debug(o);function r(v){for(var t in n.input_list){var u=n.field_list[t];var s=n.input_list[t];if(s.is_dynamic&&u.wait&&u.unwait){if(v){u.wait()}else{u.unwait()}}}}r(true);var q=this.deferred.register();var p=galaxy_config.root+"api/tools/"+this.options.id+"/build?tool_version="+this.options.version;i.request({type:"GET",url:p,data:o,success:function(s){n._updateForm(s);r(false);n.deferred.done(q);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(s)},error:function(s){n.deferred.done(q);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(s)}})},_updateForm:function(n){var o=this;this.tree.matchModel(n,function(q,u){var p=o.input_list[q];if(p&&p.options){if(!_.isEqual(p.options,u.options)){p.options=u.options;var v=o.field_list[q];if(v.update){var t=[];if((["data","data_collection","drill_down"]).indexOf(p.type)!=-1){t=p.options}else{for(var s in u.options){var r=u.options[s];if(r.length>2){t.push({label:r[0],value:r[1]})}}}v.update(t);v.trigger("change");console.debug("Updating options for "+q)}}}})},_buildForm:function(){var x=this;this.field_list={};this.input_list={};this.element_list={};this.tree=new c(this);this.job_handler=new g(this);this.content=new f(this);var y=this.options;this.message=new m.Message();var n="This tool requires ";for(var r in y.requirements){var w=y.requirements[r];n+=w.name;if(w.version){n+=" (Version "+w.version+")"}if(r<y.requirements.length-2){n+=", "}if(r==y.requirements.length-2){n+=" and "}}n+=".";var t=new m.ButtonIcon({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;x.message.update({persistent:true,message:n,status:"warning"})}else{this.visible=false;x.message.update({message:""})}}});if(!y.requirements||y.requirements.length==0){t.$el.hide()}var p=new m.ButtonMenu({icon:"fa-cubes",title:"Versions",tooltip:"Select another tool version"});if(y.versions&&y.versions.length>1){for(var r in y.versions){var u=y.versions[r];if(u!=y.version){p.addMenu({title:"Switch to "+u,version:u,icon:"fa-cube",onclick:function(){y.id=y.id.replace(y.version,this.version);y.version=this.version;x.deferred.reset();x.deferred.execute(function(){x._buildModel()})}})}}}else{p.$el.hide()}var s=new m.ButtonMenu({icon:"fa-gear",title:"Options",tooltip:"View available options"});if(y.biostar_url){s.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(y.biostar_url+"/p/new/post/")}});s.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(y.biostar_url+"/t/"+y.id+"/")}})}s.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+y.id)}});if(this.is_admin){s.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+y.id+"/download"}})}this.section=new l.View(x,{inputs:y.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+y.name+"</b> "+y.description+" (Version "+y.version+")",cls:"ui-portlet-slim",operations:{requirements:t,menu:s,versions:p},buttons:{execute:new m.Button({icon:"fa-check",tooltip:"Execute: "+y.name,title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){x.job_handler.submit()}})}});this.$el.empty();this.$el.append(this.portlet.$el);if(y.help!=""){this.$el.append(d.help(y.help))}if(y.citations){var v=$("<div/>");var o=new k.ToolCitationCollection();o.tool_id=y.id;var q=new a.CitationListView({el:v,collection:o});q.render();o.fetch();this.$el.append(v)}this.portlet.append(this.message.$el,true);this.portlet.append(this.section.$el);this.rebuild();if(y.message){this.message.update({persistent:true,status:"warning",message:y.message})}}});return{View:b}}); \ No newline at end of file +define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,j,h,m,k,a,e,d,f,l,c,g){var b=Backbone.View.extend({container:"body",initialize:function(o){console.debug(o);var n=this;var p=parent.Galaxy;if(p&&p.modal){this.modal=p.modal}else{this.modal=new m.Modal.View()}if(p&&p.currUser){this.is_admin=p.currUser.get("is_admin")}else{this.is_admin=false}this.options=o;this.deferred=new j();this.setElement("<div/>");$(this.container).append(this.$el);this._buildForm()},reciept:function(n){$(this.container).empty();$(this.container).append(n)},reset:function(){for(var n in this.element_list){this.element_list[n].reset()}},rebuild:function(){this.tree.refresh();console.debug("tools-form::rebuild() - Rebuilding data structures.")},refresh:function(){if(this.is_dynamic){var n=this;this.deferred.reset();this.deferred.execute(function(){n._updateModel()})}},_buildModel:function(){var n=this;var o=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){o+="job_id="+this.options.job_id}else{if(this.options.dataset_id){o+="dataset_id="+this.options.dataset_id}else{o+="tool_version="+this.options.version+"&";var q=top.location.href;var r=q.indexOf("?");if(q.indexOf("tool_id=")!=-1&&r!==-1){o+=q.slice(r+1)}}}var p=this.deferred.register();i.request({type:"GET",url:o,success:function(s){n.options=s;n._buildForm();n.message.update({status:"success",message:"Now you are using '"+n.options.name+"' version "+n.options.version+".",persistent:false});n.deferred.done(p);console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(s)},error:function(s){n.deferred.done(p);console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(s);var t=s.error||"Uncaught error.";n.modal.show({title:"Tool cannot be executed",body:t,buttons:{Close:function(){n.modal.hide()}}})}})},_updateModel:function(){var n=this;var o=this.tree.finalize({data:function(s){if(s.values.length>0&&s.values[0]&&s.values[0].src==="hda"){return n.content.get({id:s.values[0].id,src:"hda"}).id_uncoded}return null}});console.debug("tools-form::_refreshForm() - Refreshing states.");console.debug(o);function r(v){for(var t in n.input_list){var u=n.field_list[t];var s=n.input_list[t];if(s.is_dynamic&&u.wait&&u.unwait){if(v){u.wait()}else{u.unwait()}}}}r(true);var q=this.deferred.register();var p=galaxy_config.root+"api/tools/"+this.options.id+"/build?tool_version="+this.options.version;i.request({type:"GET",url:p,data:o,success:function(s){n._updateForm(s);r(false);n.deferred.done(q);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(s)},error:function(s){n.deferred.done(q);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(s)}})},_updateForm:function(n){var o=this;this.tree.matchModel(n,function(q,u){var p=o.input_list[q];if(p&&p.options){if(!_.isEqual(p.options,u.options)){p.options=u.options;var v=o.field_list[q];if(v.update){var t=[];if((["data","data_collection","drill_down"]).indexOf(p.type)!=-1){t=p.options}else{for(var s in u.options){var r=u.options[s];if(r.length>2){t.push({label:r[0],value:r[1]})}}}v.update(t);v.trigger("change");console.debug("Updating options for "+q)}}}})},_buildForm:function(){var z=this;this.field_list={};this.input_list={};this.element_list={};this.tree=new c(this);this.job_handler=new g(this);this.content=new f(this);var A=this.options;this.message=new m.Message();var n="This tool requires ";for(var r in A.requirements){var y=A.requirements[r];n+=y.name;if(y.version){n+=" (Version "+y.version+")"}if(r<A.requirements.length-2){n+=", "}if(r==A.requirements.length-2){n+=" and "}}n+=".";var t=new m.ButtonIcon({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;z.message.update({persistent:true,message:n,status:"warning"})}else{this.visible=false;z.message.update({message:""})}}});if(!A.requirements||A.requirements.length==0){t.$el.hide()}var p=new m.ButtonMenu({icon:"fa-cubes",title:"Versions",tooltip:"Select another tool version"});if(A.versions&&A.versions.length>1){for(var r in A.versions){var v=A.versions[r];if(v!=A.version){p.addMenu({title:"Switch to "+v,version:v,icon:"fa-cube",onclick:function(){A.id=A.id.replace(A.version,this.version);A.version=this.version;z.deferred.reset();z.deferred.execute(function(){z._buildModel()})}})}}}else{p.$el.hide()}var s=new m.ButtonMenu({icon:"fa-gear",title:"Options",tooltip:"View available options"});if(A.biostar_url){s.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(A.biostar_url+"/p/new/post/")}});s.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(A.biostar_url+"/t/"+A.id+"/")}})}s.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+A.id)}});if(this.is_admin){s.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+A.id+"/download"}})}this.section=new l.View(z,{inputs:A.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+A.name+"</b> "+A.description+" (Version "+A.version+")",cls:"ui-portlet-slim",operations:{requirements:t,menu:s,versions:p},buttons:{execute:new m.Button({icon:"fa-check",tooltip:"Execute: "+A.name,title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){z.job_handler.submit()}})}});this.$el.empty();this.$el.append(this.portlet.$el);if(A.help!=""){this.$el.append(d.help(A.help))}if(A.citations){var x=$("<div/>");var o=new k.ToolCitationCollection();o.tool_id=A.id;var q=new a.CitationListView({el:x,collection:o});q.render();o.fetch();this.$el.append(x)}this.portlet.append(this.message.$el,true);this.portlet.append(this.section.$el);this.rebuild();if(A.message){this.message.update({persistent:true,status:"warning",message:A.message})}if(A.errors){this.tree.finalize();var w=this.tree.matchResponse(A.errors);for(var u in w){this._foundError(u,w[u],true)}}},_foundError:function(o,p,n){var q=this.element_list[o];q.error(p||"Please verify this parameter.");if(!n){$(this.container).animate({scrollTop:q.$el.offset().top-20},500)}}});return{View:b}}); \ No newline at end of file diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d 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(c){this.app=c},submit:function(){var c=this;var d={tool_id:this.app.options.id,tool_version:this.app.options.version,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.reciept(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(!l||!j||!e){console.debug("tools-jobs::_validation - Retrieving input objects failed.");continue}if(!j.optional&&e.validate&&!e.validate()){this._foundError(l);return false}if(f&&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 +define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(c){this.app=c},submit:function(){var c=this;var d={tool_id:this.app.options.id,tool_version:this.app.options.version,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.reciept(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.app._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()}}})}}})},_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(!l||!j||!e){console.debug("tools-jobs::_validation - Retrieving input objects failed.");continue}if(!j.optional&&e.validate&&!e.validate()){this.app._foundError(l);return false}if(f&&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.app._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.app._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 diff -r b1f28d8e2f39990d3a8668e0165797e2ecf3d8cf -r 0929371e50230f063aa152007143e65162ef324d static/scripts/packed/mvc/tools/tools-tree.js --- a/static/scripts/packed/mvc/tools/tools-tree.js +++ b/static/scripts/packed/mvc/tools/tools-tree.js @@ -1,1 +1,1 @@ -define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("<div/>");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();if(d[q.test_param.type]){r=d[q.test_param.type](r)}c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){if(q.optional&&p.validate&&!p.validate()){r=null}c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.app.tree.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(k,h){if(typeof h==="string"){var f=b.app.tree.job_ids[k];if(f){a[f]=h}}else{for(var g in h){var e=g;if(k!==""){var j="|";if(h instanceof Array){j="_"}e=k+j+e}d(e,h[g])}}}d("",c);return a},references:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('<div id="'+h+'"/>');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})}); \ No newline at end of file +define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("<div/>");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();if(d[q.test_param.type]){r=d[q.test_param.type](r)}c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){if(q.optional&&p.validate&&!p.validate()){r=null}c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(k,h){if(typeof h==="string"){var f=b.job_ids[k];if(f){a[f]=h}}else{for(var g in h){var e=g;if(k!==""){var j="|";if(h instanceof Array){j="_"}e=k+j+e}d(e,h[g])}}}d("",c);return a},references:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('<div id="'+h+'"/>');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})}})}); \ 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.