commit/galaxy-central: guerler: ToolForm: Improve validation, minor fixes
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f02fcf8a931c/ Changeset: f02fcf8a931c User: guerler Date: 2014-09-25 20:14:56+00:00 Summary: ToolForm: Improve validation, minor fixes Affected #: 12 files diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 client/galaxy/scripts/mvc/tools/tools-jobs.js --- a/client/galaxy/scripts/mvc/tools/tools-jobs.js +++ b/client/galaxy/scripts/mvc/tools/tools-jobs.js @@ -46,18 +46,35 @@ console.debug(response); if (response && response.message && response.message.data) { var error_messages = self.app.tree.matchResponse(response.message.data); - for (var id in error_messages) { - var error_text = error_messages[id]; - if (!error_text) { - error_text = 'Please verify this parameter.'; - } - self.app.element_list[id].error(error_text); + for (var input_id in error_messages) { + self._foundError(input_id, error_messages[input_id]); } } } ); }, + /** Highlight and scroll to error + */ + _foundError: function (input_id, message) { + // get input field + var input_element = this.app.element_list[input_id]; + + // mark error + input_element.error(message || 'Please verify this parameter.'); + + // set flag + if (this.valid) { + // scroll to first input element + $(this.app.container).animate({ + scrollTop: input_element.$el.offset().top - 20 + }, 500); + + // set error flag + this.valid = false; + } + }, + /** Validate job definition */ _validation: function(job_def) { @@ -65,30 +82,7 @@ var job_inputs = job_def.inputs; // validation flag - var valid = true; - - // link this - var self = this; - - /** Highlight and scroll to error */ - function foundError (input_id, message) { - // get input field - var input_element = self.app.element_list[input_id]; - - // mark error - input_element.error(message || 'Please verify this parameter.'); - - // set flag - if (valid) { - // scroll to first input element - $(self.app.container).animate({ - scrollTop: input_element.$el.offset().top - 20 - }, 500); - - // set error flag - valid = false; - } - } + this.valid = true; // counter for values declared in batch mode var n_values = -1; @@ -105,7 +99,7 @@ // check basic field validation if (input_def && !input_def.optional && input_field && input_field.validate && !input_field.validate()) { - foundError(input_id); + this._foundError(input_id); } // check if input field is in batch mode @@ -115,15 +109,15 @@ n_values = n; } else { if (n_values !== n) { - foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); + this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); } } } } - // return result - return valid; + // return validation result + return this.valid; }, /** Refreshes the history panel diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 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 @@ -540,6 +540,10 @@ /** Slider field */ _field_slider: function(input_def) { + // set min/max + input_def.min = input_def.min || 0; + input_def.max = input_def.max || 100000; + // calculate step size var step = 1; if (input_def.type == 'float') { @@ -549,8 +553,8 @@ // create slider return new Ui.Slider.View({ id : 'field-' + input_def.id, - min : input_def.min || 0, - max : input_def.max || 1000, + min : input_def.min, + max : input_def.max, step : step }); }, diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 client/galaxy/scripts/mvc/ui/ui-options.js --- a/client/galaxy/scripts/mvc/ui/ui-options.js +++ b/client/galaxy/scripts/mvc/ui/ui-options.js @@ -114,7 +114,7 @@ current = [current]; } for (var i in current) { - if (current[i] === 'null' || !current[i]) { + if (current[i] === 'null') { return false; } } @@ -149,7 +149,7 @@ // get selected values var selected = this.$el.find(':checked'); if (selected.length == 0) { - return null; + return 'null'; } // return multiple or single value diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 client/galaxy/scripts/mvc/ui/ui-select-default.js --- a/client/galaxy/scripts/mvc/ui/ui-select-default.js +++ b/client/galaxy/scripts/mvc/ui/ui-select-default.js @@ -91,7 +91,7 @@ current = [current]; } for (var i in current) { - if (current[i] === 'null' || !current[i]) { + if (current[i] === 'null') { return false; } } diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/mvc/tools/tools-jobs.js --- a/static/scripts/mvc/tools/tools-jobs.js +++ b/static/scripts/mvc/tools/tools-jobs.js @@ -46,18 +46,35 @@ console.debug(response); if (response && response.message && response.message.data) { var error_messages = self.app.tree.matchResponse(response.message.data); - for (var id in error_messages) { - var error_text = error_messages[id]; - if (!error_text) { - error_text = 'Please verify this parameter.'; - } - self.app.element_list[id].error(error_text); + for (var input_id in error_messages) { + self._foundError(input_id, error_messages[input_id]); } } } ); }, + /** Highlight and scroll to error + */ + _foundError: function (input_id, message) { + // get input field + var input_element = this.app.element_list[input_id]; + + // mark error + input_element.error(message || 'Please verify this parameter.'); + + // set flag + if (this.valid) { + // scroll to first input element + $(this.app.container).animate({ + scrollTop: input_element.$el.offset().top - 20 + }, 500); + + // set error flag + this.valid = false; + } + }, + /** Validate job definition */ _validation: function(job_def) { @@ -65,30 +82,7 @@ var job_inputs = job_def.inputs; // validation flag - var valid = true; - - // link this - var self = this; - - /** Highlight and scroll to error */ - function foundError (input_id, message) { - // get input field - var input_element = self.app.element_list[input_id]; - - // mark error - input_element.error(message || 'Please verify this parameter.'); - - // set flag - if (valid) { - // scroll to first input element - $(self.app.container).animate({ - scrollTop: input_element.$el.offset().top - 20 - }, 500); - - // set error flag - valid = false; - } - } + this.valid = true; // counter for values declared in batch mode var n_values = -1; @@ -105,7 +99,7 @@ // check basic field validation if (input_def && !input_def.optional && input_field && input_field.validate && !input_field.validate()) { - foundError(input_id); + this._foundError(input_id); } // check if input field is in batch mode @@ -115,15 +109,15 @@ n_values = n; } else { if (n_values !== n) { - foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); + this._foundError(input_id, 'Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>' + n + '</b> selection(s) while a previous field contains <b>' + n_values + '</b>.'); } } } } - // return result - return valid; + // return validation result + return this.valid; }, /** Refreshes the history panel diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/mvc/tools/tools-section.js --- a/static/scripts/mvc/tools/tools-section.js +++ b/static/scripts/mvc/tools/tools-section.js @@ -540,6 +540,10 @@ /** Slider field */ _field_slider: function(input_def) { + // set min/max + input_def.min = input_def.min || 0; + input_def.max = input_def.max || 100000; + // calculate step size var step = 1; if (input_def.type == 'float') { @@ -549,8 +553,8 @@ // create slider return new Ui.Slider.View({ id : 'field-' + input_def.id, - min : input_def.min || 0, - max : input_def.max || 1000, + min : input_def.min, + max : input_def.max, step : step }); }, diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/mvc/ui/ui-options.js --- a/static/scripts/mvc/ui/ui-options.js +++ b/static/scripts/mvc/ui/ui-options.js @@ -114,7 +114,7 @@ current = [current]; } for (var i in current) { - if (current[i] === 'null' || !current[i]) { + if (current[i] === 'null') { return false; } } @@ -149,7 +149,7 @@ // get selected values var selected = this.$el.find(':checked'); if (selected.length == 0) { - return null; + return 'null'; } // return multiple or single value diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/mvc/ui/ui-select-default.js --- a/static/scripts/mvc/ui/ui-select-default.js +++ b/static/scripts/mvc/ui/ui-select-default.js @@ -91,7 +91,7 @@ current = [current]; } for (var i in current) { - if (current[i] === 'null' || !current[i]) { + if (current[i] === 'null') { return false; } } diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/packed/mvc/tools/tools-jobs.js --- a/static/scripts/packed/mvc/tools/tools-jobs.js +++ b/static/scripts/packed/mvc/tools/tools-jobs.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.log(d);b.request("POST",galaxy_config.root+"api/tools",d,function(e){c.app.message(a.success(e));c._refreshHdas()},function(e){console.debug(e);if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var g in h){var f=h[g];if(!f){f="Please verify this parameter."}c.app.element_list[g].error(f)}}})},_validation:function(h){var e=h.inputs;var c=true;var o=this;function m(n,p){var q=o.app.element_list[n];q.error(p||"Please verify this parameter.");if(c){$(o.app.container).animate({scrollTop:q.$el.offset().top-20},500);c=false}}var l=-1;for(var k in e){var f=e[k];var j=this.app.tree.match(k);var d=this.app.field_list[j];var i=this.app.input_list[j];if(i&&!i.optional&&d&&d.validate&&!d.validate()){m(j)}if(f.batch){var g=f.values.length;if(l===-1){l=g}else{if(l!==g){m(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+g+"</b> selection(s) while a previous field contains <b>"+l+"</b>.")}}}}return c},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})}); \ No newline at end of file +define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.log(d);b.request("POST",galaxy_config.root+"api/tools",d,function(e){c.app.message(a.success(e));c._refreshHdas()},function(e){console.debug(e);if(e&&e.message&&e.message.data){var g=c.app.tree.matchResponse(e.message.data);for(var f in g){c._foundError(f,g[f])}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");if(this.valid){$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500);this.valid=false}},_validation:function(g){var c=g.inputs;this.valid=true;var k=-1;for(var i in c){var e=c[i];var j=this.app.tree.match(i);var d=this.app.field_list[j];var h=this.app.input_list[j];if(h&&!h.optional&&d&&d.validate&&!d.validate()){this._foundError(j)}if(e.batch){var f=e.values.length;if(k===-1){k=f}else{if(k!==f){this._foundError(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+f+"</b> selection(s) while a previous field contains <b>"+k+"</b>.")}}}}return this.valid},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})}); \ No newline at end of file diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 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-dataset"],function(d,a,g,c,b){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new a.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=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(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._field_text(h);break;case"select":i=this._field_select(h);break;case"data":i=this._field_data(h);break;case"data_column":i=this._field_select(h);break;case"conditional":i=this._field_conditional(h);break;case"hidden":i=this._field_hidden(h);break;case"integer":i=this._field_slider(h);break;case"float":i=this._field_slider(h);break;case"boolean":i=this._field_boolean(h);break}if(!i){if(h.options){i=this._field_select(h)}else{i=this._field_text(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,help:h.help,$el:i.$el});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_field_conditional: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()}}}})},_field_data:function(h){var i=this;var j=h.id;return new b.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(l){var v=l.values[0].id;var t=i.app.tree.references(j,"data_column");if(t.length<=0){console.debug("tool-form::field_data() - Data column parameters unavailable.");return}var o=i.app.datasets.filter(v);var x=null;if(o){console.debug("tool-form::field_data() - Selected dataset "+v+".");x=o.get("metadata_column_types");if(!x){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+v+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+v+".")}for(var p in t){var r=i.app.input_list[t[p]];var s=i.app.field_list[t[p]];if(!r||!s){console.debug("tool-form::field_data() - FAILED: Column not found.")}var n=r.numerical;var m=[];for(var w in x){var u=x[w];var k=(parseInt(w)+1);var q="Text";if(u=="int"||u=="float"){q="Number"}if(u=="int"||u=="float"||!n){m.push({label:"Column: "+k+" ["+q+"]",value:k})}}if(s){s.update(m);if(!s.exists(s.value())){s.value(s.first())}}}}})},_field_select: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})},_field_text:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_field_slider:function(h){var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min||0,max:h.max||1000,step:i})},_field_hidden:function(h){return new g.Hidden({id:"field-"+h.id})},_field_boolean: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-dataset"],function(d,a,g,c,b){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new a.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=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(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._field_text(h);break;case"select":i=this._field_select(h);break;case"data":i=this._field_data(h);break;case"data_column":i=this._field_select(h);break;case"conditional":i=this._field_conditional(h);break;case"hidden":i=this._field_hidden(h);break;case"integer":i=this._field_slider(h);break;case"float":i=this._field_slider(h);break;case"boolean":i=this._field_boolean(h);break}if(!i){if(h.options){i=this._field_select(h)}else{i=this._field_text(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,help:h.help,$el:i.$el});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_field_conditional: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()}}}})},_field_data:function(h){var i=this;var j=h.id;return new b.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(l){var v=l.values[0].id;var t=i.app.tree.references(j,"data_column");if(t.length<=0){console.debug("tool-form::field_data() - Data column parameters unavailable.");return}var o=i.app.datasets.filter(v);var x=null;if(o){console.debug("tool-form::field_data() - Selected dataset "+v+".");x=o.get("metadata_column_types");if(!x){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+v+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+v+".")}for(var p in t){var r=i.app.input_list[t[p]];var s=i.app.field_list[t[p]];if(!r||!s){console.debug("tool-form::field_data() - FAILED: Column not found.")}var n=r.numerical;var m=[];for(var w in x){var u=x[w];var k=(parseInt(w)+1);var q="Text";if(u=="int"||u=="float"){q="Number"}if(u=="int"||u=="float"||!n){m.push({label:"Column: "+k+" ["+q+"]",value:k})}}if(s){s.update(m);if(!s.exists(s.value())){s.value(s.first())}}}}})},_field_select: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})},_field_text:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_field_slider:function(h){h.min=h.min||0;h.max=h.max||100000;var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min,max:h.max,step:i})},_field_hidden:function(h){return new g.Hidden({id:"field-"+h.id})},_field_boolean: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 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/packed/mvc/ui/ui-options.js --- a/static/scripts/packed/mvc/ui/ui-options.js +++ b/static/scripts/packed/mvc/ui/ui-options.js @@ -1,1 +1,1 @@ -define(["utils/utils"],function(b){var a=Backbone.View.extend({initialize:function(g){this.optionsDefault={value:[],visible:true,data:[],id:b.uuid(),empty:"No data available"};this.options=b.merge(g,this.optionsDefault);this.setElement("<div/>");this.$error=$(this._templateError(g));this.$options=$(this._template(g));this.$el.append(this.$error);this.$el.append(this.$options);if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value){this.value(this.options.value)}var f=this;this.on("change",function(){f._change()})},update:function(g){var j=this._getValue();this.$el.find(".ui-option").remove();for(var h in g){var i=$(this._templateOption(g[h]));i.addClass("ui-option");this.$options.append(i)}var f=this;this.$el.find("input").on("change",function(){f.value(f._getValue());f._change()});this._refresh();this.value(j)},exists:function(g){if(typeof g==="string"){g=[g]}for(var f in g){if(this.$el.find('input[value="'+g[f]+'"]').length>0){return true}}return false},first:function(){var f=this.$el.find("input");if(f.length>0){return f.val()}else{return undefined}},validate:function(){var g=this.value();if(!(g instanceof Array)){g=[g]}for(var f in g){if(g[f]==="null"||!g[f]){return false}}return true},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){var f=this.$el.find(".ui-option").length;if(f==0){this.$error.show();this.$options.hide()}else{this.$error.hide();this.$options.css("display","inline-block")}},_getValue:function(){var g=this.$el.find(":checked");if(g.length==0){return null}if(this.options.multiple){var f=[];g.each(function(){f.push($(this).val())});return f}else{return g.val()}},_templateError:function(f){return'<div class="ui-error" style="display: none;">'+f.empty+"</div>"}});var d={};d.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},value:function(f){if(typeof f==="string"){f=[f]}if(f!==undefined){this.$el.find("input").prop("checked",false);for(var g in f){this.$el.find("input[value="+f[g]+"]").prop("checked",true)}}return this._getValue()},_templateOption:function(f){return'<div><input type="radio" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"},_template:function(){return'<div class="ui-options"/>'}});var c={};c.View=d.View.extend({initialize:function(f){f.multiple=true;d.View.prototype.initialize.call(this,f)},_templateOption:function(f){return'<div><input type="checkbox" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"}});var e={};e.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},value:function(f){if(f!==undefined){this.$el.find("input").prop("checked",false);this.$el.find("label").removeClass("active");this.$el.find('[value="'+f+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(g){var f='<label class="btn btn-default">';if(g.icon){f+='<i class="fa '+g.icon+'"/>'}f+='<input type="radio" name="'+this.options.id+'" value="'+g.value+'">'+g.label+"</label>";return f},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Radio:d,RadioButton:e,Checkbox:c}}); \ No newline at end of file +define(["utils/utils"],function(b){var a=Backbone.View.extend({initialize:function(g){this.optionsDefault={value:[],visible:true,data:[],id:b.uuid(),empty:"No data available"};this.options=b.merge(g,this.optionsDefault);this.setElement("<div/>");this.$error=$(this._templateError(g));this.$options=$(this._template(g));this.$el.append(this.$error);this.$el.append(this.$options);if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value){this.value(this.options.value)}var f=this;this.on("change",function(){f._change()})},update:function(g){var j=this._getValue();this.$el.find(".ui-option").remove();for(var h in g){var i=$(this._templateOption(g[h]));i.addClass("ui-option");this.$options.append(i)}var f=this;this.$el.find("input").on("change",function(){f.value(f._getValue());f._change()});this._refresh();this.value(j)},exists:function(g){if(typeof g==="string"){g=[g]}for(var f in g){if(this.$el.find('input[value="'+g[f]+'"]').length>0){return true}}return false},first:function(){var f=this.$el.find("input");if(f.length>0){return f.val()}else{return undefined}},validate:function(){var g=this.value();if(!(g instanceof Array)){g=[g]}for(var f in g){if(g[f]==="null"){return false}}return true},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){var f=this.$el.find(".ui-option").length;if(f==0){this.$error.show();this.$options.hide()}else{this.$error.hide();this.$options.css("display","inline-block")}},_getValue:function(){var g=this.$el.find(":checked");if(g.length==0){return"null"}if(this.options.multiple){var f=[];g.each(function(){f.push($(this).val())});return f}else{return g.val()}},_templateError:function(f){return'<div class="ui-error" style="display: none;">'+f.empty+"</div>"}});var d={};d.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},value:function(f){if(typeof f==="string"){f=[f]}if(f!==undefined){this.$el.find("input").prop("checked",false);for(var g in f){this.$el.find("input[value="+f[g]+"]").prop("checked",true)}}return this._getValue()},_templateOption:function(f){return'<div><input type="radio" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"},_template:function(){return'<div class="ui-options"/>'}});var c={};c.View=d.View.extend({initialize:function(f){f.multiple=true;d.View.prototype.initialize.call(this,f)},_templateOption:function(f){return'<div><input type="checkbox" name="'+this.options.id+'" value="'+f.value+'"/>'+f.label+"<br></div>"}});var e={};e.View=a.extend({initialize:function(f){a.prototype.initialize.call(this,f)},value:function(f){if(f!==undefined){this.$el.find("input").prop("checked",false);this.$el.find("label").removeClass("active");this.$el.find('[value="'+f+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(g){var f='<label class="btn btn-default">';if(g.icon){f+='<i class="fa '+g.icon+'"/>'}f+='<input type="radio" name="'+this.options.id+'" value="'+g.value+'">'+g.label+"</label>";return f},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Radio:d,RadioButton:e,Checkbox:c}}); \ No newline at end of file diff -r 82f8d68414f5c9a0e5aeaaabca85cf7044e06183 -r f02fcf8a931c4862cfb6698da0e097d68c8025c6 static/scripts/packed/mvc/ui/ui-select-default.js --- a/static/scripts/packed/mvc/ui/ui-select-default.js +++ b/static/scripts/packed/mvc/ui/ui-select-default.js @@ -1,1 +1,1 @@ -define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",empty:"No data available",visible:true,wait:false,multiple:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find("#select");this.$icon=this.$el.find("#icon");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){this.$select.val(c)}return this.$select.val()},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},validate:function(){var d=this.value();if(!(d instanceof Array)){d=[d]}for(var c in d){if(d[c]==="null"||!d[c]){return false}}return true},text:function(){return this.$select.find("option:selected").text()},show:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down");this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin");this.$select.hide()},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find("option[value=null]").remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"null",label:this.options.empty}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><div class="button"><i id="icon"/></div><select id="select" class="select '+c.cls+" "+c.id+'"></select></div>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",empty:"No data available",visible:true,wait:false,multiple:false},initialize:function(d){this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$select=this.$el.find("#select");this.$icon=this.$el.find("#icon");if(this.options.multiple){this.$select.prop("multiple",true);this.$select.addClass("ui-select-multiple");this.$icon.remove()}else{this.$el.addClass("ui-select")}this.update(this.options.data);if(!this.options.visible){this.hide()}if(this.options.wait){this.wait()}else{this.show()}var c=this;this.$select.on("change",function(){c._change()});this.on("change",function(){c._change()})},value:function(c){if(c!==undefined){this.$select.val(c)}return this.$select.val()},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},validate:function(){var d=this.value();if(!(d instanceof Array)){d=[d]}for(var c in d){if(d[c]==="null"){return false}}return true},text:function(){return this.$select.find("option:selected").text()},show:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down");this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin");this.$select.hide()},disabled:function(){return this.$select.is(":disabled")},enable:function(){this.$select.prop("disabled",false)},disable:function(){this.$select.prop("disabled",true)},add:function(c){this.$select.append(this._templateOption(c));this._refresh()},del:function(c){this.$select.find("option[value="+c+"]").remove();this.$select.trigger("change");this._refresh()},update:function(c){var e=this.$select.val();this.$select.find("option").remove();for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(!this.$select.val()){this.$select.val(this.first())}},setOnChange:function(c){this.options.onchange=c},exists:function(c){return this.$select.find('option[value="'+c+'"]').length>0},_change:function(){if(this.options.onchange){this.options.onchange(this.$select.val())}},_refresh:function(){this.$select.find("option[value=null]").remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"null",label:this.options.empty}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><div class="button"><i id="icon"/></div><select id="select" class="select '+c.cls+" "+c.id+'"></select></div>'}});return{View:b}}); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org