commit/galaxy-central: guerler: ToolForm: Show/hide single dataset selection field
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d7450b2567fb/ Changeset: d7450b2567fb User: guerler Date: 2014-11-12 08:13:37+00:00 Summary: ToolForm: Show/hide single dataset selection field Affected #: 3 files diff -r 4231a77fe8946110b2c56efd436000b864b06a84 -r d7450b2567fb56f93ccc0191a7059ebb46b23cc5 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 @@ -14,15 +14,62 @@ // add element this.setElement('<div/>'); - // current selection - this.current = 'single'; + // list of select fields + this.list = {}; + + // radio button options + var radio_buttons = []; + + // set initial state + if (!options.multiple) { + this.current = 'single'; + } else { + this.current = 'multiple'; + } + + // add single dataset selector + if (!options.multiple) { + radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); + this.select_single = new Ui.Select.View({ + onchange : function() { + self.trigger('change'); + } + }); + this.list['single'] = { + field: this.select_single, + type : 'hda' + }; + } + + // add multiple dataset selector + radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); + this.select_multiple = new Ui.Select.View({ + multiple : true, + onchange : function() { + self.trigger('change'); + } + }); + this.list['multiple'] = { + field: this.select_multiple, + type : 'hda' + }; + + // add collection selector + radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); + this.select_collection = new Ui.Select.View({ + onchange : function() { + self.trigger('change'); + } + }); + this.list['collection'] = { + field: this.select_collection, + type : 'hdca' + }; // create button this.button_type = new Ui.RadioButton.View({ value : this.current, - data : [ { icon: 'fa-file-o', label : 'Single dataset', value : 'single' }, - { icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }, - { icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }], + data : radio_buttons, onchange: function(value) { self.current = value; self.refresh(); @@ -30,44 +77,6 @@ } }); - // single dataset select field - this.select_single = new Ui.Select.View({ - onchange : function() { - self.trigger('change'); - } - }); - - // multiple datasets select field - this.select_multiple = new Ui.Select.View({ - multiple : true, - onchange : function() { - self.trigger('change'); - } - }); - - // collection select field - this.select_collection = new Ui.Select.View({ - onchange : function() { - self.trigger('change'); - } - }); - - // list of all select fields - this.list = { - 'single' : { - field: this.select_single, - type : 'hda' - }, - 'multiple' : { - field: this.select_multiple, - type : 'hda' - }, - 'collection' : { - field: this.select_collection, - type : 'hdca' - } - }; - // add batch mode information this.$batch = $(ToolTemplate.batchMode()); @@ -129,7 +138,7 @@ } // update selection fields - this.select_single.update(dataset_options); + this.select_single && this.select_single.update(dataset_options); this.select_multiple.update(dataset_options); this.select_collection.update(collection_options); @@ -153,7 +162,7 @@ this.current = 'collection'; this.select_collection.value(list[0]); } else { - if (list.length > 1) { + if (list.length > 1 || this.options.multiple) { this.current = 'multiple'; this.select_multiple.value(list); } else { diff -r 4231a77fe8946110b2c56efd436000b864b06a84 -r d7450b2567fb56f93ccc0191a7059ebb46b23cc5 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 @@ -14,15 +14,62 @@ // add element this.setElement('<div/>'); - // current selection - this.current = 'single'; + // list of select fields + this.list = {}; + + // radio button options + var radio_buttons = []; + + // set initial state + if (!options.multiple) { + this.current = 'single'; + } else { + this.current = 'multiple'; + } + + // add single dataset selector + if (!options.multiple) { + radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); + this.select_single = new Ui.Select.View({ + onchange : function() { + self.trigger('change'); + } + }); + this.list['single'] = { + field: this.select_single, + type : 'hda' + }; + } + + // add multiple dataset selector + radio_buttons.push({icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }); + this.select_multiple = new Ui.Select.View({ + multiple : true, + onchange : function() { + self.trigger('change'); + } + }); + this.list['multiple'] = { + field: this.select_multiple, + type : 'hda' + }; + + // add collection selector + radio_buttons.push({icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }); + this.select_collection = new Ui.Select.View({ + onchange : function() { + self.trigger('change'); + } + }); + this.list['collection'] = { + field: this.select_collection, + type : 'hdca' + }; // create button this.button_type = new Ui.RadioButton.View({ value : this.current, - data : [ { icon: 'fa-file-o', label : 'Single dataset', value : 'single' }, - { icon: 'fa-files-o', label : 'Multiple datasets', value : 'multiple' }, - { icon: 'fa-folder-o', label : 'List of datasets', value : 'collection' }], + data : radio_buttons, onchange: function(value) { self.current = value; self.refresh(); @@ -30,44 +77,6 @@ } }); - // single dataset select field - this.select_single = new Ui.Select.View({ - onchange : function() { - self.trigger('change'); - } - }); - - // multiple datasets select field - this.select_multiple = new Ui.Select.View({ - multiple : true, - onchange : function() { - self.trigger('change'); - } - }); - - // collection select field - this.select_collection = new Ui.Select.View({ - onchange : function() { - self.trigger('change'); - } - }); - - // list of all select fields - this.list = { - 'single' : { - field: this.select_single, - type : 'hda' - }, - 'multiple' : { - field: this.select_multiple, - type : 'hda' - }, - 'collection' : { - field: this.select_collection, - type : 'hdca' - } - }; - // add batch mode information this.$batch = $(ToolTemplate.batchMode()); @@ -129,7 +138,7 @@ } // update selection fields - this.select_single.update(dataset_options); + this.select_single && this.select_single.update(dataset_options); this.select_multiple.update(dataset_options); this.select_collection.update(collection_options); @@ -153,7 +162,7 @@ this.current = 'collection'; this.select_collection.value(list[0]); } else { - if (list.length > 1) { + if (list.length > 1 || this.options.multiple) { this.current = 'multiple'; this.select_multiple.value(list); } else { diff -r 4231a77fe8946110b2c56efd436000b864b06a84 -r d7450b2567fb56f93ccc0191a7059ebb46b23cc5 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(j,g){this.app=j;this.options=g;var f=this;this.setElement("<div/>");this.current="single";this.button_type=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Single dataset",value:"single"},{icon:"fa-files-o",label:"Multiple datasets",value:"multiple"},{icon:"fa-folder-o",label:"List of datasets",value:"collection"}],onchange:function(i){f.current=i;f.refresh();f.trigger("change")}});this.select_single=new e.Select.View({onchange:function(){f.trigger("change")}});this.select_multiple=new e.Select.View({multiple:true,onchange:function(){f.trigger("change")}});this.select_collection=new e.Select.View({onchange:function(){f.trigger("change")}});this.list={single:{field:this.select_single,type:"hda"},multiple:{field:this.select_multiple,type:"hda"},collection:{field:this.select_collection,type:"hdca"}};this.$batch=$(a.batchMode());this.$el.append(c.wrap(this.button_type.$el));for(var h in this.list){this.$el.append(this.list[h].field.$el)}this.$el.append(this.$batch);this.update(g.data);this.refresh();this.on("change",function(){if(g.onchange){g.onchange(f.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single.update(l);this.select_multiple.update(l);this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m!==undefined){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(l.length>1){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().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.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.current!="single"&&!this.options.multiple){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});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(k,g){this.app=k;this.options=g;var f=this;this.setElement("<div/>");this.list={};var j=[];if(!g.multiple){this.current="single"}else{this.current="multiple"}if(!g.multiple){j.push({icon:"fa-file-o",label:"Single dataset",value:"single"});this.select_single=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}j.push({icon:"fa-files-o",label:"Multiple datasets",value:"multiple"});this.select_multiple=new e.Select.View({multiple:true,onchange:function(){f.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"};j.push({icon:"fa-folder-o",label:"List of datasets",value:"collection"});this.select_collection=new e.Select.View({onchange:function(){f.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"};this.button_type=new e.RadioButton.View({value:this.current,data:j,onchange:function(i){f.current=i;f.refresh();f.trigger("change")}});this.$batch=$(a.batchMode());this.$el.append(c.wrap(this.button_type.$el));for(var h in this.list){this.$el.append(this.list[h].field.$el)}this.$el.append(this.$batch);this.update(g.data);this.refresh();this.on("change",function(){if(g.onchange){g.onchange(f.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple.update(l);this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m!==undefined){try{var l=[];for(var h in m.values){l.push(m.values[h].id)}if(m&&m.values.length>0&&m.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(l.length>1||this.options.multiple){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}this.refresh();var g=this._select();if(!g.validate()){g.value(g.first())}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}var j=this._select().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.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.current!="single"&&!this.options.multiple){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ 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