1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e5e05b2b242a/ Changeset: e5e05b2b242a User: guerler Date: 2014-09-03 21:30:50 Summary: ToolForm: Adjustments and refactoring Affected #: 9 files diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -459,6 +459,13 @@ else: return self.falsevalue + def to_dict( self, trans, view='collection', value_mapper=None ): + d = super( ToolParameter, self ).to_dict() + d['value'] = self.checked + d['truevalue'] = self.truevalue + d['falsevalue'] = self.falsevalue + return d + @property def legal_values( self ): return [ self.truevalue, self.falsevalue ] @@ -992,7 +999,8 @@ value = option[1] d[ 'value' ] = value - d[ 'display' ] = self.display + d['display'] = self.display + d['multiple'] = self.multiple return d @@ -1251,7 +1259,10 @@ d = super( ColumnListParameter, self ).to_dict( trans ) # add data reference - d[ 'data_ref' ] = self.data_ref + d['data_ref'] = self.data_ref + + # add numerical flag + d['numerical'] = self.numerical # return return d @@ -2008,6 +2019,11 @@ ref = ref() return ref + def to_dict( self, trans, view='collection', value_mapper=None ): + d = super( DataToolParameter, self ).to_dict( trans ) + d['extensions'] = self.extensions + d['multiple'] = self.multiple + return d class DataCollectionToolParameter( BaseDataToolParameter ): """ diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae static/scripts/mvc/tools/tools-form.js --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -38,9 +38,6 @@ // reset sequential input definition list this.input_list = {}; - // create data model - this.data = new Backbone.Model(); - // initialize datasets this.datasets = new ToolDatasets({ success: function() { diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -11,12 +11,6 @@ // link inputs this.inputs = options.inputs; - // link datasets - this.datasets = app.datasets; - - // link data model - this.data = app.data; - // add table class for tr tag // this assist in transforming the form into a json structure options.cls_tr = 'section-row'; @@ -38,12 +32,12 @@ // load settings elements into table for (var i in this.inputs) { - this._add(this.inputs[i], this.data); + this._add(this.inputs[i]); } }, // add table row - _add: function(input, data) { + _add: function(input) { // link this var self = this; @@ -61,7 +55,7 @@ switch(type) { // conditional field case 'conditional': - this._addConditional(input_def, data); + this._addConditional(input_def); break; // repeat block case 'repeat': @@ -69,12 +63,12 @@ break; // default single element row default: - this._addRow(type, input_def, data); + this._addRow(type, input_def); } }, // add conditional block - _addConditional: function(input_def, data) { + _addConditional: function(input_def) { // add label to input definition root input_def.label = input_def.test_param.label; @@ -82,7 +76,7 @@ input_def.value = input_def.test_param.value; // build options field - this._addRow('conditional', input_def, data); + this._addRow('conditional', input_def); // add fields for (var i in input_def.cases) { @@ -182,7 +176,7 @@ }, // add table row - _addRow: function(field_type, input_def, data) { + _addRow: function(field_type, input_def) { // get id var id = input_def.id; @@ -193,65 +187,64 @@ switch(field_type) { // text input field case 'text' : - field = this._field_text(input_def, data); + field = this._field_text(input_def); break; // select field case 'select' : - field = this._field_select(input_def, data); + field = this._field_select(input_def); break; - // radiobox field - case 'radiobutton' : - field = this._field_radio(input_def, data); - break; - // dataset case 'data': - field = this._field_data(input_def, data); + field = this._field_data(input_def); break; // dataset column case 'data_column': - field = this._field_column(input_def, data); + field = this._field_column(input_def); break; // text area field case 'textarea' : - field = this._field_textarea(input_def, data); + field = this._field_textarea(input_def); break; // conditional select field case 'conditional': - field = this._field_conditional(input_def, data); + field = this._field_conditional(input_def); break; // hidden field case 'hidden': - field = this._field_hidden(input_def, data); + field = this._field_hidden(input_def); break; // integer field case 'integer': - field = this._field_integer(input_def, data); + field = this._field_slider(input_def); break; + // float field + case 'float': + field = this._field_slider(input_def); + break; + // boolean field case 'boolean': - field = this._field_radiobutton(input_def, data); + field = this._field_boolean(input_def); break; // default default: - field = this._field_text(input_def, data); + field = this._field_text(input_def); console.debug('tools-form::_addRow() : Unmatched field type (' + field_type + ').'); } - // set value - if (!data.get(id)) { - data.set(id, input_def.value); + // set field value + if (input_def.value !== undefined) { + field.value(input_def.value); } - field.value(data.get(id)); // add to field list this.app.field_list[id] = field; @@ -272,7 +265,7 @@ }, // conditional input field - _field_conditional : function(input_def, data) { + _field_conditional : function(input_def) { // link this var self = this; @@ -287,15 +280,10 @@ } // select field - var id = input_def.id; return new Ui.Select.View({ - id : 'field-' + id, + id : 'field-' + input_def.id, data : options, - value : data.get(id), onchange : function(value) { - // update value - data.set(id, value); - // check value in order to hide/show options for (var i in input_def.cases) { // get case @@ -329,7 +317,7 @@ }, // data input field - _field_data : function(input_def, data) { + _field_data : function(input_def) { // link this var self = this; @@ -337,7 +325,7 @@ var id = input_def.id; // get datasets - var datasets = this.datasets.filterType(); + var datasets = this.app.datasets.filterType(); // configure options fields var options = []; @@ -354,14 +342,11 @@ data : options, value : options[0].value, onchange : function(value) { - // update value - data.set(id, value); - // get referenced columns - var column_list = self.app.tree.findReferences(id); + var column_list = self.app.tree.findReferences(id, 'data_column'); // find selected dataset - var dataset = self.datasets.filter(value); + var dataset = self.app.datasets.filter(value); // check dataset if (dataset && column_list.length > 0) { @@ -376,19 +361,34 @@ console.debug('tool-form::field_data() - FAILED: Could not find metadata for dataset ' + value + '.'); } - // load column options - var columns = []; - for (var key in meta) { - // add to selection - columns.push({ - 'label' : 'Column: ' + (parseInt(key) + 1) + ' [' + meta[key] + ']', - 'value' : key - }); - } - // update referenced columns for (var i in column_list) { - var column_field = self.app.field_list[column_list[i]] + // get column input/field + var column_input = self.app.input_list[column_list[i]]; + var column_field = self.app.field_list[column_list[i]]; + if (!column_input || !column_field) { + console.debug('tool-form::field_data() - FAILED: Column not found.'); + } + + // is numerical? + var numerical = column_input.numerical; + + // identify column options + var columns = []; + for (var key in meta) { + // get column type + var column_type = meta[key]; + + // add to selection + if (column_type == 'int' || column_type == 'float' || !numerical) { + columns.push({ + 'label' : 'Column: ' + (parseInt(key) + 1) + ' [' + meta[key] + ']', + 'value' : key + }); + } + } + + // update field if (column_field) { column_field.update(columns); if (!column_field.exists(column_field.value())) { @@ -404,20 +404,8 @@ }); }, - // column selection field - _field_column : function (input_def, data) { - var id = input_def.id; - return new Ui.Select.View({ - id : 'field-' + id, - value : data.get(id), - onchange : function(value) { - data.set(id, value); - } - }); - }, - // select field - _field_select : function (input_def, data) { + _field_select : function (input_def) { // configure options fields var options = []; for (var i in input_def.options) { @@ -430,95 +418,66 @@ // identify display type var SelectClass = Ui.Select; - if (input_def.display == 'checkboxes') { - SelectClass = Ui.Checkbox; + switch (input_def.display) { + case 'checkboxes': + SelectClass = Ui.Checkbox; + break; + case 'radio': + SelectClass = Ui.RadioButton; + break; } // select field - var id = input_def.id; return new SelectClass.View({ - id : 'field-' + id, - data : options, - value : data.get(id), - onchange : function(value) { - data.set(id, value); - } + id : 'field-' + input_def.id, + data : options }); }, - + + // column selection field + _field_column : function (input_def) { + return new Ui.Select.View({ + id : 'field-' + input_def.id + }); + }, + // text input field - _field_text : function(input_def, data) { - var id = input_def.id; + _field_text : function(input_def) { return new Ui.Input({ - id : 'field-' + id, - value : data.get(id), - onchange : function(value) { - data.set(id, value); - } + id : 'field-' + input_def.id }); }, // integer field - _field_integer: function(input_def, data) { - var id = input_def.id; + _field_slider: function(input_def) { return new Ui.Slider.View({ - id : 'field-' + id, - value : data.get(id), - onchange : function(value) { - data.set(id, value); - } + id : 'field-' + input_def.id, + min : input_def.min || 0, + max : input_def.max || 1000, + decimal : input_def.type == 'float' }); }, // text area - _field_textarea : function(input_def, data) { - var id = input_def.id; + _field_textarea : function(input_def) { return new Ui.Textarea({ - id : 'field-' + id, - onchange : function() { - data.set(id, field.value()); - } - }); - }, - - // radio field - _field_radio : function(input_def, data) { - var id = input_def.id; - return new Ui.RadioButton({ - id : 'field-' + id, - data : input_def.data, - value : data.get(id), - onchange : function(value) { - data.set(id, value); - } + id : 'field-' + input_def.id }); }, // hidden field - _field_hidden : function(input_def, data) { - var id = input_def.id; + _field_hidden : function(input_def) { return new Ui.Hidden({ - id : 'field-' + id, - value : data.get(id) + id : 'field-' + input_def.id }); }, - // hidden field - _field_radiobutton : function(input_def, data) { - var id = input_def.id; + // boolean field + _field_boolean : function(input_def) { return new Ui.RadioButton.View({ - id : 'field-' + id, - value : data.get(id), - data : [ - { - label : 'Yes', - value : 'true' - }, - { - label : 'No', - value : 'false' - } - ] + id : 'field-' + input_def.id, + data : [ { label : 'Yes', value : true }, + { label : 'No', value : false }] }); } }); diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae static/scripts/mvc/tools/tools-tree.js --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -66,7 +66,7 @@ }, // find referenced elements - findReferences: function(identifier) { + findReferences: function(identifier, type) { // referenced elements var referenced = []; @@ -105,7 +105,7 @@ } // check for referenced element - if (input.data_ref == name) { + if (input.data_ref == name && input.type == type) { list.push(id); } } diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae static/scripts/mvc/ui/ui-slider.js --- a/static/scripts/mvc/ui/ui-slider.js +++ b/static/scripts/mvc/ui/ui-slider.js @@ -7,7 +7,9 @@ optionsDefault: { value : '', min : 1, - max : 100 + max : 100, + step : 0.1, + decimal : false }, // initialize @@ -27,6 +29,11 @@ // backup integer field this.$text = this.$el.find('#text'); + // set step size + if (!this.options.decimal) { + this.options.step = 1; + } + // load slider plugin this.$slider.slider(this.options); @@ -38,7 +45,8 @@ // add text field event this.$text.on('keydown', function (event) { var v = event.which; - if (!(v == 13 || v == 8 || v == 189 || (v >= 48 && v <= 57))) { + if (!(v == 13 || v == 8 || v == 37 || v == 39 || v == 189 || (v >= 48 && v <= 57) + || (self.options.decimal && $(this).val().indexOf('.') == -1) && v == 190)) { event.preventDefault(); } }); diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae static/scripts/packed/mvc/tools/tools-form.js --- a/static/scripts/packed/mvc/tools/tools-form.js +++ b/static/scripts/packed/mvc/tools/tools-form.js @@ -1,1 +1,1 @@ -define(["mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-datasets","mvc/tools/tools-section","mvc/tools/tools-tree"],function(g,k,i,a,f,d,h,j,c){var e=Backbone.Model.extend({initialize:function(l){this.url=galaxy_config.root+"api/tools/"+l.id+"?io_details=true"}});var b=Backbone.View.extend({main_el:"body",initialize:function(m){var l=this;this.options=m;this.model=new e({id:m.id});this.tree=new c(this);this.field_list={};this.input_list={};this.data=new Backbone.Model();this.datasets=new h({success:function(){l._initializeToolForm()}})},_initializeToolForm:function(){var l=this;this.model.fetch({error:function(m){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){l.inputs=l.model.get("inputs");l.portlet=new g.View({icon:"fa-wrench",title:"<b>"+l.model.get("name")+"</b> "+l.model.get("description"),buttons:{execute:new k.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){console.log(l.tree.create(l))}})}});l.message=new k.Message();l.portlet.append(l.message.$el);$(l.main_el).append(l.portlet.$el);if(l.options.help!=""){$(l.main_el).append(d.help(l.options.help))}if(l.options.citations){$(l.main_el).append(d.citations());var m=new i.ToolCitationCollection();m.tool_id=l.options.id;var n=new a.CitationListView({collection:m});n.render();m.fetch()}l.setElement(l.portlet.content());l.section=new j.View(l,{inputs:l.model.get("inputs")});l.portlet.append(l.section.$el);l.refresh()}})},refresh:function(){this.tree.refresh();for(var l in this.field_list){this.field_list[l].trigger("change")}console.debug("tools-form::refresh() - Recreated tree structure. Refresh.")}});return{View:b}}); \ No newline at end of file +define(["mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-datasets","mvc/tools/tools-section","mvc/tools/tools-tree"],function(g,k,i,a,f,d,h,j,c){var e=Backbone.Model.extend({initialize:function(l){this.url=galaxy_config.root+"api/tools/"+l.id+"?io_details=true"}});var b=Backbone.View.extend({main_el:"body",initialize:function(m){var l=this;this.options=m;this.model=new e({id:m.id});this.tree=new c(this);this.field_list={};this.input_list={};this.datasets=new h({success:function(){l._initializeToolForm()}})},_initializeToolForm:function(){var l=this;this.model.fetch({error:function(m){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){l.inputs=l.model.get("inputs");l.portlet=new g.View({icon:"fa-wrench",title:"<b>"+l.model.get("name")+"</b> "+l.model.get("description"),buttons:{execute:new k.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){console.log(l.tree.create(l))}})}});l.message=new k.Message();l.portlet.append(l.message.$el);$(l.main_el).append(l.portlet.$el);if(l.options.help!=""){$(l.main_el).append(d.help(l.options.help))}if(l.options.citations){$(l.main_el).append(d.citations());var m=new i.ToolCitationCollection();m.tool_id=l.options.id;var n=new a.CitationListView({collection:m});n.render();m.fetch()}l.setElement(l.portlet.content());l.section=new j.View(l,{inputs:l.model.get("inputs")});l.portlet.append(l.section.$el);l.refresh()}})},refresh:function(){this.tree.refresh();for(var l in this.field_list){this.field_list[l].trigger("change")}console.debug("tools-form::refresh() - Recreated tree structure. Refresh.")}});return{View:b}}); \ No newline at end of file diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae 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/ui/ui-tabs"],function(c,b,e,a){var d=Backbone.View.extend({initialize:function(g,f){this.app=g;this.inputs=f.inputs;this.datasets=g.datasets;this.data=g.data;f.cls_tr="section-row";this.table=new b.View(f);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var f in this.inputs){this._add(this.inputs[f],this.data)}},_add:function(h,j){var g=this;var f=jQuery.extend(true,{},h);f.id=c.uuid();this.app.input_list[f.id]=f;var i=f.type;switch(i){case"conditional":this._addConditional(f,j);break;case"repeat":this._addRepeat(f);break;default:this._addRow(i,f,j)}},_addConditional:function(f,j){f.label=f.test_param.label;f.value=f.test_param.value;this._addRow("conditional",f,j);for(var h in f.cases){var g=f.id+"-section-"+h;var k=new d(this.app,{inputs:f.cases[h].inputs,cls:"ui-table-plain"});this.table.add("");this.table.add(k.$el);this.table.append(g)}},_addRepeat:function(f){var g=this;var k=new a.View({title_new:"Add "+f.title,max:f.max,onnew:function(){var i=f.id+"-section-"+c.uuid();var m=new d(g.app,{inputs:f.inputs,cls:"ui-table-plain"});k.add({id:i,title:f.title,$el:m.$el,ondel:function(){k.del(i);k.retitle(f.title);g.app.refresh()}});k.retitle(f.title);k.show(i);g.app.refresh()}});for(var j=0;j<f.min;j++){var h=f.id+"-section-"+c.uuid();var l=new d(g.app,{inputs:f.inputs,cls:"ui-table-plain"});k.add({id:h,title:f.title,$el:l.$el})}k.retitle(f.title);this.table.add("");this.table.add(k.$el);this.table.append(f.id)},_addRow:function(i,f,g){var k=f.id;var h=null;switch(i){case"text":h=this._field_text(f,g);break;case"select":h=this._field_select(f,g);break;case"radiobutton":h=this._field_radio(f,g);break;case"data":h=this._field_data(f,g);break;case"data_column":h=this._field_column(f,g);break;case"textarea":h=this._field_textarea(f,g);break;case"conditional":h=this._field_conditional(f,g);break;case"hidden":h=this._field_hidden(f,g);break;case"integer":h=this._field_integer(f,g);break;case"boolean":h=this._field_radiobutton(f,g);break;default:h=this._field_text(f,g);console.debug("tools-form::_addRow() : Unmatched field type ("+i+").")}if(!g.get(k)){g.set(k,f.value)}h.value(g.get(k));this.app.field_list[k]=h;var j=$("<div/>");j.append(h.$el);if(f.help){j.append('<div class="ui-table-form-info">'+f.help+"</div>")}this.table.add('<span class="ui-table-form-title">'+f.label+"</span>","20%");this.table.add(j);this.table.append(k)},_field_conditional:function(f,l){var g=this;var h=[];for(var j in f.test_param.options){var k=f.test_param.options[j];h.push({label:k[0],value:k[1]})}var m=f.id;return new e.Select.View({id:"field-"+m,data:h,value:l.get(m),onchange:function(u){l.set(m,u);for(var s in f.cases){var o=f.cases[s];var r=f.id+"-section-"+s;var n=g.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()}}}})},_field_data:function(f,l){var g=this;var m=f.id;var k=this.datasets.filterType();var h=[];for(var j in k){h.push({label:k[j].get("name"),value:k[j].get("id")})}return new e.Select.View({id:"field-"+m,data:h,value:h[0].value,onchange:function(s){l.set(m,s);var o=g.app.tree.findReferences(m);var u=g.datasets.filter(s);if(u&&o.length>0){console.debug("tool-form::field_data() - Selected dataset "+s+".");var t=u.get("metadata_column_types");if(!t){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+s+".")}var r=[];for(var q in t){r.push({label:"Column: "+(parseInt(q)+1)+" ["+t[q]+"]",value:q})}for(var p in o){var n=g.app.field_list[o[p]];if(n){n.update(r);if(!n.exists(n.value())){n.value(n.first())}}}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+s+".")}}})},_field_column:function(f,g){var h=f.id;return new e.Select.View({id:"field-"+h,value:g.get(h),onchange:function(i){g.set(h,i)}})},_field_select:function(f,l){var g=[];for(var h in f.options){var j=f.options[h];g.push({label:j[0],value:j[1]})}var k=e.Select;if(f.display=="checkboxes"){k=e.Checkbox}var m=f.id;return new k.View({id:"field-"+m,data:g,value:l.get(m),onchange:function(i){l.set(m,i)}})},_field_text:function(f,g){var h=f.id;return new e.Input({id:"field-"+h,value:g.get(h),onchange:function(i){g.set(h,i)}})},_field_integer:function(f,g){var h=f.id;return new e.Slider.View({id:"field-"+h,value:g.get(h),onchange:function(i){g.set(h,i)}})},_field_textarea:function(f,g){var h=f.id;return new e.Textarea({id:"field-"+h,onchange:function(){g.set(h,field.value())}})},_field_radio:function(f,g){var h=f.id;return new e.RadioButton({id:"field-"+h,data:f.data,value:g.get(h),onchange:function(i){g.set(h,i)}})},_field_hidden:function(f,g){var h=f.id;return new e.Hidden({id:"field-"+h,value:g.get(h)})},_field_radiobutton:function(f,g){var h=f.id;return new e.RadioButton.View({id:"field-"+h,value:g.get(h),data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/ui/ui-tabs"],function(c,b,e,a){var d=Backbone.View.extend({initialize:function(g,f){this.app=g;this.inputs=f.inputs;f.cls_tr="section-row";this.table=new b.View(f);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var f in this.inputs){this._add(this.inputs[f])}},_add:function(h){var g=this;var f=jQuery.extend(true,{},h);f.id=c.uuid();this.app.input_list[f.id]=f;var i=f.type;switch(i){case"conditional":this._addConditional(f);break;case"repeat":this._addRepeat(f);break;default:this._addRow(i,f)}},_addConditional:function(f){f.label=f.test_param.label;f.value=f.test_param.value;this._addRow("conditional",f);for(var h in f.cases){var g=f.id+"-section-"+h;var j=new d(this.app,{inputs:f.cases[h].inputs,cls:"ui-table-plain"});this.table.add("");this.table.add(j.$el);this.table.append(g)}},_addRepeat:function(f){var g=this;var k=new a.View({title_new:"Add "+f.title,max:f.max,onnew:function(){var i=f.id+"-section-"+c.uuid();var m=new d(g.app,{inputs:f.inputs,cls:"ui-table-plain"});k.add({id:i,title:f.title,$el:m.$el,ondel:function(){k.del(i);k.retitle(f.title);g.app.refresh()}});k.retitle(f.title);k.show(i);g.app.refresh()}});for(var j=0;j<f.min;j++){var h=f.id+"-section-"+c.uuid();var l=new d(g.app,{inputs:f.inputs,cls:"ui-table-plain"});k.add({id:h,title:f.title,$el:l.$el})}k.retitle(f.title);this.table.add("");this.table.add(k.$el);this.table.append(f.id)},_addRow:function(h,f){var j=f.id;var g=null;switch(h){case"text":g=this._field_text(f);break;case"select":g=this._field_select(f);break;case"data":g=this._field_data(f);break;case"data_column":g=this._field_column(f);break;case"textarea":g=this._field_textarea(f);break;case"conditional":g=this._field_conditional(f);break;case"hidden":g=this._field_hidden(f);break;case"integer":g=this._field_slider(f);break;case"float":g=this._field_slider(f);break;case"boolean":g=this._field_boolean(f);break;default:g=this._field_text(f);console.debug("tools-form::_addRow() : Unmatched field type ("+h+").")}if(f.value!==undefined){g.value(f.value)}this.app.field_list[j]=g;var i=$("<div/>");i.append(g.$el);if(f.help){i.append('<div class="ui-table-form-info">'+f.help+"</div>")}this.table.add('<span class="ui-table-form-title">'+f.label+"</span>","20%");this.table.add(i);this.table.append(j)},_field_conditional:function(f){var g=this;var h=[];for(var j in f.test_param.options){var k=f.test_param.options[j];h.push({label:k[0],value:k[1]})}return new e.Select.View({id:"field-"+f.id,data:h,onchange:function(s){for(var q in f.cases){var m=f.cases[q];var p=f.id+"-section-"+q;var l=g.table.get(p);var o=false;for(var n in m.inputs){var r=m.inputs[n].type;if(r&&r!=="hidden"){o=true;break}}if(m.value==s&&o){l.fadeIn("fast")}else{l.hide()}}}})},_field_data:function(f){var g=this;var l=f.id;var k=this.app.datasets.filterType();var h=[];for(var j in k){h.push({label:k[j].get("name"),value:k[j].get("id")})}return new e.Select.View({id:"field-"+l,data:h,value:h[0].value,onchange:function(u){var s=g.app.tree.findReferences(l,"data_column");var n=g.app.datasets.filter(u);if(n&&s.length>0){console.debug("tool-form::field_data() - Selected dataset "+u+".");var w=n.get("metadata_column_types");if(!w){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+u+".")}for(var p in s){var q=g.app.input_list[s[p]];var r=g.app.field_list[s[p]];if(!q||!r){console.debug("tool-form::field_data() - FAILED: Column not found.")}var o=q.numerical;var m=[];for(var v in w){var t=w[v];if(t=="int"||t=="float"||!o){m.push({label:"Column: "+(parseInt(v)+1)+" ["+w[v]+"]",value:v})}}if(r){r.update(m);if(!r.exists(r.value())){r.value(r.first())}}}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+u+".")}}})},_field_select:function(f){var g=[];for(var h in f.options){var j=f.options[h];g.push({label:j[0],value:j[1]})}var k=e.Select;switch(f.display){case"checkboxes":k=e.Checkbox;break;case"radio":k=e.RadioButton;break}return new k.View({id:"field-"+f.id,data:g})},_field_column:function(f){return new e.Select.View({id:"field-"+f.id})},_field_text:function(f){return new e.Input({id:"field-"+f.id})},_field_slider:function(f){return new e.Slider.View({id:"field-"+f.id,min:f.min||0,max:f.max||1000,decimal:f.type=="float"})},_field_textarea:function(f){return new e.Textarea({id:"field-"+f.id})},_field_hidden:function(f){return new e.Hidden({id:"field-"+f.id})},_field_boolean:function(f){return new e.RadioButton.View({id:"field-"+f.id,data:[{label:"Yes",value:true},{label:"No",value:false}]})}});return{View:d}}); \ No newline at end of file diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae static/scripts/packed/mvc/tools/tools-tree.js --- a/static/scripts/packed/mvc/tools/tools-tree.js +++ b/static/scripts/packed/mvc/tools/tools-tree.js @@ -1,1 +1,1 @@ -define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){if(!this.app.section){return{}}this.dict={};this.xml=$("<div/>");this._iterate(this.app.section.$el,this.dict,this.xml)},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")||$(i).hasClass("tab-pane")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('<div id="'+h+'"/>');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})},findReferences:function(c){var f=[];var b=this;function d(g,i){var h=$(i).children();var k=[];var j=false;h.each(function(){var n=this;var m=$(n).attr("id");if(m!==c){var l=b.app.input_list[m];if(l){if(l.name==g){j=true;return false}if(l.data_ref==g){k.push(m)}}}});if(!j){f=f.concat(k);h.each(function(){d(g,this)})}}var e=this.xml.find("#"+c);if(e.length>0){var a=this.app.input_list[c];if(a){d(a.name,e.parent())}}return f}})}); \ No newline at end of file +define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){if(!this.app.section){return{}}this.dict={};this.xml=$("<div/>");this._iterate(this.app.section.$el,this.dict,this.xml)},_iterate:function(d,e,b){var a=this;var c=$(d).children();c.each(function(){var i=this;var h=$(i).attr("id");if($(i).hasClass("section-row")||$(i).hasClass("tab-pane")){e[h]={};var f=a.app.input_list[h];if(f){e[h]={input:f}}var g=$('<div id="'+h+'"/>');b.append(g);a._iterate(i,e[h],g)}else{a._iterate(i,e,b)}})},findReferences:function(c,e){var g=[];var b=this;function d(h,j){var i=$(j).children();var l=[];var k=false;i.each(function(){var o=this;var n=$(o).attr("id");if(n!==c){var m=b.app.input_list[n];if(m){if(m.name==h){k=true;return false}if(m.data_ref==h&&m.type==e){l.push(n)}}}});if(!k){g=g.concat(l);i.each(function(){d(h,this)})}}var f=this.xml.find("#"+c);if(f.length>0){var a=this.app.input_list[c];if(a){d(a.name,f.parent())}}return g}})}); \ No newline at end of file diff -r ebbc5e725c62e22926e5c0141aeaa95a3da20239 -r e5e05b2b242a99ab7a1c2748057db1f71ebd70ae 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},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;if(!(e==13||e==8||e==189||(e>=48&&e<=57))){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+'" style=""><input id="text" type="text" class="ui-input" style="width: 50px; float: left"/><div id="slider" style="width: calc(100% - 60px); float: left; top: 8px; left: 10px;"/></div>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",min:1,max:100,step:0.1,decimal:false},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");if(!this.options.decimal){this.options.step=1}this.$slider.slider(this.options);this.$text.on("change",function(){c.value($(this).val())});this.$text.on("keydown",function(f){var e=f.which;if(!(e==13||e==8||e==37||e==39||e==189||(e>=48&&e<=57)||(c.options.decimal&&$(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+'" style=""><input id="text" type="text" class="ui-input" style="width: 50px; float: left"/><div id="slider" style="width: calc(100% - 60px); float: left; top: 8px; left: 10px;"/></div>'}});return{View:b}}); \ 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.