commit/galaxy-central: guerler: ToolForm: Activate rerun feature for new tool form, fix sliders, fix content labels
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/78124761ad55/ Changeset: 78124761ad55 User: guerler Date: 2014-10-15 20:06:03+00:00 Summary: ToolForm: Activate rerun feature for new tool form, fix sliders, fix content labels Affected #: 20 files diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd 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 @@ -97,7 +97,7 @@ // finalize data var current_state = this.tree.finalize({ data : function(dict) { - if (dict.values.length > 0 && dict.values[0].src === 'hda') { + if (dict.values.length > 0 && dict.values[0] && dict.values[0].src === 'hda') { return self.content.get({id: dict.values[0].id}).dataset_id; } return null; @@ -185,11 +185,11 @@ }); // switch to classic tool form mako if the form definition is incompatible - //if (this.incompatible) { + if (this.incompatible) { this.$el.hide(); $('#tool-form-classic').show(); return; - //} + } // create portlet this.portlet = new Portlet.View({ diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd 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 @@ -37,7 +37,7 @@ console.debug(job_def); // show progress modal - this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }}); + this.app.modal.show({title: 'Please wait...', body: 'progress', closing_events: true, buttons: { 'Close' : function () {self.app.modal.hide();} }}); // post job Utils.request({ @@ -59,6 +59,15 @@ } else { // show error message with details console.debug(response); + self.app.modal.show({ + title : 'Job submission failed', + body : ToolTemplate.error(job_def), + buttons : { + 'Close' : function() { + self.app.modal.hide(); + } + } + }); } } }); diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd 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 @@ -529,22 +529,12 @@ /** Slider field */ _fieldSlider: function(input_def) { - // set min/max - input_def.min = input_def.min || 0; - input_def.max = input_def.max || 100000; - - // calculate step size - var step = 1; - if (input_def.type == 'float') { - step = (input_def.max - input_def.min) / 10000; - } - // create slider return new Ui.Slider.View({ id : 'field-' + input_def.id, + precise : input_def.type == 'float', min : input_def.min, - max : input_def.max, - step : step + max : input_def.max }); }, diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-select-content.js --- a/client/galaxy/scripts/mvc/tools/tools-select-content.js +++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js @@ -40,7 +40,7 @@ var dataset_options = []; for (var i in datasets) { dataset_options.push({ - label: datasets[i].name, + label: datasets[i].hid + ': ' + datasets[i].name, value: datasets[i].id }); } @@ -67,7 +67,7 @@ var collection_options = []; for (var i in collections) { collection_options.push({ - label: collections[i].name, + label: collections[i].hid + ': ' + collections[i].name, value: collections[i].id }); } @@ -103,20 +103,34 @@ }, /** Return the currently selected dataset values */ - value : function () { - // identify select element - var select = null; - switch(this.current) { - case 'hda': - select = this.select_datasets; - break; - case 'hdca': - select = this.select_collection; - break; + value : function (dict) { + // update current value + if (dict !== undefined) { + if (dict.values.length > 0 && dict.values[0] && dict.values[0].src) { + // create list + var list = []; + for (var i in dict.values) { + list.push(dict.values[i].id); + } + + // set source + this.current = dict.values[0].src; + this.refresh(); + + // identify select element + switch(this.current) { + case 'hda': + this.select_datasets.value(list); + break; + case 'hdca': + this.select_collection.value(list[0]); + break; + } + } } // transform into an array - var id_list = select.value(); + var id_list = this._select().value(); if (!(id_list instanceof Array)) { id_list = [id_list]; } @@ -142,12 +156,7 @@ /** Validate current selection */ validate: function() { - switch(this.current) { - case 'hda': - return this.select_datasets.validate(); - case 'hdca': - return this.select_collection.validate(); - } + return this._select().validate(); }, /** Refreshes data selection view */ @@ -162,6 +171,16 @@ this.select_collection.$el.fadeIn(); break; } + }, + + /** Assists in selecting the current field */ + _select: function() { + switch(this.current) { + case 'hdca': + return this.select_collection; + default: + return this.select_datasets; + } } }); diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-template.js --- a/client/galaxy/scripts/mvc/tools/tools-template.js +++ b/client/galaxy/scripts/mvc/tools/tools-template.js @@ -49,7 +49,7 @@ error: function(job_def) { return '<div>' + '<p>' + - 'Sorry, the server could not complete the request. Please contact the Galaxy Team if this error is persistent.' + + 'The server could not complete the request. Please contact the Galaxy Team if this error persists.' + '</p>' + '<textarea class="ui-textarea" disabled style="color: black;" rows="6">' + JSON.stringify(job_def, undefined, 4) + diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/ui/ui-slider.js --- a/client/galaxy/scripts/mvc/ui/ui-slider.js +++ b/client/galaxy/scripts/mvc/ui/ui-slider.js @@ -6,9 +6,11 @@ // options optionsDefault: { value : '', - min : 1, - max : 100, - step : 1 + min : null, + max : null, + step : null, + precise : false, + split : 10000 }, // initialize @@ -18,19 +20,35 @@ // configure options this.options = Utils.merge(options, this.optionsDefault); - + // create new element this.setElement(this._template(this.options)); - // backup slider - this.$slider = this.$el.find('#slider'); + // determine wether to use the slider + this.useslider = this.options.max !== null && this.options.min !== null && this.options.max > this.options.min; + + // set default step size + if (this.options.step === null) { + this.options.step = 1; + if (this.options.precise && this.useslider) { + this.options.step = (this.options.max - this.options.min) / this.options.split; + } + } + + // create slider if min and max are defined properly + if (this.useslider) { + this.$slider = this.$el.find('#slider'); + this.$slider.slider(this.options); + this.$slider.on('slide', function (event, ui) { + self.value(ui.value); + }); + } else { + this.$el.find('.ui-form-slider-text').css('width', '100%'); + } // backup integer field this.$text = this.$el.find('#text'); - // load slider plugin - this.$slider.slider(this.options); - // add text field event this.$text.on('change', function () { self.value($(this).val()); @@ -39,24 +57,23 @@ // add text field event this.$text.on('keydown', function (event) { var v = event.which; - console.log(v); if (!(v == 8 || v == 9 || v == 13 || v == 37 || v == 39 || v == 189 || (v >= 48 && v <= 57) - || (self.options.step != 1 && $(this).val().indexOf('.') == -1) && v == 190)) { + || (self.options.precise && $(this).val().indexOf('.') == -1) && v == 190)) { event.preventDefault(); } }); - - // add slider event - this.$slider.on('slide', function (event, ui) { - self.value(ui.value); - }); }, // value value : function (new_val) { if (new_val !== undefined) { - // limit - new_val = Math.max(Math.min(new_val, this.options.max), this.options.min); + // apply limit + if (this.options.max !== null) { + new_val = Math.min(new_val, this.options.max); + } + if (this.options.min !== null) { + new_val = Math.max(new_val, this.options.min); + } // trigger on change event if (this.options.onchange) { @@ -64,7 +81,7 @@ } // set values - this.$slider.slider('value', new_val); + this.$slider && this.$slider.slider('value', new_val); this.$text.val(new_val); } diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1278,7 +1278,7 @@ def to_dict( self, trans, view='collection', value_mapper=None, other_values={} ): # call parent to_dict - d = super( ColumnListParameter, self ).to_dict( trans, other_values ) + d = super( ColumnListParameter, self ).to_dict( trans, other_values=other_values) # add data reference d['data_ref'] = self.data_ref @@ -1432,7 +1432,10 @@ call_other_values = { '__trans__': trans, '__value__': value } if other_values: call_other_values.update( other_values.dict ) - return eval( self.dynamic_options, self.tool.code_namespace, call_other_values ) + try: + return eval( self.dynamic_options, self.tool.code_namespace, call_other_values ) + except Exception: + return [] def get_options( self, trans=None, value=None, other_values={} ): if self.is_dynamic: diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-form.js --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -97,7 +97,7 @@ // finalize data var current_state = this.tree.finalize({ data : function(dict) { - if (dict.values.length > 0 && dict.values[0].src === 'hda') { + if (dict.values.length > 0 && dict.values[0] && dict.values[0].src === 'hda') { return self.content.get({id: dict.values[0].id}).dataset_id; } return null; @@ -185,11 +185,11 @@ }); // switch to classic tool form mako if the form definition is incompatible - //if (this.incompatible) { + if (this.incompatible) { this.$el.hide(); $('#tool-form-classic').show(); return; - //} + } // create portlet this.portlet = new Portlet.View({ diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-jobs.js --- a/static/scripts/mvc/tools/tools-jobs.js +++ b/static/scripts/mvc/tools/tools-jobs.js @@ -37,7 +37,7 @@ console.debug(job_def); // show progress modal - this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }}); + this.app.modal.show({title: 'Please wait...', body: 'progress', closing_events: true, buttons: { 'Close' : function () {self.app.modal.hide();} }}); // post job Utils.request({ @@ -59,6 +59,15 @@ } else { // show error message with details console.debug(response); + self.app.modal.show({ + title : 'Job submission failed', + body : ToolTemplate.error(job_def), + buttons : { + 'Close' : function() { + self.app.modal.hide(); + } + } + }); } } }); diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -529,22 +529,12 @@ /** Slider field */ _fieldSlider: function(input_def) { - // set min/max - input_def.min = input_def.min || 0; - input_def.max = input_def.max || 100000; - - // calculate step size - var step = 1; - if (input_def.type == 'float') { - step = (input_def.max - input_def.min) / 10000; - } - // create slider return new Ui.Slider.View({ id : 'field-' + input_def.id, + precise : input_def.type == 'float', min : input_def.min, - max : input_def.max, - step : step + max : input_def.max }); }, diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-select-content.js --- a/static/scripts/mvc/tools/tools-select-content.js +++ b/static/scripts/mvc/tools/tools-select-content.js @@ -40,7 +40,7 @@ var dataset_options = []; for (var i in datasets) { dataset_options.push({ - label: datasets[i].name, + label: datasets[i].hid + ': ' + datasets[i].name, value: datasets[i].id }); } @@ -67,7 +67,7 @@ var collection_options = []; for (var i in collections) { collection_options.push({ - label: collections[i].name, + label: collections[i].hid + ': ' + collections[i].name, value: collections[i].id }); } @@ -103,20 +103,34 @@ }, /** Return the currently selected dataset values */ - value : function () { - // identify select element - var select = null; - switch(this.current) { - case 'hda': - select = this.select_datasets; - break; - case 'hdca': - select = this.select_collection; - break; + value : function (dict) { + // update current value + if (dict !== undefined) { + if (dict.values.length > 0 && dict.values[0] && dict.values[0].src) { + // create list + var list = []; + for (var i in dict.values) { + list.push(dict.values[i].id); + } + + // set source + this.current = dict.values[0].src; + this.refresh(); + + // identify select element + switch(this.current) { + case 'hda': + this.select_datasets.value(list); + break; + case 'hdca': + this.select_collection.value(list[0]); + break; + } + } } // transform into an array - var id_list = select.value(); + var id_list = this._select().value(); if (!(id_list instanceof Array)) { id_list = [id_list]; } @@ -142,12 +156,7 @@ /** Validate current selection */ validate: function() { - switch(this.current) { - case 'hda': - return this.select_datasets.validate(); - case 'hdca': - return this.select_collection.validate(); - } + return this._select().validate(); }, /** Refreshes data selection view */ @@ -162,6 +171,16 @@ this.select_collection.$el.fadeIn(); break; } + }, + + /** Assists in selecting the current field */ + _select: function() { + switch(this.current) { + case 'hdca': + return this.select_collection; + default: + return this.select_datasets; + } } }); diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-template.js --- a/static/scripts/mvc/tools/tools-template.js +++ b/static/scripts/mvc/tools/tools-template.js @@ -49,7 +49,7 @@ error: function(job_def) { return '<div>' + '<p>' + - 'Sorry, the server could not complete the request. Please contact the Galaxy Team if this error is persistent.' + + 'The server could not complete the request. Please contact the Galaxy Team if this error persists.' + '</p>' + '<textarea class="ui-textarea" disabled style="color: black;" rows="6">' + JSON.stringify(job_def, undefined, 4) + diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/ui/ui-slider.js --- a/static/scripts/mvc/ui/ui-slider.js +++ b/static/scripts/mvc/ui/ui-slider.js @@ -6,9 +6,11 @@ // options optionsDefault: { value : '', - min : 1, - max : 100, - step : 1 + min : null, + max : null, + step : null, + precise : false, + split : 10000 }, // initialize @@ -18,19 +20,35 @@ // configure options this.options = Utils.merge(options, this.optionsDefault); - + // create new element this.setElement(this._template(this.options)); - // backup slider - this.$slider = this.$el.find('#slider'); + // determine wether to use the slider + this.useslider = this.options.max !== null && this.options.min !== null && this.options.max > this.options.min; + + // set default step size + if (this.options.step === null) { + this.options.step = 1; + if (this.options.precise && this.useslider) { + this.options.step = (this.options.max - this.options.min) / this.options.split; + } + } + + // create slider if min and max are defined properly + if (this.useslider) { + this.$slider = this.$el.find('#slider'); + this.$slider.slider(this.options); + this.$slider.on('slide', function (event, ui) { + self.value(ui.value); + }); + } else { + this.$el.find('.ui-form-slider-text').css('width', '100%'); + } // backup integer field this.$text = this.$el.find('#text'); - // load slider plugin - this.$slider.slider(this.options); - // add text field event this.$text.on('change', function () { self.value($(this).val()); @@ -39,24 +57,23 @@ // add text field event this.$text.on('keydown', function (event) { var v = event.which; - console.log(v); if (!(v == 8 || v == 9 || v == 13 || v == 37 || v == 39 || v == 189 || (v >= 48 && v <= 57) - || (self.options.step != 1 && $(this).val().indexOf('.') == -1) && v == 190)) { + || (self.options.precise && $(this).val().indexOf('.') == -1) && v == 190)) { event.preventDefault(); } }); - - // add slider event - this.$slider.on('slide', function (event, ui) { - self.value(ui.value); - }); }, // value value : function (new_val) { if (new_val !== undefined) { - // limit - new_val = Math.max(Math.min(new_val, this.options.max), this.options.min); + // apply limit + if (this.options.max !== null) { + new_val = Math.min(new_val, this.options.max); + } + if (this.options.min !== null) { + new_val = Math.max(new_val, this.options.min); + } // trigger on change event if (this.options.onchange) { @@ -64,7 +81,7 @@ } // set values - this.$slider.slider('value', new_val); + this.$slider && this.$slider.slider('value', new_val); this.$text.val(new_val); } diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-form.js --- a/static/scripts/packed/mvc/tools/tools-form.js +++ b/static/scripts/packed/mvc/tools/tools-form.js @@ -1,1 +1,1 @@ -define(["utils/utils","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,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(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.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},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.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of available operations."});p.addMenu({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/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.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="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});this.$el.hide();$("#tool-form-classic").show();return;this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},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(!this.options.biostar_url){button_question.$el.hide();button_search.$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 m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.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(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(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.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},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.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of available operations."});p.addMenu({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/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.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="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},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(!this.options.biostar_url){button_question.$el.hide();button_search.$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 m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}}); \ No newline at end of file diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd 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(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 +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",closing_events:true,buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.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(e);c.app.modal.show({title:"Job submission failed",body:a.error(d),buttons:{Close:function(){c.app.modal.hide()}}})}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(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 a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd 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","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(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,l>=h)}var j=new e({label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.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 +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(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,l>=h)}var j=new e({label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.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){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_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 a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-select-content.js --- a/static/scripts/packed/mvc/tools/tools-select-content.js +++ b/static/scripts/packed/mvc/tools/tools-select-content.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(n,h){this.options=h;var g=this;this.setElement("<div/>");this.current="hda";this.button_new=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Select datasets",value:"hda"},{icon:"fa-files-o",label:"Select a collection",value:"hdca"}],onchange:function(i){g.current=i;g.refresh();g.trigger("change")}});var l=n.content.filterType({src:"hda",extensions:h.extensions});var k=[];for(var j in l){k.push({label:l[j].name,value:l[j].id})}this.select_datasets=new e.Select.View({multiple:true,data:k,value:k[0]&&k[0].value,onchange:function(){g.trigger("change")}});var m=n.content.filterType({src:"hdca",extensions:h.extensions});var f=[];for(var j in m){f.push({label:m[j].name,value:m[j].id})}this.select_collection=new e.Select.View({data:f,value:f[0]&&f[0].value,onchange:function(){g.trigger("change")}});this.$el.append(c.wrap(this.button_new.$el));this.$el.append(this.select_datasets.$el);this.$el.append(this.select_collection.$el);if(!this.options.multiple){this.$el.append(a.batchMode())}this.refresh();this.on("change",function(){if(h.onchange){h.onchange(g.value())}})},value:function(){var g=null;switch(this.current){case"hda":g=this.select_datasets;break;case"hdca":g=this.select_collection;break}var j=g.value();if(!(j instanceof Array)){j=[j]}var f={batch:!this.options.multiple,values:[]};for(var h in j){f.values.push({id:j[h],src:this.current})}return f},validate:function(){switch(this.current){case"hda":return this.select_datasets.validate();case"hdca":return this.select_collection.validate()}},refresh:function(){switch(this.current){case"hda":this.select_datasets.$el.fadeIn();this.select_collection.$el.hide();break;case"hdca":this.select_datasets.$el.hide();this.select_collection.$el.fadeIn();break}}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(n,h){this.options=h;var g=this;this.setElement("<div/>");this.current="hda";this.button_new=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Select datasets",value:"hda"},{icon:"fa-files-o",label:"Select a collection",value:"hdca"}],onchange:function(i){g.current=i;g.refresh();g.trigger("change")}});var l=n.content.filterType({src:"hda",extensions:h.extensions});var k=[];for(var j in l){k.push({label:l[j].hid+": "+l[j].name,value:l[j].id})}this.select_datasets=new e.Select.View({multiple:true,data:k,value:k[0]&&k[0].value,onchange:function(){g.trigger("change")}});var m=n.content.filterType({src:"hdca",extensions:h.extensions});var f=[];for(var j in m){f.push({label:m[j].hid+": "+m[j].name,value:m[j].id})}this.select_collection=new e.Select.View({data:f,value:f[0]&&f[0].value,onchange:function(){g.trigger("change")}});this.$el.append(c.wrap(this.button_new.$el));this.$el.append(this.select_datasets.$el);this.$el.append(this.select_collection.$el);if(!this.options.multiple){this.$el.append(a.batchMode())}this.refresh();this.on("change",function(){if(h.onchange){h.onchange(g.value())}})},value:function(k){if(k!==undefined){if(k.values.length>0&&k.values[0]&&k.values[0].src){var j=[];for(var g in k.values){j.push(k.values[g].id)}this.current=k.values[0].src;this.refresh();switch(this.current){case"hda":this.select_datasets.value(j);break;case"hdca":this.select_collection.value(j[0]);break}}}var h=this._select().value();if(!(h instanceof Array)){h=[h]}var f={batch:!this.options.multiple,values:[]};for(var g in h){f.values.push({id:h[g],src:this.current})}return f},validate:function(){return this._select().validate()},refresh:function(){switch(this.current){case"hda":this.select_datasets.$el.fadeIn();this.select_collection.$el.hide();break;case"hdca":this.select_datasets.$el.hide();this.select_collection.$el.fadeIn();break}},_select:function(){switch(this.current){case"hdca":return this.select_collection;default:return this.select_datasets}}});return{View:d}}); \ No newline at end of file diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-template.js --- a/static/scripts/packed/mvc/tools/tools-template.js +++ b/static/scripts/packed/mvc/tools/tools-template.js @@ -1,1 +1,1 @@ -define([],function(){return{help:function(a){return'<div class="toolHelp"><div class="toolHelpBody">'+a+"</div></div>"},citations:function(){return'<div id="citations"></div>'},success:function(c){if(!c.jobs||!c.jobs.length){console.debug("tools-template::success() - Failed jobs.");return}var a=c.jobs.length;var d="";if(a==1){d="1 job has"}else{d=a+" jobs have been"}var b='<div class="donemessagelarge"><p>'+d+" been successfully added to the queue - resulting in the following datasets:</p>";for(var e in c.outputs){b+='<p style="padding: 10px 20px;"><b>'+(parseInt(e)+1)+": "+c.outputs[e].name+"</b></p>"}b+="<p>You can check the status of queued jobs and view the resulting data by refreshing the History pane. When the job has been run the status will change from 'running' to 'finished' if completed successfully or 'error' if problems were encountered.</p></div>";return b},error:function(a){return'<div><p>Sorry, the server could not complete the request. Please contact the Galaxy Team if this error is persistent.</p><textarea class="ui-textarea" disabled style="color: black;" rows="6">'+JSON.stringify(a,undefined,4)+"</textarea></div>"},batchMode:function(){return'<div class="ui-table-form-info"><i class="fa fa-sitemap" style="font-size: 1.2em; padding: 2px 5px;"/>This is a batch mode input field. A separate job will be triggered for each dataset.';"</div>"}}}); \ No newline at end of file +define([],function(){return{help:function(a){return'<div class="toolHelp"><div class="toolHelpBody">'+a+"</div></div>"},citations:function(){return'<div id="citations"></div>'},success:function(c){if(!c.jobs||!c.jobs.length){console.debug("tools-template::success() - Failed jobs.");return}var a=c.jobs.length;var d="";if(a==1){d="1 job has"}else{d=a+" jobs have been"}var b='<div class="donemessagelarge"><p>'+d+" been successfully added to the queue - resulting in the following datasets:</p>";for(var e in c.outputs){b+='<p style="padding: 10px 20px;"><b>'+(parseInt(e)+1)+": "+c.outputs[e].name+"</b></p>"}b+="<p>You can check the status of queued jobs and view the resulting data by refreshing the History pane. When the job has been run the status will change from 'running' to 'finished' if completed successfully or 'error' if problems were encountered.</p></div>";return b},error:function(a){return'<div><p>The server could not complete the request. Please contact the Galaxy Team if this error persists.</p><textarea class="ui-textarea" disabled style="color: black;" rows="6">'+JSON.stringify(a,undefined,4)+"</textarea></div>"},batchMode:function(){return'<div class="ui-table-form-info"><i class="fa fa-sitemap" style="font-size: 1.2em; padding: 2px 5px;"/>This is a batch mode input field. A separate job will be triggered for each dataset.';"</div>"}}}); \ No newline at end of file diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/ui/ui-slider.js --- a/static/scripts/packed/mvc/ui/ui-slider.js +++ b/static/scripts/packed/mvc/ui/ui-slider.js @@ -1,1 +1,1 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",min:1,max:100,step:1},initialize:function(d){var c=this;this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$slider=this.$el.find("#slider");this.$text=this.$el.find("#text");this.$slider.slider(this.options);this.$text.on("change",function(){c.value($(this).val())});this.$text.on("keydown",function(f){var e=f.which;console.log(e);if(!(e==8||e==9||e==13||e==37||e==39||e==189||(e>=48&&e<=57)||(c.options.step!=1&&$(this).val().indexOf(".")==-1)&&e==190)){f.preventDefault()}});this.$slider.on("slide",function(e,f){c.value(f.value)})},value:function(c){if(c!==undefined){c=Math.max(Math.min(c,this.options.max),this.options.min);if(this.options.onchange){this.options.onchange(c)}this.$slider.slider("value",c);this.$text.val(c)}return this.$text.val()},_template:function(c){return'<div id="'+c.id+'" class="ui-form-slider"><input id="text" type="text" class="ui-form-slider-text"/><div id="slider" class="ui-form-slider-element"/></div>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",min:null,max:null,step:null,precise:false,split:10000},initialize:function(d){var c=this;this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.useslider=this.options.max!==null&&this.options.min!==null&&this.options.max>this.options.min;if(this.options.step===null){this.options.step=1;if(this.options.precise&&this.useslider){this.options.step=(this.options.max-this.options.min)/this.options.split}}if(this.useslider){this.$slider=this.$el.find("#slider");this.$slider.slider(this.options);this.$slider.on("slide",function(e,f){c.value(f.value)})}else{this.$el.find(".ui-form-slider-text").css("width","100%")}this.$text=this.$el.find("#text");this.$text.on("change",function(){c.value($(this).val())});this.$text.on("keydown",function(f){var e=f.which;if(!(e==8||e==9||e==13||e==37||e==39||e==189||(e>=48&&e<=57)||(c.options.precise&&$(this).val().indexOf(".")==-1)&&e==190)){f.preventDefault()}})},value:function(c){if(c!==undefined){if(this.options.max!==null){c=Math.min(c,this.options.max)}if(this.options.min!==null){c=Math.max(c,this.options.min)}if(this.options.onchange){this.options.onchange(c)}this.$slider&&this.$slider.slider("value",c);this.$text.val(c)}return this.$text.val()},_template:function(c){return'<div id="'+c.id+'" class="ui-form-slider"><input id="text" type="text" class="ui-form-slider-text"/><div id="slider" class="ui-form-slider-element"/></div>'}});return{View:b}}); \ No newline at end of file diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd templates/webapps/galaxy/tool_form_refresh.mako --- a/templates/webapps/galaxy/tool_form_refresh.mako +++ b/templates/webapps/galaxy/tool_form_refresh.mako @@ -4,30 +4,55 @@ tool_model = tool.to_dict(trans) tool_model['inputs'] = {} - ## sanitize + ## convert value to jsonifiable value + def convert(v): + # check if value is numeric + isnumber = False + try: + float(v) + isnumber = True + except Exception: + pass + + ## fix hda parsing + if isinstance(v, HistoryDatasetAssociation): + return { + 'id' : trans.security.encode_id(v.id), + 'src' : 'hda' + } + elif isinstance(v, basestring) or isnumber: + return v + else: + return None + + ## ensures that input dictionary is jsonifiable from collections import Iterable from galaxy.model import HistoryDatasetAssociation def sanitize(dict): - # quotations for Infinity so its jsonifiable + ## quotations for Infinity so its jsonifiable for name in dict: if dict[name] == Infinity: dict[name] = 'Infinity' - value = dict['value'] if 'value' in dict else None; - # check if value is numeric - def isnumber(s): - try: - float(s) - return True - except Exception: - return False - # fix hda parsing - if isinstance(value, HistoryDatasetAssociation): + + ## get current value + value = dict['value'] if 'value' in dict else None + + ## identify lists + if dict['type'] == 'data': + if isinstance(value, list): + value = [ convert(v) for v in value ] + else: + value = [ convert(value) ] value = { - 'id' : trans.security.encode_id(value.dataset_id), - 'src' : 'hda' + 'batch' : dict['multiple'], + 'values' : value } - elif value and not (isinstance(value, basestring) or isnumber(value) or isinstance(value, Iterable)): - value = 'Unsupported' + elif isinstance(value, list): + value = [ convert(v) for v in value ] + else: + value = convert(value) + + ## update and return dict['value'] = value return dict @@ -52,7 +77,7 @@ elif input.type == "conditional": try: test_param = group_inputs[input_index]['test_param'] - test_param['value'] = tool_state[test_param['name']] + test_param['value'] = group_state[test_param['name']] except Exception: pass i = group_state['__current_case__'] @@ -65,7 +90,7 @@ except Exception: pass - ## update input value from tool state and sanitize dictionary + ## update input value from tool state try: group_inputs[input_index]['value'] = tool_state[group_inputs[input_index]['name']] group_inputs[input_index] = sanitize(group_inputs[input_index]) 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