1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/34e643839cda/ Changeset: 34e643839cda User: guerler Date: 2014-10-10 03:48:59+00:00 Summary: ToolForm: Fix optional parameters Affected #: 17 files diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 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 @@ -1,10 +1,10 @@ /** This is the main class of the tool form plugin. It is referenced as 'app' in all lower level modules. */ -define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc', +define(['utils/utils', '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(Portlet, Ui, CitationModel, CitationView, + function(Utils, Portlet, Ui, CitationModel, CitationView, Tools, ToolTemplate, ToolContent, ToolSection, ToolTree, ToolJobs) { // create tool model @@ -42,8 +42,7 @@ // load tool model this.model = new Model({ - id : options.id, - job_id : options.job_id + id : options.id }); // creates a tree/json structure from the input form @@ -102,6 +101,37 @@ // link this var self = this; + // fetch model and render form + this.model.fetch({ + error: function(response) { + console.debug('tools-form::_initializeToolForm() : Attempt to fetch tool model failed.'); + }, + success: function() { + // backup inputs + self.inputs = self.model.get('inputs'); + + // update inputs with job parameters + if (self.options.job_id) { + Utils.get({ + url: galaxy_config.root + 'api/jobs/' + self.options.job_id, + success: function(parameters) { + // TODO: Update input parameters + //self._updateInputs(self.inputs, parameters); + self._buildForm(); + } + }); + } else { + self._buildForm(); + } + } + }); + }, + + // builds the tool form + _buildForm: function() { + // link this + var self = this; + // create question button var button_question = new Ui.ButtonIcon({ icon : 'fa-question-circle', @@ -152,79 +182,70 @@ }); } - // fetch model and render form - this.model.fetch({ - error: function(response) { - console.debug('tools-form::_initializeToolForm() : Attempt to fetch tool model failed.'); - }, - success: function() { - // create tool form section - self.section = new ToolSection.View(self, { - inputs : self.model.get('inputs'), - cls : 'ui-table-plain' - }); - - // TEMPORARY SWITCH - // switch to classic tool form mako if the form definition is incompatible - if (self.incompatible) { - self.$el.hide(); - $('#tool-form-classic').show(); - return; - } - - // create portlet - self.portlet = new Portlet.View({ - icon : 'fa-wrench', - title: '<b>' + self.model.get('name') + '</b> ' + self.model.get('description'), - operations: operations, - buttons: { - execute: new Ui.Button({ - icon : 'fa-check', - tooltip : 'Execute the tool', - title : 'Execute', - cls : 'btn btn-primary', - floating : 'clear', - onclick : function() { - self.job_handler.submit(); - } - }) + // create tool form section + this.section = new ToolSection.View(self, { + inputs : this.inputs, + cls : 'ui-table-plain' + }); + + // switch to classic tool form mako if the form definition is incompatible + if (this.incompatible) { + this.$el.hide(); + $('#tool-form-classic').show(); + return; + } + + // create portlet + this.portlet = new Portlet.View({ + icon : 'fa-wrench', + title: '<b>' + this.model.get('name') + '</b> ' + this.model.get('description'), + operations: operations, + buttons: { + execute: new Ui.Button({ + icon : 'fa-check', + tooltip : 'Execute the tool', + title : 'Execute', + cls : 'btn btn-primary', + floating : 'clear', + onclick : function() { + self.job_handler.submit(); } - }); - - // configure button selection - if(!self.options.biostar_url) { - button_question.$el.hide(); - button_search.$el.hide(); - } - - // append form - self.$el.append(self.portlet.$el); - - // append help - if (self.options.help != '') { - self.$el.append(ToolTemplate.help(self.options.help)); - } - - // append citations - if (self.options.citations) { - // append html - self.$el.append(ToolTemplate.citations()); - - // fetch citations - var citations = new CitationModel.ToolCitationCollection(); - citations.tool_id = self.options.id; - var citation_list_view = new CitationView.CitationListView({ collection: citations } ); - citation_list_view.render(); - citations.fetch(); - } - - // append tool section - self.portlet.append(self.section.$el); - - // trigger refresh - self.refresh(); + }) } }); + + // configure button selection + if(!this.options.biostar_url) { + button_question.$el.hide(); + button_search.$el.hide(); + } + + // append form + this.$el.append(this.portlet.$el); + + // append help + if (this.options.help != '') { + this.$el.append(ToolTemplate.help(this.options.help)); + } + + // append citations + if (this.options.citations) { + // append html + this.$el.append(ToolTemplate.citations()); + + // fetch citations + var citations = new CitationModel.ToolCitationCollection(); + citations.tool_id = this.options.id; + var citation_list_view = new CitationView.CitationListView({ collection: citations } ); + citation_list_view.render(); + citations.fetch(); + } + + // append tool section + this.portlet.append(this.section.$el); + + // trigger refresh + this.refresh(); } }); diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 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 @@ -98,9 +98,9 @@ var input_id = this.app.tree.match(job_input_id); var input_field = this.app.field_list[input_id]; var input_def = this.app.input_list[input_id]; - + // check basic field validation - if (input_def && !input_def.optional && input_field && input_field.validate && !input_field.validate()) { + if (input_def && input_field && input_field.validate && !input_field.validate()) { this._foundError(input_id); return false; } diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 client/galaxy/scripts/mvc/tools/tools-section.js --- a/client/galaxy/scripts/mvc/tools/tools-section.js +++ b/client/galaxy/scripts/mvc/tools/tools-section.js @@ -1,58 +1,8 @@ /** This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function. */ -define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content'], - function(Utils, Table, Ui, Repeat, SelectContent) { - - // input field element wrapper - var InputElement = Backbone.View.extend({ - // initialize input wrapper - initialize: function(options) { - this.setElement(this._template(options)); - }, - - /** Set error text - */ - error: function(text) { - // set text - this.$el.find('.ui-table-form-error-text').html(text); - this.$el.find('.ui-table-form-error').fadeIn(); - this.$el.addClass('ui-error'); - }, - - /** Reset this view - */ - reset: function() { - this.$el.find('.ui-table-form-error').hide(); - this.$el.removeClass('ui-error'); - }, - - /** Main Template - */ - _template: function(options) { - // create table element - var $input = $('<div class="ui-table-element"/>'); - - // add error - $input.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>'); - - // add label - if (options.label) { - $input.append('<div class="ui-table-form-title-strong">' + options.label + '</div>'); - } - - // add input element - $input.append(options.$el); - - // add help - if (options.help) { - $input.append('<div class="ui-table-form-info">' + options.help + '</div>'); - } - - // return input element - return $input; - } - }); +define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content', 'mvc/tools/tools-input'], + function(Utils, Table, Ui, Repeat, SelectContent, InputElement) { // create form view var View = Backbone.View.extend({ @@ -234,7 +184,7 @@ var input_element = new InputElement({ label : input_def.title, help : input_def.help, - $el : repeat.$el + field : repeat }); // displays as grouped subsection @@ -337,9 +287,10 @@ // create input field wrapper var input_element = new InputElement({ - label : input_def.label, - help : input_def.help, - $el : field.$el + label : input_def.label, + optional : input_def.optional, + help : input_def.help, + field : field }); // add to element list diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 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 @@ -110,8 +110,13 @@ } break; default: + // get conditional value + var field = self.app.field_list[input.id]; + // handle default value - add (job_input_id, input.id, self.app.field_list[input.id].value()); + if (!field.skip) { + add (job_input_id, input.id, field.value()); + } } } } diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -200,6 +200,7 @@ pass #HACK for assert trans.history, 'requires a history' tool_dict[ 'model_class' ] = self.__class__.__name__ + tool_dict[ 'optional' ] = self.optional if hasattr( self, 'value' ): tool_dict[ 'value' ] = self.value return tool_dict diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/mvc/tools/tools-form.js --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -1,10 +1,10 @@ /** This is the main class of the tool form plugin. It is referenced as 'app' in all lower level modules. */ -define(['mvc/ui/ui-portlet', 'mvc/ui/ui-misc', +define(['utils/utils', '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(Portlet, Ui, CitationModel, CitationView, + function(Utils, Portlet, Ui, CitationModel, CitationView, Tools, ToolTemplate, ToolContent, ToolSection, ToolTree, ToolJobs) { // create tool model @@ -42,8 +42,7 @@ // load tool model this.model = new Model({ - id : options.id, - job_id : options.job_id + id : options.id }); // creates a tree/json structure from the input form @@ -102,6 +101,37 @@ // link this var self = this; + // fetch model and render form + this.model.fetch({ + error: function(response) { + console.debug('tools-form::_initializeToolForm() : Attempt to fetch tool model failed.'); + }, + success: function() { + // backup inputs + self.inputs = self.model.get('inputs'); + + // update inputs with job parameters + if (self.options.job_id) { + Utils.get({ + url: galaxy_config.root + 'api/jobs/' + self.options.job_id, + success: function(parameters) { + // TODO: Update input parameters + //self._updateInputs(self.inputs, parameters); + self._buildForm(); + } + }); + } else { + self._buildForm(); + } + } + }); + }, + + // builds the tool form + _buildForm: function() { + // link this + var self = this; + // create question button var button_question = new Ui.ButtonIcon({ icon : 'fa-question-circle', @@ -152,79 +182,70 @@ }); } - // fetch model and render form - this.model.fetch({ - error: function(response) { - console.debug('tools-form::_initializeToolForm() : Attempt to fetch tool model failed.'); - }, - success: function() { - // create tool form section - self.section = new ToolSection.View(self, { - inputs : self.model.get('inputs'), - cls : 'ui-table-plain' - }); - - // TEMPORARY SWITCH - // switch to classic tool form mako if the form definition is incompatible - if (self.incompatible) { - self.$el.hide(); - $('#tool-form-classic').show(); - return; - } - - // create portlet - self.portlet = new Portlet.View({ - icon : 'fa-wrench', - title: '<b>' + self.model.get('name') + '</b> ' + self.model.get('description'), - operations: operations, - buttons: { - execute: new Ui.Button({ - icon : 'fa-check', - tooltip : 'Execute the tool', - title : 'Execute', - cls : 'btn btn-primary', - floating : 'clear', - onclick : function() { - self.job_handler.submit(); - } - }) + // create tool form section + this.section = new ToolSection.View(self, { + inputs : this.inputs, + cls : 'ui-table-plain' + }); + + // switch to classic tool form mako if the form definition is incompatible + if (this.incompatible) { + this.$el.hide(); + $('#tool-form-classic').show(); + return; + } + + // create portlet + this.portlet = new Portlet.View({ + icon : 'fa-wrench', + title: '<b>' + this.model.get('name') + '</b> ' + this.model.get('description'), + operations: operations, + buttons: { + execute: new Ui.Button({ + icon : 'fa-check', + tooltip : 'Execute the tool', + title : 'Execute', + cls : 'btn btn-primary', + floating : 'clear', + onclick : function() { + self.job_handler.submit(); } - }); - - // configure button selection - if(!self.options.biostar_url) { - button_question.$el.hide(); - button_search.$el.hide(); - } - - // append form - self.$el.append(self.portlet.$el); - - // append help - if (self.options.help != '') { - self.$el.append(ToolTemplate.help(self.options.help)); - } - - // append citations - if (self.options.citations) { - // append html - self.$el.append(ToolTemplate.citations()); - - // fetch citations - var citations = new CitationModel.ToolCitationCollection(); - citations.tool_id = self.options.id; - var citation_list_view = new CitationView.CitationListView({ collection: citations } ); - citation_list_view.render(); - citations.fetch(); - } - - // append tool section - self.portlet.append(self.section.$el); - - // trigger refresh - self.refresh(); + }) } }); + + // configure button selection + if(!this.options.biostar_url) { + button_question.$el.hide(); + button_search.$el.hide(); + } + + // append form + this.$el.append(this.portlet.$el); + + // append help + if (this.options.help != '') { + this.$el.append(ToolTemplate.help(this.options.help)); + } + + // append citations + if (this.options.citations) { + // append html + this.$el.append(ToolTemplate.citations()); + + // fetch citations + var citations = new CitationModel.ToolCitationCollection(); + citations.tool_id = this.options.id; + var citation_list_view = new CitationView.CitationListView({ collection: citations } ); + citation_list_view.render(); + citations.fetch(); + } + + // append tool section + this.portlet.append(this.section.$el); + + // trigger refresh + this.refresh(); } }); diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/mvc/tools/tools-input.js --- /dev/null +++ b/static/scripts/mvc/tools/tools-input.js @@ -0,0 +1,108 @@ +/** + This class creates a tool form input element wrapper +*/ +define([], function() { + + // input field element wrapper + return Backbone.View.extend({ + // initialize input wrapper + initialize: function(options) { + // link field + this.field = options.field; + + // set element + this.setElement(this._template(options)); + + // link elements + this.$field = this.$el.find('.ui-table-form-field'); + this.$title_optional = this.$el.find('.ui-table-form-title-optional'); + this.$error_text = this.$el.find('.ui-table-form-error-text'); + this.$error = this.$el.find('.ui-table-form-error'); + + // add field element + this.$field.prepend(this.field.$el); + + // hide optional field on initialization + if (options.optional) { + this.field.skip = true; + } else { + this.field.skip = false; + } + + // refresh view + this._refresh(); + + // add optional hide/show + var self = this; + this.$title_optional.on('click', function() { + // flip flag + self.field.skip = !self.field.skip; + + // refresh view + self._refresh(); + }); + }, + + /** Set error text + */ + error: function(text) { + this.$error_text.html(text); + this.$error.fadeIn(); + this.$el.addClass('ui-error'); + }, + + /** Reset this view + */ + reset: function() { + this.$error.hide(); + this.$el.removeClass('ui-error'); + }, + + /** Refresh element + */ + _refresh: function() { + // show/hide field element + if (!this.field.skip) { + this.$field.fadeIn('fast'); + this.$title_optional.html('Disable'); + } else { + this.$field.hide(); + this.$title_optional.html('Enable'); + } + }, + + /** Main Template + */ + _template: function(options) { + // create table element + var tmp = '<div class="ui-table-form-element">' + + '<div class="ui-table-form-error ui-error">' + + '<span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/>' + + '</div>' + + '<div class="ui-table-form-title-strong">'; + + // is optional + if (options.optional) { + tmp += '*Optional: ' + options.label + + '<span> [<span class="ui-table-form-title-optional"/>]</span>'; + } else { + tmp += options.label; + } + + // finalize title + tmp += '</div>' + + '<div class="ui-table-form-field">'; + // add help + if (options.help) { + tmp += '<div class="ui-table-form-info">' + options.help + '</div>'; + } + + // finalize + tmp += '</div>' + + '</div>'; + + // return input element + return tmp; + } + }); +}); diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/mvc/tools/tools-jobs.js --- a/static/scripts/mvc/tools/tools-jobs.js +++ b/static/scripts/mvc/tools/tools-jobs.js @@ -98,9 +98,9 @@ var input_id = this.app.tree.match(job_input_id); var input_field = this.app.field_list[input_id]; var input_def = this.app.input_list[input_id]; - + // check basic field validation - if (input_def && !input_def.optional && input_field && input_field.validate && !input_field.validate()) { + if (input_def && input_field && input_field.validate && !input_field.validate()) { this._foundError(input_id); return false; } diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -1,58 +1,8 @@ /** This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function. */ -define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content'], - function(Utils, Table, Ui, Repeat, SelectContent) { - - // input field element wrapper - var InputElement = Backbone.View.extend({ - // initialize input wrapper - initialize: function(options) { - this.setElement(this._template(options)); - }, - - /** Set error text - */ - error: function(text) { - // set text - this.$el.find('.ui-table-form-error-text').html(text); - this.$el.find('.ui-table-form-error').fadeIn(); - this.$el.addClass('ui-error'); - }, - - /** Reset this view - */ - reset: function() { - this.$el.find('.ui-table-form-error').hide(); - this.$el.removeClass('ui-error'); - }, - - /** Main Template - */ - _template: function(options) { - // create table element - var $input = $('<div class="ui-table-element"/>'); - - // add error - $input.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>'); - - // add label - if (options.label) { - $input.append('<div class="ui-table-form-title-strong">' + options.label + '</div>'); - } - - // add input element - $input.append(options.$el); - - // add help - if (options.help) { - $input.append('<div class="ui-table-form-info">' + options.help + '</div>'); - } - - // return input element - return $input; - } - }); +define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content', 'mvc/tools/tools-input'], + function(Utils, Table, Ui, Repeat, SelectContent, InputElement) { // create form view var View = Backbone.View.extend({ @@ -234,7 +184,7 @@ var input_element = new InputElement({ label : input_def.title, help : input_def.help, - $el : repeat.$el + field : repeat }); // displays as grouped subsection @@ -337,9 +287,10 @@ // create input field wrapper var input_element = new InputElement({ - label : input_def.label, - help : input_def.help, - $el : field.$el + label : input_def.label, + optional : input_def.optional, + help : input_def.help, + field : field }); // add to element list diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/mvc/tools/tools-tree.js --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -110,8 +110,13 @@ } break; default: + // get conditional value + var field = self.app.field_list[input.id]; + // handle default value - add (job_input_id, input.id, self.app.field_list[input.id].value()); + if (!field.skip) { + add (job_input_id, input.id, field.value()); + } } } } diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 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(["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,l,j,a,f,d,g,k,c,h){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(n){var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.setElement("<div/>");$(this.container).append(this.$el);this.model=new e({id:n.id,job_id:n.job_id});this.tree=new c(this);this.job_handler=new h(this);this.field_list={};this.input_list={};this.element_list={};this.content=new g({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_initializeToolForm:function(){var n=this;var p=new l.ButtonIcon({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});var q=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});var o={button_question:p,button_search:q,button_share:m};if(Galaxy.currUser.get("is_admin")){o.button_download=new l.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.model.fetch({error:function(r){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new i.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),operations:o,buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!n.options.biostar_url){p.$el.hide();q.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var r=new j.ToolCitationCollection();r.tool_id=n.options.id;var s=new a.CitationListView({collection:r});s.render();r.fetch()}n.portlet.append(n.section.$el);n.refresh()}})}});return{View:b}}); \ No newline at end of file +define(["utils/utils","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(j,i,m,k,a,f,d,g,l,c,h){var e=Backbone.Model.extend({initialize:function(n){this.url=galaxy_config.root+"api/tools/"+n.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(o){var n=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new m.Modal.View()}this.options=o;this.setElement("<div/>");$(this.container).append(this.$el);this.model=new e({id:o.id});this.tree=new c(this);this.job_handler=new h(this);this.field_list={};this.input_list={};this.element_list={};this.content=new g({history_id:this.options.history_id,success:function(){n._initializeToolForm()}})},message:function(n){$(this.container).empty();$(this.container).append(n)},reset:function(){for(var n in this.element_list){this.element_list[n].reset()}},refresh:function(){this.tree.refresh();for(var n in this.field_list){this.field_list[n].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_initializeToolForm:function(){var n=this;this.model.fetch({error:function(o){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.inputs=n.model.get("inputs");if(n.options.job_id){j.get({url:galaxy_config.root+"api/jobs/"+n.options.job_id,success:function(o){n._buildForm()}})}else{n._buildForm()}}})},_buildForm:function(){var p=this;var r=new m.ButtonIcon({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(p.options.biostar_url+"/p/new/post/")}});var s=new m.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(p.options.biostar_url+"/t/"+p.options.id+"/")}});var n=new m.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+p.options.id)}});var q={button_question:r,button_search:s,button_share:n};if(Galaxy.currUser.get("is_admin")){q.button_download=new m.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+p.options.id+"/download"}})}this.section=new l.View(p,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new i.View({icon:"fa-wrench",title:"<b>"+this.model.get("name")+"</b> "+this.model.get("description"),operations:q,buttons:{execute:new m.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){p.job_handler.submit()}})}});if(!this.options.biostar_url){r.$el.hide();s.$el.hide()}this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var o=new k.ToolCitationCollection();o.tool_id=this.options.id;var t=new a.CitationListView({collection:o});t.render();o.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}}); \ No newline at end of file diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/packed/mvc/tools/tools-input.js --- /dev/null +++ b/static/scripts/packed/mvc/tools/tools-input.js @@ -0,0 +1,1 @@ +define([],function(){return Backbone.View.extend({initialize:function(b){this.field=b.field;this.setElement(this._template(b));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);if(b.optional){this.field.skip=true}else{this.field.skip=false}this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh()})},error:function(a){this.$error_text.html(a);this.$error.fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html("Disable")}else{this.$field.hide();this.$title_optional.html("Enable")}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+="*Optional: "+a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})}); \ No newline at end of file diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 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",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])}}else{console.debug(d);console.debug(e)}}})},_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&&!h.optional&&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",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])}}else{console.debug(d);console.debug(e)}}})},_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 diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/scripts/packed/mvc/tools/tools-section.js --- a/static/scripts/packed/mvc/tools/tools-section.js +++ b/static/scripts/packed/mvc/tools/tools-section.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content"],function(d,b,g,c,a){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(k,h)}},_addConditional:function(h){h.label=h.test_param.label;h.value=h.test_param.value;var j=this._addRow("conditional",h);for(var l in h.cases){var k=h.id+"-section-"+l;var m=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(k)}},_addRepeat:function(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.is_dynamic=false;i=this._fieldSelect(h);break;case"conditional":i=this._fieldConditional(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":i=this._fieldSelect(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,help:h.help,$el:i.$el});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_fieldConditional:function(h){var j=this;var k=[];for(var l in h.test_param.options){var m=h.test_param.options[l];k.push({label:m[0],value:m[1]})}return new g.Select.View({id:"field-"+h.id,data:k,onchange:function(u){for(var s in h.cases){var o=h.cases[s];var r=h.id+"-section-"+s;var n=j.table.get(r);var q=false;for(var p in o.inputs){var t=o.inputs[p].type;if(t&&t!=="hidden"){q=true;break}}if(o.value==u&&q){n.fadeIn("fast")}else{n.hide()}}}})},_fieldData:function(h){var i=this;var j=h.id;return new a.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(q){var o=q.values[0];var m=o.id;var p=o.src;var l=i.app.tree.references(j,"data_column");if(l.length<=0){console.debug("tool-form::field_data() - Data column parameters unavailable.");return}for(var n in l){var k=i.app.field_list[l[n]];k.wait&&k.wait()}i.app.content.getDetails({id:m,src:p,success:function(y){var B=null;if(y){console.debug("tool-form::field_data() - Selected content "+m+".");if(p=="hdca"&&y.elements&&y.elements.length>0){y=y.elements[0].object}B=y.metadata_column_types;if(!B){console.debug("tool-form::field_data() - FAILED: Could not find metadata for content "+m+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find content "+m+".")}for(var u in l){var w=i.app.input_list[l[u]];var x=i.app.field_list[l[u]];if(!w||!x){console.debug("tool-form::field_data() - FAILED: Column not found.")}var t=w.numerical;var s=[];for(var A in B){var z=B[A];var r=(parseInt(A)+1);var v="Text";if(z=="int"||z=="float"){v="Number"}if(z=="int"||z=="float"||!t){s.push({label:"Column: "+r+" ["+v+"]",value:r})}}if(x){x.update(s);if(!x.exists(x.value())){x.value(x.first())}x.show()}}}})}})},_fieldSelect:function(h){if(h.is_dynamic){this.app.incompatible=true}var j=[];for(var k in h.options){var l=h.options[k];j.push({label:l[0],value:l[1]})}var m=g.Select;switch(h.display){case"checkboxes":m=g.Checkbox;break;case"radio":m=g.Radio;break}return new m.View({id:"field-"+h.id,data:j,multiple:h.multiple})},_fieldText:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_fieldSlider:function(h){h.min=h.min||0;h.max=h.max||100000;var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min,max:h.max,step:i})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(k,h)}},_addConditional:function(h){h.label=h.test_param.label;h.value=h.test_param.value;var j=this._addRow("conditional",h);for(var l in h.cases){var k=h.id+"-section-"+l;var m=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(k)}},_addRepeat:function(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,field:m});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.is_dynamic=false;i=this._fieldSelect(h);break;case"conditional":i=this._fieldConditional(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":i=this._fieldSelect(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_fieldConditional:function(h){var j=this;var k=[];for(var l in h.test_param.options){var m=h.test_param.options[l];k.push({label:m[0],value:m[1]})}return new g.Select.View({id:"field-"+h.id,data:k,onchange:function(u){for(var s in h.cases){var o=h.cases[s];var r=h.id+"-section-"+s;var n=j.table.get(r);var q=false;for(var p in o.inputs){var t=o.inputs[p].type;if(t&&t!=="hidden"){q=true;break}}if(o.value==u&&q){n.fadeIn("fast")}else{n.hide()}}}})},_fieldData:function(h){var i=this;var j=h.id;return new a.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(q){var o=q.values[0];var m=o.id;var p=o.src;var l=i.app.tree.references(j,"data_column");if(l.length<=0){console.debug("tool-form::field_data() - Data column parameters unavailable.");return}for(var n in l){var k=i.app.field_list[l[n]];k.wait&&k.wait()}i.app.content.getDetails({id:m,src:p,success:function(y){var B=null;if(y){console.debug("tool-form::field_data() - Selected content "+m+".");if(p=="hdca"&&y.elements&&y.elements.length>0){y=y.elements[0].object}B=y.metadata_column_types;if(!B){console.debug("tool-form::field_data() - FAILED: Could not find metadata for content "+m+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find content "+m+".")}for(var u in l){var w=i.app.input_list[l[u]];var x=i.app.field_list[l[u]];if(!w||!x){console.debug("tool-form::field_data() - FAILED: Column not found.")}var t=w.numerical;var s=[];for(var A in B){var z=B[A];var r=(parseInt(A)+1);var v="Text";if(z=="int"||z=="float"){v="Number"}if(z=="int"||z=="float"||!t){s.push({label:"Column: "+r+" ["+v+"]",value:r})}}if(x){x.update(s);if(!x.exists(x.value())){x.value(x.first())}x.show()}}}})}})},_fieldSelect:function(h){if(h.is_dynamic){this.app.incompatible=true}var j=[];for(var k in h.options){var l=h.options[k];j.push({label:l[0],value:l[1]})}var m=g.Select;switch(h.display){case"checkboxes":m=g.Checkbox;break;case"radio":m=g.Radio;break}return new m.View({id:"field-"+h.id,data:j,multiple:h.multiple})},_fieldText:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_fieldSlider:function(h){h.min=h.min||0;h.max=h.max||100000;var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min,max:h.max,step:i})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}}); \ No newline at end of file diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 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(){var a=this;this.job_def={};this.job_ids={};function c(f,e,d){a.job_def[f]=d;a.job_ids[f]=e}function b(j,m){for(var g in m){var e=m[g];if(e.input){var n=e.input;var h=j;if(j!=""){h+="|"}h+=n.name;switch(n.type){case"repeat":var d="section-";var q=[];var l=null;for(var p in e){var k=p.indexOf(d);if(k!=-1){k+=d.length;q.push(parseInt(p.substr(k)));if(!l){l=p.substr(0,k)}}}q.sort(function(r,i){return r-i});var g=0;for(var f in q){b(h+"_"+g++,e[l+q[f]])}break;case"conditional":var o=a.app.field_list[n.id].value();c(h+"|"+n.test_param.name,n.id,o);for(var f in n.cases){if(n.cases[f].value==o){b(h,m[n.id+"-section-"+f]);break}}break;default:c(h,n.id,a.app.field_list[n.id].value())}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchResponse:function(c){var a={};var b=this;function d(j,h){if(typeof h==="string"){var f=b.app.tree.job_ids[j];if(f){a[f]=h}}else{for(var g in h){var e=g;if(j!==""){e=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(){var a=this;this.job_def={};this.job_ids={};function c(f,e,d){a.job_def[f]=d;a.job_ids[f]=e}function b(j,m){for(var g in m){var e=m[g];if(e.input){var o=e.input;var h=j;if(j!=""){h+="|"}h+=o.name;switch(o.type){case"repeat":var d="section-";var r=[];var l=null;for(var q in e){var k=q.indexOf(d);if(k!=-1){k+=d.length;r.push(parseInt(q.substr(k)));if(!l){l=q.substr(0,k)}}}r.sort(function(s,i){return s-i});var g=0;for(var f in r){b(h+"_"+g++,e[l+r[f]])}break;case"conditional":var p=a.app.field_list[o.id].value();c(h+"|"+o.test_param.name,o.id,p);for(var f in o.cases){if(o.cases[f].value==p){b(h,m[o.id+"-section-"+f]);break}}break;default:var n=a.app.field_list[o.id];if(!n.skip){c(h,o.id,n.value())}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchResponse:function(c){var a={};var b=this;function d(j,h){if(typeof h==="string"){var f=b.app.tree.job_ids[j];if(f){a[f]=h}}else{for(var g in h){var e=g;if(j!==""){e=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 diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1284,8 +1284,10 @@ .ui-table tbody{cursor:pointer} .ui-table-plain tbody td{padding:5px 0px 5px 0px !important;border:none !important} .ui-table-plain tbody{cursor:auto !important} +.ui-table-form-element .ui-table-form-title-optional{font-weight:bold;text-decoration:underline;cursor:pointer} +.ui-table-form-element .ui-table-form-field{margin-top:5px} .ui-table-form-section{border-left:solid 3px #ebd9b2;border-radius:5px !important;padding-left:10px} -.ui-table-form-title-strong{font-weight:bold;padding-bottom:5px} +.ui-table-form-title-strong{font-weight:bold} .ui-table-form-info{clear:both !important} .ui-table-form-separator{font-weight:bold;font-size:0.9em} .ui-label{font-weight:bold} diff -r 46523237518bb9ec8ed9fa4cf30453c800580c24 -r 34e643839cdace531f6ebf1a7d08e5d735be51a6 static/style/src/less/ui.less --- a/static/style/src/less/ui.less +++ b/static/style/src/less/ui.less @@ -44,6 +44,17 @@ } } +.ui-table-form-element { + .ui-table-form-title-optional { + font-weight: bold; + text-decoration: underline; + cursor: pointer; + } + .ui-table-form-field { + margin-top: 5px; + } +} + .ui-table-form-section { border-left: solid 3px @form-heading-bg; border-radius: 5px !important; @@ -52,7 +63,6 @@ .ui-table-form-title-strong { font-weight: bold; - padding-bottom: 5px; } .ui-table-form-info { 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.