commit/galaxy-central: guerler: ToolForm: Refactoring, generalize conditional parameters
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/37fb229769f4/ Changeset: 37fb229769f4 User: guerler Date: 2014-11-06 20:11:23+00:00 Summary: ToolForm: Refactoring, generalize conditional parameters Affected #: 6 files diff -r 5f0d3cbd97d9c1472bdb8249f3df72d6683caaff -r 37fb229769f4a1cc02d7df26790c5c6f13e913d6 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 @@ -1,5 +1,5 @@ /** - This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function. + This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _createField() function. */ 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(Utils, Table, Ui, Repeat, SelectContent, InputElement) { @@ -68,23 +68,61 @@ break; // default single element row default: - this._addRow(type, input_def); + this._addRow(input_def); } }, /** Add a conditional block */ _addConditional: function(input_def) { - // add label to input definition root - input_def.label = input_def.test_param.label; - - // add value to input definition root - input_def.value = input_def.test_param.value; - - // build options field - var field = this._addRow('conditional', input_def); + // link this + var self = this; - // add fields + // copy identifier + input_def.test_param.id = input_def.id; + + // build test parameter + var field = this._addRow(input_def.test_param); + + // set onchange event for test parameter + field.options.onchange = function(value) { + // identify the selected case + var selectedCase = self.app.tree.matchCase(input_def, value); + + // check value in order to hide/show options + for (var i in input_def.cases) { + // get case + var case_def = input_def.cases[i]; + + // identify subsection name + var section_id = input_def.id + '-section-' + i; + + // identify row + var section_row = self.table.get(section_id); + + // check if non-hidden elements exist + var nonhidden = false; + for (var j in case_def.inputs) { + var type = case_def.inputs[j].type; + if (type && type !== 'hidden') { + nonhidden = true; + break; + } + } + + // show/hide sub form + if (i == selectedCase && nonhidden) { + section_row.fadeIn('fast'); + } else { + section_row.hide(); + } + } + + // refresh form inputs + self.app.refresh(); + }; + + // add conditional sub sections for (var i in input_def.cases) { // create id tag var sub_section_id = input_def.id + '-section-' + i; @@ -208,17 +246,52 @@ this.table.append(input_def.id); }, - /** Add a single field element + /** Add a single input field element */ - _addRow: function(field_type, input_def) { + _addRow: function(input_def) { // get id var id = input_def.id; + // create input field + var field = this._createField(input_def); + + // flagging this form as dynamic will trigger api-driven refresh events + if (input_def.is_dynamic) { + this.app.is_dynamic = true; + } + + // add to field list + this.app.field_list[id] = field; + + // create input field wrapper + var input_element = new InputElement(this.app, { + label : input_def.label, + optional : input_def.optional, + help : input_def.help, + field : field + }); + + // add to element list + this.app.element_list[id] = input_element; + + // create table row + this.table.add(input_element.$el); + + // append to table + this.table.append(id); + + // return created field + return field; + }, + + /** Returns an input field for a given field type + */ + _createField: function(input_def) { // field wrapper var field = null; // identify field type - switch(field_type) { + switch(input_def.type) { // text input field case 'text' : field = this._fieldText(input_def); @@ -239,11 +312,6 @@ field = this._fieldSelect(input_def); break; - // conditional select field - case 'conditional': - field = this._fieldConditional(input_def); - break; - // hidden field case 'hidden': field = this._fieldHidden(input_def); @@ -287,97 +355,15 @@ console.debug('tools-form::_addRow() : Auto matched field type (' + field_type + ').'); } - // deactivate dynamic fields - if (input_def.is_dynamic) { - //this.app.incompatible = true; - this.app.is_dynamic = true; - } - // set field value if (input_def.value !== undefined) { field.value(input_def.value); } - // add to field list - this.app.field_list[id] = field; - - // create input field wrapper - var input_element = new InputElement(this.app, { - label : input_def.label, - optional : input_def.optional, - help : input_def.help, - field : field - }); - - // add to element list - this.app.element_list[id] = input_element; - - // create table row - this.table.add(input_element.$el); - - // append to table - this.table.append(id); - - // return created field + // return field element return field; }, - /** Conditional input field selector - */ - _fieldConditional : function(input_def) { - // link this - var self = this; - - // configure options fields - var options = []; - for (var i in input_def.test_param.options) { - var option = input_def.test_param.options[i]; - options.push({ - label: option[0], - value: option[1] - }); - } - - // select field - return new Ui.Select.View({ - id : 'field-' + input_def.id, - data : options, - onchange : function(value) { - // check value in order to hide/show options - for (var i in input_def.cases) { - // get case - var case_def = input_def.cases[i]; - - // identify subsection name - var section_id = input_def.id + '-section-' + i; - - // identify row - var section_row = self.table.get(section_id); - - // check if non-hidden elements exist - var nonhidden = false; - for (var j in case_def.inputs) { - var type = case_def.inputs[j].type; - if (type && type !== 'hidden') { - nonhidden = true; - break; - } - } - - // show/hide sub form - if (case_def.value == value && nonhidden) { - section_row.fadeIn('fast'); - } else { - section_row.hide(); - } - } - - // refresh form inputs - self.app.refresh(); - } - }); - }, - /** Data input field */ _fieldData : function(input_def) { diff -r 5f0d3cbd97d9c1472bdb8249f3df72d6683caaff -r 37fb229769f4a1cc02d7df26790c5c6f13e913d6 client/galaxy/scripts/mvc/tools/tools-tree.js --- a/client/galaxy/scripts/mvc/tools/tools-tree.js +++ b/client/galaxy/scripts/mvc/tools/tools-tree.js @@ -104,12 +104,10 @@ // add conditional value add (job_input_id + '|' + input.test_param.name, input.id, value); - // find selected case - for (var i in input.cases) { - if (input.cases[i].value == value) { - convert(job_input_id, head[input.id + '-section-' + i]); - break; - } + // identify selected case + var selectedCase = self.matchCase(input, value); + if (selectedCase != -1) { + convert(job_input_id, head[input.id + '-section-' + selectedCase]); } break; default: @@ -146,6 +144,29 @@ return this.job_ids && this.job_ids[job_input_id]; }, + /** Match conditional values to selected cases + */ + matchCase: function(input, value) { + // format value for boolean inputs + if (input.test_param.type == 'boolean') { + if (value == 'true') { + value = input.test_param.truevalue || 'true'; + } else { + value = input.test_param.falsevalue || 'false'; + } + } + + // find selected case + for (var i in input.cases) { + if (input.cases[i].value == value) { + return i; + } + } + + // selected case not found + return -1; + }, + /** Matches identifier from api model to input elements */ matchModel: function(model, callback) { @@ -163,24 +184,24 @@ if (id != '') { index = id + '|' + index; } - if (node.type == 'repeat') { - for (var j in node.cache) { - search (index + '_' + j, node.cache[j]); - } - } else { - if (node.type == 'conditional') { + switch (node.type) { + case 'repeat': + for (var j in node.cache) { + search (index + '_' + j, node.cache[j]); + } + break; + case 'conditional': var value = node.test_param && node.test_param.value; - for (var j in node.cases) { - if (node.cases[j].value == value) { - search (index, node.cases[j].inputs); - } + var selectedCase = self.matchCase(node, value); + if (selectedCase != -1) { + search (index, node.cases[selectedCase].inputs); } - } else { + break; + default: var input_id = self.app.tree.job_ids[index]; if (input_id) { callback(input_id, node); } - } } } } diff -r 5f0d3cbd97d9c1472bdb8249f3df72d6683caaff -r 37fb229769f4a1cc02d7df26790c5c6f13e913d6 static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -1,5 +1,5 @@ /** - This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function. + This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _createField() function. */ 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(Utils, Table, Ui, Repeat, SelectContent, InputElement) { @@ -68,23 +68,61 @@ break; // default single element row default: - this._addRow(type, input_def); + this._addRow(input_def); } }, /** Add a conditional block */ _addConditional: function(input_def) { - // add label to input definition root - input_def.label = input_def.test_param.label; - - // add value to input definition root - input_def.value = input_def.test_param.value; - - // build options field - var field = this._addRow('conditional', input_def); + // link this + var self = this; - // add fields + // copy identifier + input_def.test_param.id = input_def.id; + + // build test parameter + var field = this._addRow(input_def.test_param); + + // set onchange event for test parameter + field.options.onchange = function(value) { + // identify the selected case + var selectedCase = self.app.tree.matchCase(input_def, value); + + // check value in order to hide/show options + for (var i in input_def.cases) { + // get case + var case_def = input_def.cases[i]; + + // identify subsection name + var section_id = input_def.id + '-section-' + i; + + // identify row + var section_row = self.table.get(section_id); + + // check if non-hidden elements exist + var nonhidden = false; + for (var j in case_def.inputs) { + var type = case_def.inputs[j].type; + if (type && type !== 'hidden') { + nonhidden = true; + break; + } + } + + // show/hide sub form + if (i == selectedCase && nonhidden) { + section_row.fadeIn('fast'); + } else { + section_row.hide(); + } + } + + // refresh form inputs + self.app.refresh(); + }; + + // add conditional sub sections for (var i in input_def.cases) { // create id tag var sub_section_id = input_def.id + '-section-' + i; @@ -208,17 +246,52 @@ this.table.append(input_def.id); }, - /** Add a single field element + /** Add a single input field element */ - _addRow: function(field_type, input_def) { + _addRow: function(input_def) { // get id var id = input_def.id; + // create input field + var field = this._createField(input_def); + + // flagging this form as dynamic will trigger api-driven refresh events + if (input_def.is_dynamic) { + this.app.is_dynamic = true; + } + + // add to field list + this.app.field_list[id] = field; + + // create input field wrapper + var input_element = new InputElement(this.app, { + label : input_def.label, + optional : input_def.optional, + help : input_def.help, + field : field + }); + + // add to element list + this.app.element_list[id] = input_element; + + // create table row + this.table.add(input_element.$el); + + // append to table + this.table.append(id); + + // return created field + return field; + }, + + /** Returns an input field for a given field type + */ + _createField: function(input_def) { // field wrapper var field = null; // identify field type - switch(field_type) { + switch(input_def.type) { // text input field case 'text' : field = this._fieldText(input_def); @@ -239,11 +312,6 @@ field = this._fieldSelect(input_def); break; - // conditional select field - case 'conditional': - field = this._fieldConditional(input_def); - break; - // hidden field case 'hidden': field = this._fieldHidden(input_def); @@ -287,97 +355,15 @@ console.debug('tools-form::_addRow() : Auto matched field type (' + field_type + ').'); } - // deactivate dynamic fields - if (input_def.is_dynamic) { - //this.app.incompatible = true; - this.app.is_dynamic = true; - } - // set field value if (input_def.value !== undefined) { field.value(input_def.value); } - // add to field list - this.app.field_list[id] = field; - - // create input field wrapper - var input_element = new InputElement(this.app, { - label : input_def.label, - optional : input_def.optional, - help : input_def.help, - field : field - }); - - // add to element list - this.app.element_list[id] = input_element; - - // create table row - this.table.add(input_element.$el); - - // append to table - this.table.append(id); - - // return created field + // return field element return field; }, - /** Conditional input field selector - */ - _fieldConditional : function(input_def) { - // link this - var self = this; - - // configure options fields - var options = []; - for (var i in input_def.test_param.options) { - var option = input_def.test_param.options[i]; - options.push({ - label: option[0], - value: option[1] - }); - } - - // select field - return new Ui.Select.View({ - id : 'field-' + input_def.id, - data : options, - onchange : function(value) { - // check value in order to hide/show options - for (var i in input_def.cases) { - // get case - var case_def = input_def.cases[i]; - - // identify subsection name - var section_id = input_def.id + '-section-' + i; - - // identify row - var section_row = self.table.get(section_id); - - // check if non-hidden elements exist - var nonhidden = false; - for (var j in case_def.inputs) { - var type = case_def.inputs[j].type; - if (type && type !== 'hidden') { - nonhidden = true; - break; - } - } - - // show/hide sub form - if (case_def.value == value && nonhidden) { - section_row.fadeIn('fast'); - } else { - section_row.hide(); - } - } - - // refresh form inputs - self.app.refresh(); - } - }); - }, - /** Data input field */ _fieldData : function(input_def) { diff -r 5f0d3cbd97d9c1472bdb8249f3df72d6683caaff -r 37fb229769f4a1cc02d7df26790c5c6f13e913d6 static/scripts/mvc/tools/tools-tree.js --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -104,12 +104,10 @@ // add conditional value add (job_input_id + '|' + input.test_param.name, input.id, value); - // find selected case - for (var i in input.cases) { - if (input.cases[i].value == value) { - convert(job_input_id, head[input.id + '-section-' + i]); - break; - } + // identify selected case + var selectedCase = self.matchCase(input, value); + if (selectedCase != -1) { + convert(job_input_id, head[input.id + '-section-' + selectedCase]); } break; default: @@ -146,6 +144,29 @@ return this.job_ids && this.job_ids[job_input_id]; }, + /** Match conditional values to selected cases + */ + matchCase: function(input, value) { + // format value for boolean inputs + if (input.test_param.type == 'boolean') { + if (value == 'true') { + value = input.test_param.truevalue || 'true'; + } else { + value = input.test_param.falsevalue || 'false'; + } + } + + // find selected case + for (var i in input.cases) { + if (input.cases[i].value == value) { + return i; + } + } + + // selected case not found + return -1; + }, + /** Matches identifier from api model to input elements */ matchModel: function(model, callback) { @@ -163,24 +184,24 @@ if (id != '') { index = id + '|' + index; } - if (node.type == 'repeat') { - for (var j in node.cache) { - search (index + '_' + j, node.cache[j]); - } - } else { - if (node.type == 'conditional') { + switch (node.type) { + case 'repeat': + for (var j in node.cache) { + search (index + '_' + j, node.cache[j]); + } + break; + case 'conditional': var value = node.test_param && node.test_param.value; - for (var j in node.cases) { - if (node.cases[j].value == value) { - search (index, node.cases[j].inputs); - } + var selectedCase = self.matchCase(node, value); + if (selectedCase != -1) { + search (index, node.cases[selectedCase].inputs); } - } else { + break; + default: var input_id = self.app.tree.job_ids[index]; if (input_id) { callback(input_id, node); } - } } } } diff -r 5f0d3cbd97d9c1472bdb8249f3df72d6683caaff -r 37fb229769f4a1cc02d7df26790c5c6f13e913d6 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 l=this._addRow("conditional",h);for(var k in h.cases){var j=h.id+"-section-"+k;var m=new f(this.app,{inputs:h.cases[k].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(j)}l.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(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(this.app,{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 i},_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()}}j.app.refresh()}})},_fieldData:function(h){var i=this;return new a.View(this.app,{id:"field-"+h.id,extensions:h.extensions,multiple:h.multiple,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,onchange:function(){j.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":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 ("+field_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,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,onchange:function(){j.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 5f0d3cbd97d9c1472bdb8249f3df72d6683caaff -r 37fb229769f4a1cc02d7df26790c5c6f13e913d6 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(){this.dict={};this.xml=$("<div/>");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(k,n){for(var h in n){var f=n[h];if(f.input){var p=f.input;var j=k;if(k!=""){j+="|"}j+=p.name;switch(p.type){case"repeat":var e="section-";var s=[];var m=null;for(var r in f){var l=r.indexOf(e);if(l!=-1){l+=e.length;s.push(parseInt(r.substr(l)));if(!m){m=r.substr(0,l)}}}s.sort(function(t,i){return t-i});var h=0;for(var g in s){b(j+"_"+h++,f[m+s[g]])}break;case"conditional":var q=a.app.field_list[p.id].value();c(j+"|"+p.test_param.name,p.id,q);for(var g in p.cases){if(p.cases[g].value==q){b(j,n[p.id+"-section-"+g]);break}}break;default:var o=a.app.field_list[p.id];var q=o.value();if(d[p.type]){q=d[p.type](q)}if(!o.skip){c(j,p.id,q)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchModel:function(c,e){var a={};var b=this;function d(o,l){for(var k in l){var m=l[k];var h=m.name;if(o!=""){h=o+"|"+h}if(m.type=="repeat"){for(var g in m.cache){d(h+"_"+g,m.cache[g])}}else{if(m.type=="conditional"){var n=m.test_param&&m.test_param.value;for(var g in m.cases){if(m.cases[g].value==n){d(h,m.cases[g].inputs)}}}else{var f=b.app.tree.job_ids[h];if(f){e(f,m)}}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(j,h){if(typeof h==="string"){var f=b.app.tree.job_ids[j];if(f){a[f]=h}}else{for(var g in h){var e=g;if(j!==""){e=j+"|"+e}d(e,h[g])}}}d("",c);return a},references: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},_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")){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)}})}})}); \ No newline at end of file +define([],function(){return Backbone.Model.extend({initialize:function(a){this.app=a},refresh:function(){this.dict={};this.xml=$("<div/>");if(!this.app.section){return{}}this._iterate(this.app.section.$el,this.dict,this.xml)},finalize:function(d){d=d||{};var a=this;this.job_def={};this.job_ids={};function c(g,f,e){a.job_def[g]=e;a.job_ids[g]=f}function b(l,o){for(var j in o){var g=o[j];if(g.input){var q=g.input;var k=l;if(l!=""){k+="|"}k+=q.name;switch(q.type){case"repeat":var f="section-";var t=[];var n=null;for(var s in g){var m=s.indexOf(f);if(m!=-1){m+=f.length;t.push(parseInt(s.substr(m)));if(!n){n=s.substr(0,m)}}}t.sort(function(u,i){return u-i});var j=0;for(var h in t){b(k+"_"+j++,g[n+t[h]])}break;case"conditional":var r=a.app.field_list[q.id].value();c(k+"|"+q.test_param.name,q.id,r);var e=a.matchCase(q,r);if(e!=-1){b(k,o[q.id+"-section-"+e])}break;default:var p=a.app.field_list[q.id];var r=p.value();if(d[q.type]){r=d[q.type](r)}if(!p.skip){c(k,q.id,r)}}}}}b("",this.dict);return this.job_def},match:function(a){return this.job_ids&&this.job_ids[a]},matchCase:function(a,c){if(a.test_param.type=="boolean"){if(c=="true"){c=a.test_param.truevalue||"true"}else{c=a.test_param.falsevalue||"false"}}for(var b in a.cases){if(a.cases[b].value==c){return b}}return -1},matchModel:function(c,e){var a={};var b=this;function d(f,o){for(var l in o){var h=o[l];var m=h.name;if(f!=""){m=f+"|"+m}switch(h.type){case"repeat":for(var k in h.cache){d(m+"_"+k,h.cache[k])}break;case"conditional":var p=h.test_param&&h.test_param.value;var g=b.matchCase(h,p);if(g!=-1){d(m,h.cases[g].inputs)}break;default:var n=b.app.tree.job_ids[m];if(n){e(n,h)}}}}d("",c.inputs);return a},matchResponse:function(c){var a={};var b=this;function d(j,h){if(typeof h==="string"){var f=b.app.tree.job_ids[j];if(f){a[f]=h}}else{for(var g in h){var e=g;if(j!==""){e=j+"|"+e}d(e,h[g])}}}d("",c);return a},references: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},_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")){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)}})}})}); \ 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