commit/galaxy-central: guerler: ToolForm: Place requirements into pulldown menu, add toolshed link, remove spaces
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/1bb9dcb87c49/ Changeset: 1bb9dcb87c49 User: guerler Date: 2015-02-11 03:13:42+00:00 Summary: ToolForm: Place requirements into pulldown menu, add toolshed link, remove spaces Affected #: 4 files diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 client/galaxy/scripts/mvc/tools/tools-form-base.js --- a/client/galaxy/scripts/mvc/tools/tools-form-base.js +++ b/client/galaxy/scripts/mvc/tools/tools-form-base.js @@ -22,13 +22,13 @@ // portlet style cls_portlet : 'ui-portlet-limited' }; - + // configure options this.options = Utils.merge(options, this.optionsDefault); - + // log options console.debug(this.options); - + // link galaxy modal or create one var galaxy = parent.Galaxy; if (galaxy && galaxy.modal) { @@ -36,84 +36,84 @@ } else { this.modal = new Ui.Modal.View(); } - + // check if the user is an admin if (galaxy && galaxy.currUser) { this.is_admin = galaxy.currUser.get('is_admin'); } else { this.is_admin = false; } - + // link container this.container = this.options.container || 'body'; - + // create deferred processing queue handler // this handler reduces the number of requests to the api by filtering redundant requests this.deferred = new Deferred(); - + // set element this.setElement('<div/>'); - + // add to main element $(this.container).append(this.$el); - + // build this form 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'); }, @@ -124,7 +124,7 @@ $(this.container).empty(); $(this.container).append($el); }, - + /** Highlight and scroll to input element (currently only used for error notifications) */ highlight: function (input_id, message, silent) { @@ -144,7 +144,7 @@ } } }, - + /** Highlights errors */ _errors: function(options) { @@ -168,35 +168,10 @@ _renderForm: function(options) { // link this var self = this; - + // create message view this.message = new Ui.Message(); - - // button for version selection - var requirements_button = new Ui.ButtonIcon({ - icon : 'fa-info-circle', - title : (!options.narrow && 'Requirements') || null, - tooltip : 'Display tool requirements', - onclick : function() { - if (!this.visible) { - this.visible = true; - self.message.update({ - persistent : true, - message : ToolTemplate.requirements(options), - status : 'info' - }); - } else { - this.visible = false; - self.message.update({ - message : '' - }); - } - } - }); - if (!options.requirements || options.requirements.length == 0) { - requirements_button.$el.hide(); - } - + // button for version selection var versions_button = new Ui.ButtonMenu({ icon : 'fa-cubes', @@ -226,14 +201,14 @@ } else { versions_button.$el.hide(); } - + // button menu var menu_button = new Ui.ButtonMenu({ icon : 'fa-caret-down', title : (!options.narrow && 'Options') || null, tooltip : 'View available options' }); - + // configure button selection if(options.biostar_url) { // add question option @@ -256,7 +231,7 @@ } }); }; - + // create share button menu_button.addMenu({ icon : 'fa-share', @@ -266,7 +241,7 @@ prompt('Copy to clipboard: Ctrl+C, Enter', window.location.origin + galaxy_config.root + 'root?tool_id=' + options.id); } }); - + // add admin operations if (this.is_admin) { // create download button @@ -279,47 +254,83 @@ } }); } - + + // button for version selection + if (options.requirements && options.requirements.length > 0) { + menu_button.addMenu({ + icon : 'fa-info-circle', + title : 'Requirements', + tooltip : 'Display tool requirements', + onclick : function() { + if (!this.visible) { + this.visible = true; + self.message.update({ + persistent : true, + message : ToolTemplate.requirements(options), + status : 'info' + }); + } else { + this.visible = false; + self.message.update({ + message : '' + }); + } + } + }); + } + + + // add toolshed url + if (this.options.sharable_url) { + menu_button.addMenu({ + icon : 'fa-external-link', + title : 'Open in Toolshed', + tooltip : 'Access the repository', + onclick : function() { + window.open(self.options.sharable_url); + } + }); + } + // create tool form section this.section = new ToolSection.View(self, { inputs : options.inputs }); - + // 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>' + options.name + '</b> ' + options.description + ' (Galaxy Tool Version ' + options.version + ')', cls : this.options.cls_portlet, operations: { - requirements : requirements_button, - menu : menu_button, - versions : versions_button + menu : menu_button, + versions : versions_button }, buttons : this.buttons }); - + // append message this.portlet.append(this.message.$el.addClass('ui-margin-top')); - + // append tool section this.portlet.append(this.section.$el); - + // start form this.$el.empty(); this.$el.append(this.portlet.$el); - + // append help if (options.help != '') { this.$el.append(ToolTemplate.help(options.help)); } - + // append citations if (options.citations) { var $citations = $('<div/>'); @@ -330,7 +341,7 @@ citations.fetch(); this.$el.append($citations); } - + // show message if available in model if (options.message) { this.message.update({ diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2520,7 +2520,7 @@ for t in tools: tool_versions.append(t.version) - ## add information with underlying requirements and their versions + # add information with underlying requirements and their versions tool_requirements = [] if self.requirements: for requirement in self.requirements: @@ -2529,11 +2529,17 @@ 'version' : requirement.version }) + # add toolshed url + sharable_url = None + if self.tool_shed_repository: + sharable_url = self.tool_shed_repository.get_sharable_url( trans.app ) + # add additional properties tool_model.update({ 'help' : tool_help, 'citations' : tool_citations, 'biostar_url' : trans.app.config.biostar_url, + 'sharable_url' : sharable_url, 'message' : tool_message, 'versions' : tool_versions, 'requirements' : tool_requirements, diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 static/scripts/mvc/tools/tools-form-base.js --- a/static/scripts/mvc/tools/tools-form-base.js +++ b/static/scripts/mvc/tools/tools-form-base.js @@ -22,13 +22,13 @@ // portlet style cls_portlet : 'ui-portlet-limited' }; - + // configure options this.options = Utils.merge(options, this.optionsDefault); - + // log options console.debug(this.options); - + // link galaxy modal or create one var galaxy = parent.Galaxy; if (galaxy && galaxy.modal) { @@ -36,84 +36,84 @@ } else { this.modal = new Ui.Modal.View(); } - + // check if the user is an admin if (galaxy && galaxy.currUser) { this.is_admin = galaxy.currUser.get('is_admin'); } else { this.is_admin = false; } - + // link container this.container = this.options.container || 'body'; - + // create deferred processing queue handler // this handler reduces the number of requests to the api by filtering redundant requests this.deferred = new Deferred(); - + // set element this.setElement('<div/>'); - + // add to main element $(this.container).append(this.$el); - + // build this form 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'); }, @@ -124,7 +124,7 @@ $(this.container).empty(); $(this.container).append($el); }, - + /** Highlight and scroll to input element (currently only used for error notifications) */ highlight: function (input_id, message, silent) { @@ -144,7 +144,7 @@ } } }, - + /** Highlights errors */ _errors: function(options) { @@ -168,35 +168,10 @@ _renderForm: function(options) { // link this var self = this; - + // create message view this.message = new Ui.Message(); - - // button for version selection - var requirements_button = new Ui.ButtonIcon({ - icon : 'fa-info-circle', - title : (!options.narrow && 'Requirements') || null, - tooltip : 'Display tool requirements', - onclick : function() { - if (!this.visible) { - this.visible = true; - self.message.update({ - persistent : true, - message : ToolTemplate.requirements(options), - status : 'info' - }); - } else { - this.visible = false; - self.message.update({ - message : '' - }); - } - } - }); - if (!options.requirements || options.requirements.length == 0) { - requirements_button.$el.hide(); - } - + // button for version selection var versions_button = new Ui.ButtonMenu({ icon : 'fa-cubes', @@ -226,14 +201,14 @@ } else { versions_button.$el.hide(); } - + // button menu var menu_button = new Ui.ButtonMenu({ icon : 'fa-caret-down', title : (!options.narrow && 'Options') || null, tooltip : 'View available options' }); - + // configure button selection if(options.biostar_url) { // add question option @@ -256,7 +231,7 @@ } }); }; - + // create share button menu_button.addMenu({ icon : 'fa-share', @@ -266,7 +241,7 @@ prompt('Copy to clipboard: Ctrl+C, Enter', window.location.origin + galaxy_config.root + 'root?tool_id=' + options.id); } }); - + // add admin operations if (this.is_admin) { // create download button @@ -279,47 +254,83 @@ } }); } - + + // button for version selection + if (options.requirements && options.requirements.length > 0) { + menu_button.addMenu({ + icon : 'fa-info-circle', + title : 'Requirements', + tooltip : 'Display tool requirements', + onclick : function() { + if (!this.visible) { + this.visible = true; + self.message.update({ + persistent : true, + message : ToolTemplate.requirements(options), + status : 'info' + }); + } else { + this.visible = false; + self.message.update({ + message : '' + }); + } + } + }); + } + + + // add toolshed url + if (this.options.sharable_url) { + menu_button.addMenu({ + icon : 'fa-external-link', + title : 'Open in Toolshed', + tooltip : 'Access the repository', + onclick : function() { + window.open(self.options.sharable_url); + } + }); + } + // create tool form section this.section = new ToolSection.View(self, { inputs : options.inputs }); - + // 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>' + options.name + '</b> ' + options.description + ' (Galaxy Tool Version ' + options.version + ')', cls : this.options.cls_portlet, operations: { - requirements : requirements_button, - menu : menu_button, - versions : versions_button + menu : menu_button, + versions : versions_button }, buttons : this.buttons }); - + // append message this.portlet.append(this.message.$el.addClass('ui-margin-top')); - + // append tool section this.portlet.append(this.section.$el); - + // start form this.$el.empty(); this.$el.append(this.portlet.$el); - + // append help if (options.help != '') { this.$el.append(ToolTemplate.help(options.help)); } - + // append citations if (options.citations) { var $citations = $('<div/>'); @@ -330,7 +341,7 @@ citations.fetch(); this.$el.append($citations); } - + // show message if available in model if (options.message) { this.message.update({ diff -r 0afbc9b476c5cd7ebf827b834628c877f75fe3e6 -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 static/scripts/packed/mvc/tools/tools-form-base.js --- a/static/scripts/packed/mvc/tools/tools-form-base.js +++ b/static/scripts/packed/mvc/tools/tools-form-base.js @@ -1,1 +1,1 @@ -define(["utils/utils","utils/deferred","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree"],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,cls_portlet:"ui-portlet-limited"};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("<div/>");$(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:"<b>"+u.name+"</b> "+u.description+" (Galaxy Tool Version "+u.version+")",cls:this.options.cls_portlet,operations:{requirements:q,menu:p,versions:m},buttons:this.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));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=$("<div/>");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,cls_portlet:"ui-portlet-limited"};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("<div/>");$(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(t){var s=this;this.message=new k.Message();var m=new k.ButtonMenu({icon:"fa-cubes",title:(!t.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(t.versions&&t.versions.length>1){for(var o in t.versions){var q=t.versions[o];if(q!=t.version){m.addMenu({title:"Switch to "+q,version:q,icon:"fa-cube",onclick:function(){s.options.id=s.options.id.replace(s.options.version,this.version);s.options.version=this.version;s.deferred.reset();s.deferred.execute(function(){s._buildModel()})}})}}}else{m.$el.hide()}var p=new k.ButtonMenu({icon:"fa-caret-down",title:(!t.narrow&&"Options")||null,tooltip:"View available options"});if(t.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(t.biostar_url+"/t/"+t.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="+t.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/"+t.id+"/download"}})}if(t.requirements&&t.requirements.length>0){p.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;s.message.update({persistent:true,message:c.requirements(t),status:"info"})}else{this.visible=false;s.message.update({message:""})}}})}if(this.options.sharable_url){p.addMenu({icon:"fa-external-link",title:"Open in Toolshed",tooltip:"Access the repository",onclick:function(){window.open(s.options.sharable_url)}})}this.section=new j.View(s,{inputs:t.inputs});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new f.View({icon:"fa-wrench",title:"<b>"+t.name+"</b> "+t.description+" (Galaxy Tool Version "+t.version+")",cls:this.options.cls_portlet,operations:{menu:p,versions:m},buttons:this.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(t.help!=""){this.$el.append(c.help(t.help))}if(t.citations){var r=$("<div/>");var l=new i.ToolCitationCollection();l.tool_id=t.id;var n=new a.CitationListView({el:r,collection:l});n.render();l.fetch();this.$el.append(r)}if(t.message){this.message.update({persistent:true,status:"warning",message:t.message})}}})}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org