commit/galaxy-central: guerler: Parameters: Fix initial value for drill downs, Workflow/ToolForm: Move module building to api
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/de8fa2d2312e/ Changeset: de8fa2d2312e User: guerler Date: 2015-02-09 04:49:24+00:00 Summary: Parameters: Fix initial value for drill downs, Workflow/ToolForm: Move module building to api Affected #: 14 files diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 client/galaxy/scripts/mvc/tools/tools-form-workflow.js --- a/client/galaxy/scripts/mvc/tools/tools-form-workflow.js +++ b/client/galaxy/scripts/mvc/tools/tools-form-workflow.js @@ -275,10 +275,16 @@ /** Request a new model for an already created tool form and updates the form inputs */ _updateModel: function() { + // link self + var self = this; + // create the request dictionary - var self = this; - var current_state = this.tree.finalize(); - + var current_state = { + tool_id : this.options.id, + tool_version : this.options.version, + inputs : this.tree.finalize() + } + // log tool state console.debug('tools-form-workflow::_refreshForm() - Refreshing states.'); console.debug(current_state); @@ -287,11 +293,11 @@ var process_id = this.deferred.register(); // build model url for request - var model_url = galaxy_config.root + 'workflow/editor_form_post?tool_id=' + this.options.id + '&__is_dynamic__=False'; + var model_url = galaxy_config.root + 'api/workflows/build_module'; // post job Utils.request({ - type : 'GET', + type : 'POST', url : model_url, data : current_state, success : function(data) { diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 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 @@ -10,13 +10,13 @@ initialize: function(app) { this.app = app; }, - + /** Convert dictionary representation into tool api specific flat dictionary format. */ finalize: function(patch) { // link this var self = this; - + // dictionary with api specific identifiers this.map_dict = {}; @@ -24,24 +24,24 @@ if (!this.app.section) { return {}; } - + // ensure that dictionary with patching functions exists patch = patch || {}; - + // dictionary formatted for job submission or tool form update var result_dict = {}; // prepare full dictionary var dict = {}; - + // fill dictionary from dom this._iterate(this.app.section.$el, dict); - + // add identifier and value to job definition function add(job_input_id, input_id, input_value) { // add entry to result dictionary result_dict[job_input_id] = input_value; - + // backup id mapping self.map_dict[job_input_id] = input_id; }; @@ -53,21 +53,21 @@ if (node.input) { // get node var input = node.input; - + // create identifier var job_input_id = identifier; if (identifier != '') { job_input_id += '|'; } job_input_id += input.name; - + // process input type switch (input.type) { // handle repeats case 'repeat': // section identifier var section_label = 'section-'; - + // collect repeat block identifiers var block_indices = []; var block_prefix = null; @@ -81,10 +81,10 @@ } } } - + // sort repeat blocks block_indices.sort(function(a,b) { return a - b; }); - + // add to response dictionary in created order var index = 0; for (var i in block_indices) { @@ -98,10 +98,10 @@ if (patch[input.test_param.type]) { value = patch[input.test_param.type](value); } - + // add conditional value add (job_input_id + '|' + input.test_param.name, input.id, value); - + // identify selected case var selectedCase = self.matchCase(input, value); if (selectedCase != -1) { @@ -116,22 +116,17 @@ // get field var field = self.app.field_list[input.id]; if (field && field.value) { + // validate field value + var value = field.value(); + if (field.validate && !field.validate()) { + value = null; + } + // get and patch field value - var value = field.value(); if (patch[input.type]) { value = patch[input.type](value); } - // validate field value - if (field.skip) { - continue; - } - - // validate field value - if (field.validate && !field.validate()) { - value = null; - } - // ignore certain values if (input.ignore === undefined || (value !== null && input.ignore != value)) { // add value to submission @@ -149,20 +144,20 @@ } } } - + // start conversion convert('', dict); - + // return result return result_dict; }, - + /** Match job definition identifier to input element identifier */ match: function (job_input_id) { return this.map_dict && this.map_dict[job_input_id]; }, - + /** Match conditional values to selected cases */ matchCase: function(input, value) { @@ -174,27 +169,27 @@ value = input.test_param.falsevalue || 'false'; } } - + // find selected case for (var i in input.cases) { if (input.cases[i].value == value) { return i; } } - + // selected case not found return -1; }, - + /** Matches identifier from api model to input elements */ matchModel: function(model, callback) { // final result dictionary var result = {}; - + // link this var self = this; - + // search throughout response function search (id, head) { for (var i in head) { @@ -224,23 +219,23 @@ } } } - + // match all ids and return messages search('', model.inputs); // return matched results return result; }, - + /** Matches identifier from api response to input elements */ matchResponse: function(response) { // final result dictionary var result = {}; - + // link this var self = this; - + // search throughout response function search (id, head) { if (typeof head === 'string') { @@ -262,14 +257,14 @@ } } } - + // match all ids and return messages search('', response); - + // return matched results return result; }, - + /** Iterate through the tool form dom and map it to the dictionary. */ _iterate: function(parent, dict) { @@ -279,15 +274,15 @@ children.each(function() { // get child element var child = this; - + // get id var id = $(child).attr('id'); - + // create new branch if ($(child).hasClass('section-row')) { // create sub dictionary dict[id] = {}; - + // add input element if it exists var input = self.app.input_list[id]; if (input) { @@ -295,7 +290,7 @@ input : input } } - + // fill sub dictionary self._iterate(child, dict[id]); } else { diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2250,13 +2250,12 @@ return tool_dict - def to_json (self, trans, **kwd): + def to_json (self, trans, kwd={}, is_dynamic=True): """ Recursively creates a tool dictionary containing repeats, dynamic options and updated states. """ job_id = kwd.get('__job_id__', None) dataset_id = kwd.get('__dataset_id__', None) - is_dynamic = string_as_bool(kwd.get('__is_dynamic__', True)) # load job details if provided job = None diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1618,6 +1618,8 @@ return UnvalidatedValue( None ) initial_values = [] recurse_options( initial_values, self.get_options( trans=trans, other_values=context ) ) + if len( initial_values ) == 0: + initial_values = None return initial_values def value_to_display_text( self, value, app ): diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 lib/galaxy/webapps/galaxy/api/tools.py --- a/lib/galaxy/webapps/galaxy/api/tools.py +++ b/lib/galaxy/webapps/galaxy/api/tools.py @@ -76,14 +76,10 @@ GET /api/tools/{tool_id}/build Returns a tool model including dynamic parameters and updated values, repeats block etc. """ - tool_id = urllib.unquote_plus( id ) tool_version = kwd.get( 'tool_version', None ) - tool = self.app.toolbox.get_tool( tool_id, tool_version ) - if not tool: - trans.response.status = 500 - return { 'error': 'Could not find tool with id \'%s\'' % tool_id } - return tool.to_json(trans, **kwd) - + tool = self._get_tool( id, tool_version=tool_version, user=trans.user ) + return tool.to_json(trans, kwd) + @_future_expose_api @web.require_admin def reload( self, trans, tool_id, **kwd ): diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -6,6 +6,8 @@ import uuid import logging +import copy +import urllib from sqlalchemy import desc, or_, and_ from galaxy import exceptions, util from galaxy.model.item_attrs import UsesAnnotations @@ -17,6 +19,7 @@ from galaxy.workflow.extract import extract_workflow from galaxy.workflow.run import invoke, queue_invoke from galaxy.workflow.run_request import build_workflow_run_config +from galaxy.workflow.modules import module_factory log = logging.getLogger(__name__) @@ -305,6 +308,52 @@ raise exceptions.RequestParameterInvalidException( message ) return self.workflow_contents_manager.workflow_to_dict( trans, stored_workflow, style="instance" ) + @expose_api + def build_module( self, trans, payload={}): + """ + POST /api/workflows/build_module + Builds module details including a tool model for the workflow editor. + """ + tool_id = payload.get( 'tool_id', None ) + tool_version = payload.get( 'tool_version', None ) + tool_inputs = payload.get( 'inputs', None ) + annotation = payload.get( 'annotation', '' ) + + # load tool + tool = self._get_tool( tool_id, tool_version=tool_version, user=trans.user ) + + # initialize module + trans.workflow_building_mode = True + module = module_factory.from_dict( trans, { + 'type' : 'tool', + 'tool_id' : tool.id, + 'tool_state' : None + } ) + + # create tool model and default tool state (if missing) + tool_model = module.tool.to_json(trans, tool_inputs, is_dynamic=False) + module.state.inputs = copy.deepcopy(tool_model['state_inputs']) + return { + 'tool_model' : tool_model, + 'tool_state' : module.get_state(), + 'data_inputs' : module.get_data_inputs(), + 'data_outputs' : module.get_data_outputs(), + 'tool_errors' : module.get_errors(), + 'form_html' : module.get_config_form(), + 'annotation' : annotation, + 'post_job_actions' : module.get_post_job_actions(tool_inputs) + } + + # + # -- Helper methods -- + # + def _get_tool( self, id, tool_version=None, user=None ): + id = urllib.unquote_plus( id ) + tool = self.app.toolbox.get_tool( id, tool_version ) + if not tool or not tool.allow_user_access( user ): + raise exceptions.ObjectNotFound("Could not find tool with id '%s'" % id) + return tool + def __api_import_new_workflow( self, trans, payload, **kwd ): data = payload['workflow'] diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -217,6 +217,7 @@ webapp.mapper.resource_with_deleted( 'user', 'users', path_prefix='/api' ) webapp.mapper.resource( 'genome', 'genomes', path_prefix='/api' ) webapp.mapper.resource( 'visualization', 'visualizations', path_prefix='/api' ) + webapp.mapper.connect( '/api/workflows/build_module', action='build_module', controller="workflows" ) webapp.mapper.resource( 'workflow', 'workflows', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'history', 'histories', path_prefix='/api' ) webapp.mapper.connect( '/api/histories/{history_id}/citations', action='citations', controller="histories" ) diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -609,7 +609,6 @@ This is used for the form shown in the right pane when a node is selected. """ - tool_state = incoming.pop('tool_state', None) trans.workflow_building_mode = True module = module_factory.from_dict( trans, { @@ -617,22 +616,7 @@ 'tool_id': tool_id, 'tool_state': tool_state } ) - - # create tool model and default tool state (if missing) - if type == 'tool' and not tool_state: - tool_model = module.tool.to_json(trans, **incoming) - module.state.inputs = copy.deepcopy(tool_model['state_inputs']) - return { - 'tool_model': tool_model, - 'tool_state': module.get_state(), - 'data_inputs': module.get_data_inputs(), - 'data_outputs': module.get_data_outputs(), - 'tool_errors': module.get_errors(), - 'form_html': module.get_config_form(), - 'annotation': annotation, - 'post_job_actions': module.get_post_job_actions(incoming) - } - + # update module state module.update_state( incoming ) @@ -669,7 +653,8 @@ module = module_factory.new( trans, type, **kwargs ) tool_model = None if type == 'tool': - tool_model = module.tool.to_json(trans) + tool_model = module.tool.to_json(trans, is_dynamic=False) + module.state.inputs = copy.deepcopy(tool_model['state_inputs']) return { 'type': module.type, 'name': module.get_name(), diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 static/scripts/mvc/tools/tools-form-workflow.js --- a/static/scripts/mvc/tools/tools-form-workflow.js +++ b/static/scripts/mvc/tools/tools-form-workflow.js @@ -275,10 +275,16 @@ /** Request a new model for an already created tool form and updates the form inputs */ _updateModel: function() { + // link self + var self = this; + // create the request dictionary - var self = this; - var current_state = this.tree.finalize(); - + var current_state = { + tool_id : this.options.id, + tool_version : this.options.version, + inputs : this.tree.finalize() + } + // log tool state console.debug('tools-form-workflow::_refreshForm() - Refreshing states.'); console.debug(current_state); @@ -287,11 +293,11 @@ var process_id = this.deferred.register(); // build model url for request - var model_url = galaxy_config.root + 'workflow/editor_form_post?tool_id=' + this.options.id + '&__is_dynamic__=False'; + var model_url = galaxy_config.root + 'api/workflows/build_module'; // post job Utils.request({ - type : 'GET', + type : 'POST', url : model_url, data : current_state, success : function(data) { diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 static/scripts/mvc/tools/tools-tree.js --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -10,13 +10,13 @@ initialize: function(app) { this.app = app; }, - + /** Convert dictionary representation into tool api specific flat dictionary format. */ finalize: function(patch) { // link this var self = this; - + // dictionary with api specific identifiers this.map_dict = {}; @@ -24,24 +24,24 @@ if (!this.app.section) { return {}; } - + // ensure that dictionary with patching functions exists patch = patch || {}; - + // dictionary formatted for job submission or tool form update var result_dict = {}; // prepare full dictionary var dict = {}; - + // fill dictionary from dom this._iterate(this.app.section.$el, dict); - + // add identifier and value to job definition function add(job_input_id, input_id, input_value) { // add entry to result dictionary result_dict[job_input_id] = input_value; - + // backup id mapping self.map_dict[job_input_id] = input_id; }; @@ -53,21 +53,21 @@ if (node.input) { // get node var input = node.input; - + // create identifier var job_input_id = identifier; if (identifier != '') { job_input_id += '|'; } job_input_id += input.name; - + // process input type switch (input.type) { // handle repeats case 'repeat': // section identifier var section_label = 'section-'; - + // collect repeat block identifiers var block_indices = []; var block_prefix = null; @@ -81,10 +81,10 @@ } } } - + // sort repeat blocks block_indices.sort(function(a,b) { return a - b; }); - + // add to response dictionary in created order var index = 0; for (var i in block_indices) { @@ -98,10 +98,10 @@ if (patch[input.test_param.type]) { value = patch[input.test_param.type](value); } - + // add conditional value add (job_input_id + '|' + input.test_param.name, input.id, value); - + // identify selected case var selectedCase = self.matchCase(input, value); if (selectedCase != -1) { @@ -116,22 +116,17 @@ // get field var field = self.app.field_list[input.id]; if (field && field.value) { + // validate field value + var value = field.value(); + if (field.validate && !field.validate()) { + value = null; + } + // get and patch field value - var value = field.value(); if (patch[input.type]) { value = patch[input.type](value); } - // validate field value - if (field.skip) { - continue; - } - - // validate field value - if (field.validate && !field.validate()) { - value = null; - } - // ignore certain values if (input.ignore === undefined || (value !== null && input.ignore != value)) { // add value to submission @@ -149,20 +144,20 @@ } } } - + // start conversion convert('', dict); - + // return result return result_dict; }, - + /** Match job definition identifier to input element identifier */ match: function (job_input_id) { return this.map_dict && this.map_dict[job_input_id]; }, - + /** Match conditional values to selected cases */ matchCase: function(input, value) { @@ -174,27 +169,27 @@ value = input.test_param.falsevalue || 'false'; } } - + // find selected case for (var i in input.cases) { if (input.cases[i].value == value) { return i; } } - + // selected case not found return -1; }, - + /** Matches identifier from api model to input elements */ matchModel: function(model, callback) { // final result dictionary var result = {}; - + // link this var self = this; - + // search throughout response function search (id, head) { for (var i in head) { @@ -224,23 +219,23 @@ } } } - + // match all ids and return messages search('', model.inputs); // return matched results return result; }, - + /** Matches identifier from api response to input elements */ matchResponse: function(response) { // final result dictionary var result = {}; - + // link this var self = this; - + // search throughout response function search (id, head) { if (typeof head === 'string') { @@ -262,14 +257,14 @@ } } } - + // match all ids and return messages search('', response); - + // return matched results return result; }, - + /** Iterate through the tool form dom and map it to the dictionary. */ _iterate: function(parent, dict) { @@ -279,15 +274,15 @@ children.each(function() { // get child element var child = this; - + // get id var id = $(child).attr('id'); - + // create new branch if ($(child).hasClass('section-row')) { // create sub dictionary dict[id] = {}; - + // add input element if it exists var input = self.app.input_list[id]; if (input) { @@ -295,7 +290,7 @@ input : input } } - + // fill sub dictionary self._iterate(child, dict[id]); } else { diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 static/scripts/packed/mvc/tools/tools-form-workflow.js --- a/static/scripts/packed/mvc/tools/tools-form-workflow.js +++ b/static/scripts/packed/mvc/tools/tools-form-workflow.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/tools/tools-form-base"],function(b,a){var c=a.extend({initialize:function(e){this.node=workflow.active_node;if(!this.node){console.debug("FAILED - tools-form-workflow:initialize() - Node not found in workflow.");return}this.post_job_actions=this.node.post_job_actions||{};this.options=e;this.options.text_enable="In Advance";this.options.text_disable="At Runtime";this.options.is_dynamic=false;this.options.narrow=true;this.options.initial_errors=true;this.options.cls_portlet="ui-portlet-narrow";b.deepeach(e.inputs,function(f){if(f.type){f.optional=(["data","data_hidden","hidden","drill_down","repeat","conditional"]).indexOf(f.type)==-1}});b.deepeach(e.inputs,function(f){if(f.type){if(f.type=="conditional"){f.test_param.optional=false}}});var d=this;b.get({url:galaxy_config.root+"api/datatypes",cache:true,success:function(f){d.datatypes=f;d._makeSections(e.inputs);a.prototype.initialize.call(d,e)}})},_makeSections:function(d){d[b.uuid()]={label:"Annotation / Notes",name:"annotation",type:"text",area:true,help:"Add an annotation or note for this step. It will be shown with the workflow.",value:this.node.annotation};var f=this.node.output_terminals&&Object.keys(this.node.output_terminals)[0];if(f){d[b.uuid()]={name:"pja__"+f+"__EmailAction",label:"Email notification",type:"boolean",value:String(Boolean(this.post_job_actions["EmailAction"+f])),ignore:"false",help:"An email notification will be send when the job has completed.",payload:{host:window.location.host}};d[b.uuid()]={name:"pja__"+f+"__DeleteIntermediatesAction",label:"Output cleanup",type:"boolean",value:String(Boolean(this.post_job_actions["DeleteIntermediatesAction"+f])),ignore:"false",help:"Delete intermediate outputs if they are not used as input for another job."};for(var e in this.node.output_terminals){d[b.uuid()]=this._makeSection(e)}}},_makeSection:function(h){var g=[];for(key in this.datatypes){g.push({0:this.datatypes[key],1:this.datatypes[key]})}g.sort(function(j,i){return j.label>i.label?1:j.label<i.label?-1:0});g.unshift({0:"Sequences",1:"Sequences"});g.unshift({0:"Roadmaps",1:"Roadmaps"});g.unshift({0:"Leave unchanged",1:""});var f={label:"Add Actions: '"+h+"'",type:"section",inputs:[{action:"RenameDatasetAction",argument:"newname",label:"Rename dataset",type:"text",value:"",ignore:"",help:'This action will rename the result dataset. Click <a href="https://wiki.galaxyproject.org/Learn/AdvancedWorkflow/Variables">here</a> for more information.'},{action:"ChangeDatatypeAction",argument:"newtype",label:"Change datatype",type:"select",ignore:"",options:g,help:"This action will change the datatype of the output to the indicated value."},{action:"TagDatasetAction",argument:"tags",label:"Tags",type:"text",value:"",ignore:"",help:"This action will set tags for the dataset."},{label:"Assign columns",type:"section",inputs:[{action:"ColumnSetAction",argument:"chromCol",label:"Chrom column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"startCol",label:"Start column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"endCol",label:"End column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"strandCol",label:"Strand column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"nameCol",label:"Name column",type:"integer",value:"",ignore:""}],help:"This action will set column assignments in the output dataset. Blank fields are ignored."}]};var d=this;function e(n,o){o=o||[];o.push(n);for(var m in n.inputs){var k=n.inputs[m];if(k.action){k.name="pja__"+h+"__"+k.action;if(k.argument){k.name+="__"+k.argument}if(k.payload){for(var s in k.payload){var q=k.payload[s];k.payload[k.name+"__"+s]=q;delete q}}var r=d.post_job_actions[k.action+h];if(r){for(var l in o){o[l].expand=true}if(k.argument){k.value=r.action_arguments&&r.action_arguments[k.argument]||k.value}else{k.value="true"}}}if(k.inputs){e(k,o.slice(0))}}}e(f);return f},_buildModel:function(){Galaxy.modal.show({title:"Coming soon...",body:"This feature has not been implemented yet.",buttons:{Close:function(){Galaxy.modal.hide()}}})},_updateModel:function(){var d=this;var e=this.tree.finalize();console.debug("tools-form-workflow::_refreshForm() - Refreshing states.");console.debug(e);var g=this.deferred.register();var f=galaxy_config.root+"workflow/editor_form_post?tool_id="+this.options.id+"&__is_dynamic__=False";b.request({type:"GET",url:f,data:e,success:function(h){d.node.update_field_data(h);d._errors(h&&h.tool_model);d.deferred.done(g);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(h)},error:function(h){d.deferred.done(g);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(h)}})}});return{View:c}}); \ No newline at end of file +define(["utils/utils","mvc/tools/tools-form-base"],function(b,a){var c=a.extend({initialize:function(e){this.node=workflow.active_node;if(!this.node){console.debug("FAILED - tools-form-workflow:initialize() - Node not found in workflow.");return}this.post_job_actions=this.node.post_job_actions||{};this.options=e;this.options.text_enable="In Advance";this.options.text_disable="At Runtime";this.options.is_dynamic=false;this.options.narrow=true;this.options.initial_errors=true;this.options.cls_portlet="ui-portlet-narrow";b.deepeach(e.inputs,function(f){if(f.type){f.optional=(["data","data_hidden","hidden","drill_down","repeat","conditional"]).indexOf(f.type)==-1}});b.deepeach(e.inputs,function(f){if(f.type){if(f.type=="conditional"){f.test_param.optional=false}}});var d=this;b.get({url:galaxy_config.root+"api/datatypes",cache:true,success:function(f){d.datatypes=f;d._makeSections(e.inputs);a.prototype.initialize.call(d,e)}})},_makeSections:function(d){d[b.uuid()]={label:"Annotation / Notes",name:"annotation",type:"text",area:true,help:"Add an annotation or note for this step. It will be shown with the workflow.",value:this.node.annotation};var f=this.node.output_terminals&&Object.keys(this.node.output_terminals)[0];if(f){d[b.uuid()]={name:"pja__"+f+"__EmailAction",label:"Email notification",type:"boolean",value:String(Boolean(this.post_job_actions["EmailAction"+f])),ignore:"false",help:"An email notification will be send when the job has completed.",payload:{host:window.location.host}};d[b.uuid()]={name:"pja__"+f+"__DeleteIntermediatesAction",label:"Output cleanup",type:"boolean",value:String(Boolean(this.post_job_actions["DeleteIntermediatesAction"+f])),ignore:"false",help:"Delete intermediate outputs if they are not used as input for another job."};for(var e in this.node.output_terminals){d[b.uuid()]=this._makeSection(e)}}},_makeSection:function(h){var g=[];for(key in this.datatypes){g.push({0:this.datatypes[key],1:this.datatypes[key]})}g.sort(function(j,i){return j.label>i.label?1:j.label<i.label?-1:0});g.unshift({0:"Sequences",1:"Sequences"});g.unshift({0:"Roadmaps",1:"Roadmaps"});g.unshift({0:"Leave unchanged",1:""});var f={label:"Add Actions: '"+h+"'",type:"section",inputs:[{action:"RenameDatasetAction",argument:"newname",label:"Rename dataset",type:"text",value:"",ignore:"",help:'This action will rename the result dataset. Click <a href="https://wiki.galaxyproject.org/Learn/AdvancedWorkflow/Variables">here</a> for more information.'},{action:"ChangeDatatypeAction",argument:"newtype",label:"Change datatype",type:"select",ignore:"",options:g,help:"This action will change the datatype of the output to the indicated value."},{action:"TagDatasetAction",argument:"tags",label:"Tags",type:"text",value:"",ignore:"",help:"This action will set tags for the dataset."},{label:"Assign columns",type:"section",inputs:[{action:"ColumnSetAction",argument:"chromCol",label:"Chrom column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"startCol",label:"Start column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"endCol",label:"End column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"strandCol",label:"Strand column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"nameCol",label:"Name column",type:"integer",value:"",ignore:""}],help:"This action will set column assignments in the output dataset. Blank fields are ignored."}]};var d=this;function e(n,o){o=o||[];o.push(n);for(var m in n.inputs){var k=n.inputs[m];if(k.action){k.name="pja__"+h+"__"+k.action;if(k.argument){k.name+="__"+k.argument}if(k.payload){for(var s in k.payload){var q=k.payload[s];k.payload[k.name+"__"+s]=q;delete q}}var r=d.post_job_actions[k.action+h];if(r){for(var l in o){o[l].expand=true}if(k.argument){k.value=r.action_arguments&&r.action_arguments[k.argument]||k.value}else{k.value="true"}}}if(k.inputs){e(k,o.slice(0))}}}e(f);return f},_buildModel:function(){Galaxy.modal.show({title:"Coming soon...",body:"This feature has not been implemented yet.",buttons:{Close:function(){Galaxy.modal.hide()}}})},_updateModel:function(){var d=this;var e={tool_id:this.options.id,tool_version:this.options.version,inputs:this.tree.finalize()};console.debug("tools-form-workflow::_refreshForm() - Refreshing states.");console.debug(e);var g=this.deferred.register();var f=galaxy_config.root+"api/workflows/build_module";b.request({type:"POST",url:f,data:e,success:function(h){d.node.update_field_data(h);d._errors(h&&h.tool_model);d.deferred.done(g);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(h)},error:function(h){d.deferred.done(g);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(h)}})}});return{View:c}}); \ No newline at end of file diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 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(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(g[u.type]){v=g[u.type](v)}if(t.skip){continue}if(t.validate&&!t.validate()){v=null}if(u.ignore===undefined||(v!==null&&u.ignore!=v)){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})}); \ No newline at end of file +define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(t.validate&&!t.validate()){v=null}if(g[u.type]){v=g[u.type](v)}if(u.ignore===undefined||(v!==null&&u.ignore!=v)){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})}); \ No newline at end of file diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 templates/webapps/galaxy/tool_form.mako --- a/templates/webapps/galaxy/tool_form.mako +++ b/templates/webapps/galaxy/tool_form.mako @@ -10,7 +10,7 @@ ## This avoids making two separate requests since the classic form requires the mako anyway. params = dict(trans.request.params) params['__dataset_id__'] = params.get('id', None) - self.form_config = tool.to_json(trans, **params) + self.form_config = tool.to_json(trans, params) self.form_config.update({ 'id' : tool.id, 'job_id' : trans.security.encode_id( job.id ) if job else None, diff -r 28126538ef19e8dc9d5a5dede2ccf3080ccdf603 -r de8fa2d2312eaad8178fe9aa39a2278bae7da239 templates/webapps/galaxy/workflow/editor_tool_form.mako --- a/templates/webapps/galaxy/workflow/editor_tool_form.mako +++ b/templates/webapps/galaxy/workflow/editor_tool_form.mako @@ -6,11 +6,9 @@ ## TEMPORARY: create tool dictionary in mako while both tool forms are in use. ## This avoids making two separate requests since the classic form requires the mako anyway. from galaxy.tools.parameters import params_to_incoming - incoming = { - '__is_dynamic__' : False - } + incoming = {} params_to_incoming( incoming, tool.inputs, module.state.inputs, trans.app, to_html=False) - self.form_config = tool.to_json(trans, **incoming) + self.form_config = tool.to_json(trans, incoming, is_dynamic=False) self.form_config.update({ 'id' : tool.id, 'job_id' : trans.security.encode_id( job.id ) if job else None, 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