1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/713526cf328d/ Changeset: 713526cf328d User: guerler Date: 2014-10-30 15:27:26+00:00 Summary: ToolForm: Activate dynamic parameter handling Affected #: 7 files
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f 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 @@ -128,6 +128,11 @@ // link this var self = this;
+ // only refresh the state if the form contains dynamic parameters + if (!this.is_dynamic) { + return; + } + // finalize data var current_state = this.tree.finalize({ data : function(dict) { @@ -139,7 +144,7 @@ });
// log tool state - console.debug('tools-form::_refreshForm() - Refreshing inputs/states.'); + console.debug('tools-form::_refreshForm() - Refreshing states.'); console.debug(current_state);
// post job @@ -152,7 +157,7 @@ self._rebuildForm(response);
// log success - console.debug('tools-form::_refreshForm() - Refreshed inputs/states.'); + console.debug('tools-form::_refreshForm() - States refreshed.'); console.debug(response); }, error : function(response) { @@ -174,7 +179,7 @@
// get/update field (currently only done for select fields) var field = self.field_list[input_id]; - if (field.update && input.type == 'select') { + if (field.update && input.type != 'data') { var new_options = []; for (var i in node.options) { var opt = node.options[i];
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f 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 @@ -231,7 +231,6 @@
// data column case 'data_column': - input_def.is_dynamic = false; field = this._fieldSelect(input_def); break;
@@ -285,7 +284,7 @@
// deactivate dynamic fields if (input_def.is_dynamic) { - this.app.incompatible = true; + //this.app.incompatible = true; this.app.is_dynamic = true; }
@@ -374,119 +373,13 @@ /** Data input field */ _fieldData : function(input_def) { - // link this var self = this; - - // get element id - var id = input_def.id; - - // select field return new SelectContent.View(this.app, { - id : 'field-' + id, + id : 'field-' + input_def.id, extensions : input_def.extensions, multiple : input_def.multiple, onchange : function(dict) { - // rebuild the form - if (self.app.is_dynamic) { - self.app.rebuild(); - } - - // pick the first content only (todo: maybe collect multiple meta information) - var content_def = dict.values[0]; - var content_id = content_def.id; - var content_src = content_def.src; - - // get referenced columns - var column_list = self.app.tree.references(id, 'data_column'); - - // check data column list - if (column_list.length <= 0) { - console.debug('tool-form::field_data() - Data column parameters unavailable.'); - return; - } - - // set wait mode - for (var i in column_list) { - var column_field = self.app.field_list[column_list[i]]; - column_field.wait && column_field.wait(); - } - - // find selected content - self.app.content.getDetails({ - id : content_id, - src : content_src, - success : function(content) { - // meta data - var meta = null; - - // check content - if (content) { - // log selection - console.debug('tool-form::field_data() - Selected content ' + content_id + '.'); - - // select the first dataset to represent collections - if (content_src == 'hdca' && content.elements && content.elements.length > 0) { - content = content.elements[0].object; - } - - // get meta data - meta = content.metadata_column_types; - - // check meta data - if (!meta) { - console.debug('tool-form::field_data() - FAILED: Could not find metadata for content ' + content_id + '.'); - } - } else { - console.debug('tool-form::field_data() - FAILED: Could not find content ' + content_id + '.'); - } - - // update referenced columns - for (var i in column_list) { - // 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]; - - // column index - var column_index = (parseInt(key) + 1); - - // column type label - var column_label = 'Text'; - if (column_type == 'int' || column_type == 'float') { - column_label = 'Number'; - } - - // add to selection - if (column_type == 'int' || column_type == 'float' || !numerical) { - columns.push({ - 'label' : 'Column: ' + column_index + ' [' + column_label + ']', - 'value' : column_index - }); - } - } - - // update field - if (column_field) { - column_field.update(columns); - if (!column_field.exists(column_field.value())) { - column_field.value(column_field.first()); - } - column_field.show(); - } - } - } - }); + self.app.rebuild(); } }); }, @@ -516,10 +409,14 @@ }
// select field + var self = this; return new SelectClass.View({ id : 'field-' + input_def.id, data : options, - multiple: input_def.multiple + multiple: input_def.multiple, + onchange: function() { + self.app.rebuild(); + } }); },
@@ -535,7 +432,6 @@ /** Slider field */ _fieldSlider: function(input_def) { - // create slider return new Ui.Slider.View({ id : 'field-' + input_def.id, precise : input_def.type == 'float',
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f lib/galaxy/tools/parameters/basic.py --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -1242,7 +1242,7 @@ if type(col) == type(()) and len(col) == 2: # fiddled options.append((col[1],col[0],False)) else: - options.append( ( 'c' + col, col, False ) ) + options.append( ( 'Column: ' + col, col, False ) ) return options
def get_initial_value( self, trans, context, history=None ):
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f static/scripts/mvc/tools/tools-form.js --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -128,6 +128,11 @@ // link this var self = this;
+ // only refresh the state if the form contains dynamic parameters + if (!this.is_dynamic) { + return; + } + // finalize data var current_state = this.tree.finalize({ data : function(dict) { @@ -139,7 +144,7 @@ });
// log tool state - console.debug('tools-form::_refreshForm() - Refreshing inputs/states.'); + console.debug('tools-form::_refreshForm() - Refreshing states.'); console.debug(current_state);
// post job @@ -152,7 +157,7 @@ self._rebuildForm(response);
// log success - console.debug('tools-form::_refreshForm() - Refreshed inputs/states.'); + console.debug('tools-form::_refreshForm() - States refreshed.'); console.debug(response); }, error : function(response) { @@ -174,7 +179,7 @@
// get/update field (currently only done for select fields) var field = self.field_list[input_id]; - if (field.update && input.type == 'select') { + if (field.update && input.type != 'data') { var new_options = []; for (var i in node.options) { var opt = node.options[i];
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -231,7 +231,6 @@
// data column case 'data_column': - input_def.is_dynamic = false; field = this._fieldSelect(input_def); break;
@@ -285,7 +284,7 @@
// deactivate dynamic fields if (input_def.is_dynamic) { - this.app.incompatible = true; + //this.app.incompatible = true; this.app.is_dynamic = true; }
@@ -374,119 +373,13 @@ /** Data input field */ _fieldData : function(input_def) { - // link this var self = this; - - // get element id - var id = input_def.id; - - // select field return new SelectContent.View(this.app, { - id : 'field-' + id, + id : 'field-' + input_def.id, extensions : input_def.extensions, multiple : input_def.multiple, onchange : function(dict) { - // rebuild the form - if (self.app.is_dynamic) { - self.app.rebuild(); - } - - // pick the first content only (todo: maybe collect multiple meta information) - var content_def = dict.values[0]; - var content_id = content_def.id; - var content_src = content_def.src; - - // get referenced columns - var column_list = self.app.tree.references(id, 'data_column'); - - // check data column list - if (column_list.length <= 0) { - console.debug('tool-form::field_data() - Data column parameters unavailable.'); - return; - } - - // set wait mode - for (var i in column_list) { - var column_field = self.app.field_list[column_list[i]]; - column_field.wait && column_field.wait(); - } - - // find selected content - self.app.content.getDetails({ - id : content_id, - src : content_src, - success : function(content) { - // meta data - var meta = null; - - // check content - if (content) { - // log selection - console.debug('tool-form::field_data() - Selected content ' + content_id + '.'); - - // select the first dataset to represent collections - if (content_src == 'hdca' && content.elements && content.elements.length > 0) { - content = content.elements[0].object; - } - - // get meta data - meta = content.metadata_column_types; - - // check meta data - if (!meta) { - console.debug('tool-form::field_data() - FAILED: Could not find metadata for content ' + content_id + '.'); - } - } else { - console.debug('tool-form::field_data() - FAILED: Could not find content ' + content_id + '.'); - } - - // update referenced columns - for (var i in column_list) { - // 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]; - - // column index - var column_index = (parseInt(key) + 1); - - // column type label - var column_label = 'Text'; - if (column_type == 'int' || column_type == 'float') { - column_label = 'Number'; - } - - // add to selection - if (column_type == 'int' || column_type == 'float' || !numerical) { - columns.push({ - 'label' : 'Column: ' + column_index + ' [' + column_label + ']', - 'value' : column_index - }); - } - } - - // update field - if (column_field) { - column_field.update(columns); - if (!column_field.exists(column_field.value())) { - column_field.value(column_field.first()); - } - column_field.show(); - } - } - } - }); + self.app.rebuild(); } }); }, @@ -516,10 +409,14 @@ }
// select field + var self = this; return new SelectClass.View({ id : 'field-' + input_def.id, data : options, - multiple: input_def.multiple + multiple: input_def.multiple, + onchange: function() { + self.app.rebuild(); + } }); },
@@ -535,7 +432,6 @@ /** Slider field */ _fieldSlider: function(input_def) { - // create slider return new Ui.Slider.View({ id : 'field-' + input_def.id, precise : input_def.type == 'float',
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f 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.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.content=new f({history_id:m.options.history_id,success:function(){m._buildForm(m.options)}})},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.")},_buildModel:function(){var m=this;var n=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){n+="job_id="+this.options.job_id}else{if(this.options.dataset_id){n+="dataset_id="+this.options.dataset_id}else{var o=top.location.href;var p=o.indexOf("?");if(o.indexOf("tool_id=")!=-1&&p!==-1){n+=o.slice(p+1)}}}i.request({type:"GET",url:n,success:function(q){m.options=$.extend(m.options,q);m.model=q;m.inputs=q.inputs;console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(q);m._buildForm()},error:function(q){console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(q)}})},rebuild: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+"api/tools/"+this.options.id+"/build",data:n,success:function(o){m._rebuildForm(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)}})},_rebuildForm:function(m){var n=this;this.tree.matchModel(m,function(p,t){var o=n.input_list[p];if(o&&o.options){if(JSON.stringify(o.options)!=JSON.stringify(t.options)){o.options=t.options;var u=n.field_list[p];if(u.update&&o.type=="select"){var s=[];for(var r in t.options){var q=t.options[r];if(q.length>2){s.push({label:q[0],value:q[1]})}}u.update(s);console.debug("Updating options for "+p)}}}})},_buildForm:function(o){var n=this;this.field_list={};this.input_list={};this.element_list={};this.model=o;this.inputs=o.inputs;var q=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(o.biostar_url){q.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/")}});q.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+"/")}})}q.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")){q.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:q},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()}})}});this.$el.empty();this.$el.append(this.portlet.$el);if(o.help!=""){this.$el.append(d.help(o.help))}if(o.citations){var m=new j.ToolCitationCollection();m.tool_id=o.id;var p=new a.CitationListView({collection:m});p.render();m.fetch();this.$el.append(p.$el)}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.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.content=new f({history_id:m.options.history_id,success:function(){m._buildForm(m.options)}})},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.")},_buildModel:function(){var m=this;var n=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){n+="job_id="+this.options.job_id}else{if(this.options.dataset_id){n+="dataset_id="+this.options.dataset_id}else{var o=top.location.href;var p=o.indexOf("?");if(o.indexOf("tool_id=")!=-1&&p!==-1){n+=o.slice(p+1)}}}i.request({type:"GET",url:n,success:function(q){m.options=$.extend(m.options,q);m.model=q;m.inputs=q.inputs;console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(q);m._buildForm()},error:function(q){console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(q)}})},rebuild:function(){var m=this;if(!this.is_dynamic){return}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 states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"api/tools/"+this.options.id+"/build",data:n,success:function(o){m._rebuildForm(o);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_rebuildForm:function(m){var n=this;this.tree.matchModel(m,function(p,t){var o=n.input_list[p];if(o&&o.options){if(JSON.stringify(o.options)!=JSON.stringify(t.options)){o.options=t.options;var u=n.field_list[p];if(u.update&&o.type!="data"){var s=[];for(var r in t.options){var q=t.options[r];if(q.length>2){s.push({label:q[0],value:q[1]})}}u.update(s);console.debug("Updating options for "+p)}}}})},_buildForm:function(o){var n=this;this.field_list={};this.input_list={};this.element_list={};this.model=o;this.inputs=o.inputs;var q=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(o.biostar_url){q.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/")}});q.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+"/")}})}q.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")){q.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:q},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()}})}});this.$el.empty();this.$el.append(this.portlet.$el);if(o.help!=""){this.$el.append(d.help(o.help))}if(o.citations){var m=new j.ToolCitationCollection();m.tool_id=o.id;var p=new a.CitationListView({collection:m});p.render();m.fetch();this.$el.append(p.$el)}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}}); \ No newline at end of file
diff -r 55c20724a69cacf121a756594d1ba112e5ae56d5 -r 713526cf328d41f0248ce85860e1d33db779482f 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(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.is_dynamic){this.app.incompatible=true;this.app.is_dynamic=true}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){if(i.app.is_dynamic){i.app.rebuild()}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){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 +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(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":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.is_dynamic){this.app.is_dynamic=true}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;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,onchange:function(j){i.app.rebuild()}})},_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,onchange:function(){j.app.rebuild()}})},_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
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.
galaxy-commits@lists.galaxyproject.org