diff --git a/client/galaxy/scripts/mvc/tools/tools-form-base.js b/client/galaxy/scripts/mvc/tools/tools-form-base.js index 3e46e5d133a..f8b88ccbe75 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form-base.js +++ b/client/galaxy/scripts/mvc/tools/tools-form-base.js @@ -15,12 +15,10 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', this.optionsDefault = { // uses dynamic fields instead of text fields is_dynamic : true, - // shows form in compact view mode - compact : false, + // shows form in narrow view mode + narrow : false, // shows errors on start - initial_errors : false, - // use default value for disabled fields - use_defaults : false + initial_errors : false }; // configure options @@ -58,9 +56,66 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', $(this.container).append(this.$el); // build this form - this._buildForm(); + this.build(this.options); }, + /** Main tool form build function. This function is called once a new model is available. + */ + build: function(options) { + // link this + var self = this; + + // reset events + this.off('refresh'); + this.off('reset'); + + // reset field list, which contains the input field elements + this.field_list = {}; + + // reset sequential input definition list, which contains the input definitions as provided from the api + this.input_list = {}; + + // reset input element list, which contains the dom elements of each input element (includes also the input field) + this.element_list = {}; + + // creates a tree/json data structure from the input form + this.tree = new ToolTree(this); + + // request history content and build form + this.content = new ToolContent(this); + + // update model data + self.options.inputs = options && options.inputs; + + // create ui elements + this._renderForm(options); + + // rebuild the underlying data structure + this.tree.finalize(); + + // show errors on startup + if (options.initial_errors) { + this._errors(options); + } + + // add refresh listener + this.on('refresh', function() { + // by using/resetting the deferred ajax queue the number of redundant calls is reduced + self.deferred.reset(); + self.deferred.execute(function(){self._updateModel()}); + }); + + // add reset listener + this.on('reset', function() { + for (var i in this.element_list) { + this.element_list[i].reset(); + } + }); + + // refresh + this.trigger('refresh'); + }, + /** Shows the final message (usually upon successful job submission) */ reciept: function($el) { @@ -105,63 +160,6 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', } } }, - - /** Main tool form build function. This function is called once a new model is available. - */ - _buildForm: function() { - // link this - var self = this; - - // reset events - this.off('refresh'); - this.off('reset'); - - // reset field list, which contains the input field elements - this.field_list = {}; - - // reset sequential input definition list, which contains the input definitions as provided from the api - this.input_list = {}; - - // reset input element list, which contains the dom elements of each input element (includes also the input field) - this.element_list = {}; - - // creates a tree/json data structure from the input form - this.tree = new ToolTree(this); - - // request history content and build form - this.content = new ToolContent(this); - - // link model options - var options = this.options; - - // create ui elements - this._renderForm(options); - - // rebuild the underlying data structure - this.tree.finalize(); - - // show errors on startup - if (options.initial_errors) { - this._errors(options); - } - - // add refresh listener - this.on('refresh', function() { - // by using/resetting the deferred ajax queue the number of redundant calls is reduced - self.deferred.reset(); - self.deferred.execute(function(){self._updateModel()}); - }); - - // add reset listener - this.on('reset', function() { - for (var i in this.element_list) { - this.element_list[i].reset(); - } - }); - - // refresh - this.trigger('refresh'); - }, /** Renders the UI elements required for the form */ @@ -175,7 +173,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', // button for version selection var requirements_button = new Ui.ButtonIcon({ icon : 'fa-info-circle', - title : (!options.compact && 'Requirements') || null, + title : (!options.narrow && 'Requirements') || null, tooltip : 'Display tool requirements', onclick : function() { if (!this.visible) { @@ -200,7 +198,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', // button for version selection var versions_button = new Ui.ButtonMenu({ icon : 'fa-cubes', - title : (!options.compact && 'Versions') || null, + title : (!options.narrow && 'Versions') || null, tooltip : 'Select another tool version' }); if (options.versions && options.versions.length > 1) { @@ -213,8 +211,8 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', icon : 'fa-cube', onclick : function() { // here we update the tool version (some tools encode the version also in the id) - options.id = options.id.replace(options.version, this.version); - options.version = this.version; + self.options.id = self.options.id.replace(self.options.version, this.version); + self.options.version = this.version; // rebuild the model and form self.deferred.reset(); @@ -230,7 +228,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', // button menu var menu_button = new Ui.ButtonMenu({ icon : 'fa-caret-down', - title : (!options.compact && 'Options') || null, + title : (!options.narrow && 'Options') || null, tooltip : 'View available options' }); @@ -306,7 +304,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', }); // remove padding - if (options.compact) { + if (options.narrow) { this.portlet.$content.css('padding', '0px'); } diff --git a/client/galaxy/scripts/mvc/tools/tools-form-workflow.js b/client/galaxy/scripts/mvc/tools/tools-form-workflow.js index 6249164b837..49c3abf786f 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form-workflow.js +++ b/client/galaxy/scripts/mvc/tools/tools-form-workflow.js @@ -21,9 +21,13 @@ define(['utils/utils', 'mvc/tools/tools-form-base'], this.options = options; // set labels - this.options.text_enable = 'In Advance'; - this.options.text_disable = 'At Runtime'; - this.options.use_defaults = true; + this.options.text_enable = 'In Advance'; + this.options.text_disable = 'At Runtime'; + + // configure workflow style + this.options.is_dynamic = false; + this.options.narrow = true; + this.options.initial_errors = true; // declare fields as optional Utils.deepeach(options.inputs, function(item) { diff --git a/client/galaxy/scripts/mvc/tools/tools-form.js b/client/galaxy/scripts/mvc/tools/tools-form.js index 94a0af0a7f4..94cf93f9622 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form.js +++ b/client/galaxy/scripts/mvc/tools/tools-form.js @@ -24,7 +24,7 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } ToolFormBase.prototype.initialize.call(this, options); }, - + /** Builds a new model through api call and recreates the entire form */ _buildModel: function() { @@ -47,31 +47,28 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } } } - + // register process var process_id = this.deferred.register(); - + // get initial model Utils.request({ type : 'GET', url : model_url, success : function(response) { - // link model data update options - self.options = response; - - // build form - self._buildForm(); - + // build new tool form + self.build(response); + // notification self.message.update({ status : 'success', message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.', persistent : false }); - + // process completed self.deferred.done(process_id); - + // log success console.debug('tools-form::initialize() - Initial tool model ready.'); console.debug(response); @@ -79,11 +76,11 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools error : function(response) { // process completed self.deferred.done(process_id); - + // log error console.debug('tools-form::initialize() - Initial tool model request failed.'); console.debug(response); - + // show error var error_message = response.error || 'Uncaught error.'; self.modal.show({ @@ -98,7 +95,7 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } }); }, - + /** Request a new model for an already created tool form and updates the form inputs */ _updateModel: function() { @@ -112,11 +109,11 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools return null; } }); - + // log tool state console.debug('tools-form::_refreshForm() - Refreshing states.'); console.debug(current_state); - + // activates/disables spinner for dynamic fields to indicate that they are currently being updated function wait(active) { for (var i in self.input_list) { @@ -131,10 +128,10 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } } } - + // set wait mode wait(true); - + // register process var process_id = this.deferred.register(); @@ -179,13 +176,13 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } } }); - + // unset wait mode wait(false); - + // process completed self.deferred.done(process_id); - + // log success console.debug('tools-form::_refreshForm() - States refreshed.'); console.debug(new_model); @@ -193,7 +190,7 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools error : function(response) { // process completed self.deferred.done(process_id); - + // log error console.debug('tools-form::_refreshForm() - Refresh request failed.'); console.debug(response); diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 49cbbd0bfef..46ba59e477b 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2254,8 +2254,8 @@ class Tool( object, Dictifiable ): """ 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) + 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 diff --git a/static/scripts/mvc/tools/tools-form-base.js b/static/scripts/mvc/tools/tools-form-base.js index 3e46e5d133a..f8b88ccbe75 100644 --- a/static/scripts/mvc/tools/tools-form-base.js +++ b/static/scripts/mvc/tools/tools-form-base.js @@ -15,12 +15,10 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', this.optionsDefault = { // uses dynamic fields instead of text fields is_dynamic : true, - // shows form in compact view mode - compact : false, + // shows form in narrow view mode + narrow : false, // shows errors on start - initial_errors : false, - // use default value for disabled fields - use_defaults : false + initial_errors : false }; // configure options @@ -58,9 +56,66 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', $(this.container).append(this.$el); // build this form - this._buildForm(); + this.build(this.options); }, + /** Main tool form build function. This function is called once a new model is available. + */ + build: function(options) { + // link this + var self = this; + + // reset events + this.off('refresh'); + this.off('reset'); + + // reset field list, which contains the input field elements + this.field_list = {}; + + // reset sequential input definition list, which contains the input definitions as provided from the api + this.input_list = {}; + + // reset input element list, which contains the dom elements of each input element (includes also the input field) + this.element_list = {}; + + // creates a tree/json data structure from the input form + this.tree = new ToolTree(this); + + // request history content and build form + this.content = new ToolContent(this); + + // update model data + self.options.inputs = options && options.inputs; + + // create ui elements + this._renderForm(options); + + // rebuild the underlying data structure + this.tree.finalize(); + + // show errors on startup + if (options.initial_errors) { + this._errors(options); + } + + // add refresh listener + this.on('refresh', function() { + // by using/resetting the deferred ajax queue the number of redundant calls is reduced + self.deferred.reset(); + self.deferred.execute(function(){self._updateModel()}); + }); + + // add reset listener + this.on('reset', function() { + for (var i in this.element_list) { + this.element_list[i].reset(); + } + }); + + // refresh + this.trigger('refresh'); + }, + /** Shows the final message (usually upon successful job submission) */ reciept: function($el) { @@ -105,63 +160,6 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', } } }, - - /** Main tool form build function. This function is called once a new model is available. - */ - _buildForm: function() { - // link this - var self = this; - - // reset events - this.off('refresh'); - this.off('reset'); - - // reset field list, which contains the input field elements - this.field_list = {}; - - // reset sequential input definition list, which contains the input definitions as provided from the api - this.input_list = {}; - - // reset input element list, which contains the dom elements of each input element (includes also the input field) - this.element_list = {}; - - // creates a tree/json data structure from the input form - this.tree = new ToolTree(this); - - // request history content and build form - this.content = new ToolContent(this); - - // link model options - var options = this.options; - - // create ui elements - this._renderForm(options); - - // rebuild the underlying data structure - this.tree.finalize(); - - // show errors on startup - if (options.initial_errors) { - this._errors(options); - } - - // add refresh listener - this.on('refresh', function() { - // by using/resetting the deferred ajax queue the number of redundant calls is reduced - self.deferred.reset(); - self.deferred.execute(function(){self._updateModel()}); - }); - - // add reset listener - this.on('reset', function() { - for (var i in this.element_list) { - this.element_list[i].reset(); - } - }); - - // refresh - this.trigger('refresh'); - }, /** Renders the UI elements required for the form */ @@ -175,7 +173,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', // button for version selection var requirements_button = new Ui.ButtonIcon({ icon : 'fa-info-circle', - title : (!options.compact && 'Requirements') || null, + title : (!options.narrow && 'Requirements') || null, tooltip : 'Display tool requirements', onclick : function() { if (!this.visible) { @@ -200,7 +198,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', // button for version selection var versions_button = new Ui.ButtonMenu({ icon : 'fa-cubes', - title : (!options.compact && 'Versions') || null, + title : (!options.narrow && 'Versions') || null, tooltip : 'Select another tool version' }); if (options.versions && options.versions.length > 1) { @@ -213,8 +211,8 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', icon : 'fa-cube', onclick : function() { // here we update the tool version (some tools encode the version also in the id) - options.id = options.id.replace(options.version, this.version); - options.version = this.version; + self.options.id = self.options.id.replace(self.options.version, this.version); + self.options.version = this.version; // rebuild the model and form self.deferred.reset(); @@ -230,7 +228,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', // button menu var menu_button = new Ui.ButtonMenu({ icon : 'fa-caret-down', - title : (!options.compact && 'Options') || null, + title : (!options.narrow && 'Options') || null, tooltip : 'View available options' }); @@ -306,7 +304,7 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', }); // remove padding - if (options.compact) { + if (options.narrow) { this.portlet.$content.css('padding', '0px'); } diff --git a/static/scripts/mvc/tools/tools-form-workflow.js b/static/scripts/mvc/tools/tools-form-workflow.js index 6249164b837..49c3abf786f 100644 --- a/static/scripts/mvc/tools/tools-form-workflow.js +++ b/static/scripts/mvc/tools/tools-form-workflow.js @@ -21,9 +21,13 @@ define(['utils/utils', 'mvc/tools/tools-form-base'], this.options = options; // set labels - this.options.text_enable = 'In Advance'; - this.options.text_disable = 'At Runtime'; - this.options.use_defaults = true; + this.options.text_enable = 'In Advance'; + this.options.text_disable = 'At Runtime'; + + // configure workflow style + this.options.is_dynamic = false; + this.options.narrow = true; + this.options.initial_errors = true; // declare fields as optional Utils.deepeach(options.inputs, function(item) { diff --git a/static/scripts/mvc/tools/tools-form.js b/static/scripts/mvc/tools/tools-form.js index 94a0af0a7f4..94cf93f9622 100644 --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -24,7 +24,7 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } ToolFormBase.prototype.initialize.call(this, options); }, - + /** Builds a new model through api call and recreates the entire form */ _buildModel: function() { @@ -47,31 +47,28 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } } } - + // register process var process_id = this.deferred.register(); - + // get initial model Utils.request({ type : 'GET', url : model_url, success : function(response) { - // link model data update options - self.options = response; - - // build form - self._buildForm(); - + // build new tool form + self.build(response); + // notification self.message.update({ status : 'success', message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.', persistent : false }); - + // process completed self.deferred.done(process_id); - + // log success console.debug('tools-form::initialize() - Initial tool model ready.'); console.debug(response); @@ -79,11 +76,11 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools error : function(response) { // process completed self.deferred.done(process_id); - + // log error console.debug('tools-form::initialize() - Initial tool model request failed.'); console.debug(response); - + // show error var error_message = response.error || 'Uncaught error.'; self.modal.show({ @@ -98,7 +95,7 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } }); }, - + /** Request a new model for an already created tool form and updates the form inputs */ _updateModel: function() { @@ -112,11 +109,11 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools return null; } }); - + // log tool state console.debug('tools-form::_refreshForm() - Refreshing states.'); console.debug(current_state); - + // activates/disables spinner for dynamic fields to indicate that they are currently being updated function wait(active) { for (var i in self.input_list) { @@ -131,10 +128,10 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } } } - + // set wait mode wait(true); - + // register process var process_id = this.deferred.register(); @@ -179,13 +176,13 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools } } }); - + // unset wait mode wait(false); - + // process completed self.deferred.done(process_id); - + // log success console.debug('tools-form::_refreshForm() - States refreshed.'); console.debug(new_model); @@ -193,7 +190,7 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools error : function(response) { // process completed self.deferred.done(process_id); - + // log error console.debug('tools-form::_refreshForm() - Refresh request failed.'); console.debug(response); diff --git a/static/scripts/packed/mvc/tools/tools-form-base.js b/static/scripts/packed/mvc/tools/tools-form-base.js index ae8763891bc..885d25f7b1c 100644 --- a/static/scripts/packed/mvc/tools/tools-form-base.js +++ b/static/scripts/packed/mvc/tools/tools-form-base.js @@ -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"],function(g,h,f,k,i,a,d,c,e,j,b){return Backbone.View.extend({initialize:function(l){this.optionsDefault={is_dynamic:true,compact:false,initial_errors:false,use_defaults:false};this.options=g.merge(l,this.optionsDefault);console.debug(this.options);var m=parent.Galaxy;if(m&&m.modal){this.modal=m.modal}else{this.modal=new k.Modal.View()}if(m&&m.currUser){this.is_admin=m.currUser.get("is_admin")}else{this.is_admin=false}this.container=this.options.container||"body";this.deferred=new h();this.setElement("
");$(this.container).append(this.$el);this._buildForm()},reciept:function(l){$(this.container).empty();$(this.container).append(l)},highlight:function(m,n,l){var o=this.element_list[m];if(o){o.error(n||"Please verify this parameter.");if(!l){$(this.container).animate({scrollTop:o.$el.offset().top-20},500)}}},_errors:function(n){this.trigger("reset");if(n&&n.errors){var o=this.tree.matchResponse(n.errors);for(var m in this.element_list){var l=this.element_list[m];if(o[m]){this.highlight(m,o[m],true)}}}},_buildForm:function(){var l=this;this.off("refresh");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.tree=new b(this);this.content=new e(this);var m=this.options;this._renderForm(m);this.tree.finalize();if(m.initial_errors){this._errors(m)}this.on("refresh",function(){l.deferred.reset();l.deferred.execute(function(){l._updateModel()})});this.on("reset",function(){for(var n in this.element_list){this.element_list[n].reset()}});this.trigger("refresh")},_renderForm:function(u){var t=this;this.message=new k.Message();var q=new k.ButtonIcon({icon:"fa-info-circle",title:(!u.compact&&"Requirements")||null,tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;t.message.update({persistent:true,message:c.requirements(u),status:"info"})}else{this.visible=false;t.message.update({message:""})}}});if(!u.requirements||u.requirements.length==0){q.$el.hide()}var m=new k.ButtonMenu({icon:"fa-cubes",title:(!u.compact&&"Versions")||null,tooltip:"Select another tool version"});if(u.versions&&u.versions.length>1){for(var o in u.versions){var r=u.versions[o];if(r!=u.version){m.addMenu({title:"Switch to "+r,version:r,icon:"fa-cube",onclick:function(){u.id=u.id.replace(u.version,this.version);u.version=this.version;t.deferred.reset();t.deferred.execute(function(){t._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!u.compact&&"Options")||null,tooltip:"View available options"});if(u.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(u.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(u.biostar_url+"/t/"+u.id+"/")}})}p.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="+u.id)}});if(this.is_admin){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+u.id+"/download"}})}this.section=new j.View(t,{inputs:u.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:""+u.name+" "+u.description+" (Galaxy Tool Version "+u.version+")",cls:"ui-portlet-slim",operations:{requirements:q,menu:p,versions:m},buttons:this.buttons});if(u.compact){this.portlet.$content.css("padding","0px")}this.portlet.append(this.message.$el,true);this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(u.help!=""){this.$el.append(c.help(u.help))}if(u.citations){var s=$("");var l=new i.ToolCitationCollection();l.tool_id=u.id;var n=new a.CitationListView({el:s,collection:l});n.render();l.fetch();this.$el.append(s)}if(u.message){this.message.update({persistent:true,status:"warning",message:u.message})}}})}); \ 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"],function(g,h,f,k,i,a,d,c,e,j,b){return Backbone.View.extend({initialize:function(l){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false};this.options=g.merge(l,this.optionsDefault);console.debug(this.options);var m=parent.Galaxy;if(m&&m.modal){this.modal=m.modal}else{this.modal=new k.Modal.View()}if(m&&m.currUser){this.is_admin=m.currUser.get("is_admin")}else{this.is_admin=false}this.container=this.options.container||"body";this.deferred=new h();this.setElement("");$(this.container).append(this.$el);this.build(this.options)},build:function(m){var l=this;this.off("refresh");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.tree=new b(this);this.content=new e(this);l.options.inputs=m&&m.inputs;this._renderForm(m);this.tree.finalize();if(m.initial_errors){this._errors(m)}this.on("refresh",function(){l.deferred.reset();l.deferred.execute(function(){l._updateModel()})});this.on("reset",function(){for(var n in this.element_list){this.element_list[n].reset()}});this.trigger("refresh")},reciept:function(l){$(this.container).empty();$(this.container).append(l)},highlight:function(m,n,l){var o=this.element_list[m];if(o){o.error(n||"Please verify this parameter.");if(!l){$(this.container).animate({scrollTop:o.$el.offset().top-20},500)}}},_errors:function(n){this.trigger("reset");if(n&&n.errors){var o=this.tree.matchResponse(n.errors);for(var m in this.element_list){var l=this.element_list[m];if(o[m]){this.highlight(m,o[m],true)}}}},_renderForm:function(u){var t=this;this.message=new k.Message();var q=new k.ButtonIcon({icon:"fa-info-circle",title:(!u.narrow&&"Requirements")||null,tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;t.message.update({persistent:true,message:c.requirements(u),status:"info"})}else{this.visible=false;t.message.update({message:""})}}});if(!u.requirements||u.requirements.length==0){q.$el.hide()}var m=new k.ButtonMenu({icon:"fa-cubes",title:(!u.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(u.versions&&u.versions.length>1){for(var o in u.versions){var r=u.versions[o];if(r!=u.version){m.addMenu({title:"Switch to "+r,version:r,icon:"fa-cube",onclick:function(){t.options.id=t.options.id.replace(t.options.version,this.version);t.options.version=this.version;t.deferred.reset();t.deferred.execute(function(){t._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!u.narrow&&"Options")||null,tooltip:"View available options"});if(u.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(u.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(u.biostar_url+"/t/"+u.id+"/")}})}p.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="+u.id)}});if(this.is_admin){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+u.id+"/download"}})}this.section=new j.View(t,{inputs:u.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:""+u.name+" "+u.description+" (Galaxy Tool Version "+u.version+")",cls:"ui-portlet-slim",operations:{requirements:q,menu:p,versions:m},buttons:this.buttons});if(u.narrow){this.portlet.$content.css("padding","0px")}this.portlet.append(this.message.$el,true);this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(u.help!=""){this.$el.append(c.help(u.help))}if(u.citations){var s=$("");var l=new i.ToolCitationCollection();l.tool_id=u.id;var n=new a.CitationListView({el:s,collection:l});n.render();l.fetch();this.$el.append(s)}if(u.message){this.message.update({persistent:true,status:"warning",message:u.message})}}})}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-form-workflow.js b/static/scripts/packed/mvc/tools/tools-form-workflow.js index 9b5d73e5133..b98ffd58276 100644 --- a/static/scripts/packed/mvc/tools/tools-form-workflow.js +++ b/static/scripts/packed/mvc/tools/tools-form-workflow.js @@ -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.use_defaults=true;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