commit/galaxy-central: guerler: ToolForm: Add data collection parameter
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f2e8f6fdeb72/ Changeset: f2e8f6fdeb72 User: guerler Date: 2014-12-03 22:29:34+00:00 Summary: ToolForm: Add data collection parameter Affected #: 7 files diff -r caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 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 @@ -307,6 +307,11 @@ field = this._fieldData(input_def); break; + // collection selector + //case 'data_collection': + // field = this._fieldData(input_def); + // break; + // data column case 'data_column': field = this._fieldSelect(input_def); @@ -383,6 +388,7 @@ id : 'field-' + input_def.id, extensions : input_def.extensions, multiple : input_def.multiple, + type : input_def.type, data : input_def.options, onchange : function() { self.app.refresh(); diff -r caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 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 @@ -20,15 +20,23 @@ // radio button options var radio_buttons = []; + // identify selector type + if (options.type == 'data_collection') { + this.mode = 'collection'; + } else { + if (options.multiple) { + this.mode = 'multiple'; + } else { + this.mode = 'single'; + } + } + // set initial state - if (!options.multiple) { - this.current = 'single'; - } else { - this.current = 'multiple'; - } - + this.current = this.mode; + this.list = {}; + // add single dataset selector - if (!options.multiple) { + if (this.mode == 'single') { radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); this.select_single = new Ui.Select.View({ onchange : function() { @@ -42,29 +50,33 @@ } // 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' - }; + if (this.mode == 'single' || this.mode == 'multiple') { + 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' - }; + if (this.mode == 'single' || this.mode == 'collection') { + 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({ @@ -81,7 +93,9 @@ this.$batch = $(ToolTemplate.batchMode()); // add elements to dom - this.$el.append(Utils.wrap(this.button_type.$el)); + if (_.size(this.list) > 1) { + this.$el.append(Utils.wrap(this.button_type.$el)); + } for (var i in this.list) { this.$el.append(this.list[i].field.$el); } @@ -144,8 +158,8 @@ // update selection fields this.select_single && this.select_single.update(dataset_options); - this.select_multiple.update(dataset_options); - this.select_collection.update(collection_options); + this.select_multiple && this.select_multiple.update(dataset_options); + this.select_collection && this.select_collection.update(collection_options); // add to content list this.app.content.add(options); @@ -167,7 +181,7 @@ this.current = 'collection'; this.select_collection.value(list[0]); } else { - if (list.length > 1 || this.options.multiple) { + if (this.mode == 'multiple') { this.current = 'multiple'; this.select_multiple.value(list); } else { @@ -195,7 +209,7 @@ // prepare result dict var result = { - batch : !this.options.multiple && this.current != 'single', + batch : this.mode == 'single' && this.current != 'single', values : [] } @@ -227,7 +241,7 @@ $el.hide(); } } - if (this.current != 'single' && !this.options.multiple) { + if (this.mode == 'single' && this.current != 'single') { this.$batch.show(); } else { this.$batch.hide(); diff -r caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2314,6 +2314,47 @@ return d + def to_dict( self, trans, view='collection', value_mapper=None, other_values=None ): + # create dictionary and fill default parameters + d = super( DataCollectionToolParameter, self ).to_dict( trans ) + d['multiple'] = self.multiple + d['is_dynamic'] = False + d['options'] = {'hda': [], 'hdca': []} + + # return default content if context is not available + if other_values is None: + return d + + # prepare dataset/collection matching + dataset_matcher = DatasetMatcher( trans, self, None, other_values ) + history = trans.history + + # append directly matched collections + for hdca in self.match_collections( trans, history, dataset_matcher ): + d['options']['hdca'].append({ + 'id' : trans.security.encode_id( hdca.id ), + 'id_uncoded' : hdca.id, + 'hid' : hdca.hid, + 'name' : hdca.name, + 'src' : 'hdca' + }) + + # append matching subcollections + for hdca in self.match_multirun_collections( trans, history, dataset_matcher ): + subcollection_type = self._history_query( trans ).collection_type_description.collection_type + d['options']['hdca'].append({ + 'id' : trans.security.encode_id( hdca.id ), + 'id_uncoded' : hdca.id, + 'hid' : hdca.hid, + 'name' : hdca.name, + 'src' : 'hdca' + }) + + # sort both lists + d['options']['hdca'] = sorted(d['options']['hdca'], key=lambda k: k['hid'], reverse=True) + + # return final dictionary + return d class HiddenDataToolParameter( HiddenToolParameter, DataToolParameter ): """ diff -r caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -307,6 +307,11 @@ field = this._fieldData(input_def); break; + // collection selector + //case 'data_collection': + // field = this._fieldData(input_def); + // break; + // data column case 'data_column': field = this._fieldSelect(input_def); @@ -383,6 +388,7 @@ id : 'field-' + input_def.id, extensions : input_def.extensions, multiple : input_def.multiple, + type : input_def.type, data : input_def.options, onchange : function() { self.app.refresh(); diff -r caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 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 @@ -20,15 +20,23 @@ // radio button options var radio_buttons = []; + // identify selector type + if (options.type == 'data_collection') { + this.mode = 'collection'; + } else { + if (options.multiple) { + this.mode = 'multiple'; + } else { + this.mode = 'single'; + } + } + // set initial state - if (!options.multiple) { - this.current = 'single'; - } else { - this.current = 'multiple'; - } - + this.current = this.mode; + this.list = {}; + // add single dataset selector - if (!options.multiple) { + if (this.mode == 'single') { radio_buttons.push({icon: 'fa-file-o', label : 'Single dataset', value : 'single'}); this.select_single = new Ui.Select.View({ onchange : function() { @@ -42,29 +50,33 @@ } // 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' - }; + if (this.mode == 'single' || this.mode == 'multiple') { + 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' - }; + if (this.mode == 'single' || this.mode == 'collection') { + 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({ @@ -81,7 +93,9 @@ this.$batch = $(ToolTemplate.batchMode()); // add elements to dom - this.$el.append(Utils.wrap(this.button_type.$el)); + if (_.size(this.list) > 1) { + this.$el.append(Utils.wrap(this.button_type.$el)); + } for (var i in this.list) { this.$el.append(this.list[i].field.$el); } @@ -144,8 +158,8 @@ // update selection fields this.select_single && this.select_single.update(dataset_options); - this.select_multiple.update(dataset_options); - this.select_collection.update(collection_options); + this.select_multiple && this.select_multiple.update(dataset_options); + this.select_collection && this.select_collection.update(collection_options); // add to content list this.app.content.add(options); @@ -167,7 +181,7 @@ this.current = 'collection'; this.select_collection.value(list[0]); } else { - if (list.length > 1 || this.options.multiple) { + if (this.mode == 'multiple') { this.current = 'multiple'; this.select_multiple.value(list); } else { @@ -195,7 +209,7 @@ // prepare result dict var result = { - batch : !this.options.multiple && this.current != 'single', + batch : this.mode == 'single' && this.current != 'single', values : [] } @@ -227,7 +241,7 @@ $el.hide(); } } - if (this.current != 'single' && !this.options.multiple) { + if (this.mode == 'single' && this.current != 'single') { this.$batch.show(); } else { this.$batch.hide(); diff -r caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 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=j.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(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_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.rebuild();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.rebuild();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(this.app,{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(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":i=this._fieldSelect(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":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(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 ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_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 +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=j.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(h)}},_addConditional:function(h){var j=this;h.test_param.id=h.id;var m=this._addRow(h.test_param);m.options.onchange=function(t){var p=j.app.tree.matchCase(h,t);for(var r in h.cases){var w=h.cases[r];var u=h.id+"-section-"+r;var o=j.table.get(u);var v=false;for(var q in w.inputs){var s=w.inputs[q].type;if(s&&s!=="hidden"){v=true;break}}if(r==p&&v){o.fadeIn("fast")}else{o.hide()}}j.app.refresh()};for(var l in h.cases){var k=h.id+"-section-"+l;var n=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});n.$el.addClass("ui-table-form-section");this.table.add(n.$el);this.table.append(k)}m.trigger("change")},_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.rebuild();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.rebuild();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(this.app,{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(h){var k=h.id;var i=this._createField(h);if(h.is_dynamic){this.app.is_dynamic=true}this.app.field_list[k]=i;var j=new e(this.app,{label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[k]=j;this.table.add(j.$el);this.table.append(k);return i},_createField:function(h){var i=null;switch(h.type){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":i=this._fieldSelect(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":h.searchable=true;i=this._fieldSelect(h);break;case"drill_down":i=this._fieldDrilldown(h);break;case"baseurl":i=this._fieldHidden(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 ("+h.type+").")}if(h.value!==undefined){i.value(h.value)}return i},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,type:h.type,data:h.options,onchange:function(){i.app.refresh()}})},_fieldSelect:function(h){var k=[];for(var l in h.options){var m=h.options[l];k.push({label:m[0],value:m[1]})}var n=g.Select;switch(h.display){case"checkboxes":n=g.Checkbox;break;case"radio":n=g.Radio;break}var j=this;return new n.View({id:"field-"+h.id,data:k,multiple:h.multiple,searchable:h.searchable,onchange:function(){j.app.refresh()}})},_fieldDrilldown:function(h){var i=this;return new g.Drilldown.View({id:"field-"+h.id,data:h.options,display:h.display,onchange:function(){i.app.refresh()}})},_fieldText:function(h){var i=this;return new g.Input({id:"field-"+h.id,area:h.area,onchange:function(){i.app.refresh()}})},_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 caf0f2bf161d9cd6e8fe6a205c6c967d5495c0fe -r f2e8f6fdeb720a4c1d4643306f45f13bb9fc8924 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(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);if(this.options.value!==undefined){this.value(this.options.value)}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&&m.values){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&&this.current!="single",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.type=="data_collection"){this.mode="collection"}else{if(g.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};if(this.mode=="single"){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"}}if(this.mode=="single"||this.mode=="multiple"){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"}}if(this.mode=="single"||this.mode=="collection"){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());if(_.size(this.list)>1){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);if(this.options.value!==undefined){this.value(this.options.value)}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&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(m){if(m&&m.values){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(this.mode=="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.mode=="single"&&this.current!="single",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.mode=="single"&&this.current!="single"){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