commit/galaxy-central: guerler: ToolForm: Update select validation, remove spaces
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/bbd5375d27aa/ Changeset: bbd5375d27aa User: guerler Date: 2015-02-11 17:20:06+00:00 Summary: ToolForm: Update select validation, remove spaces Affected #: 6 files diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e 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 @@ -105,7 +105,7 @@ if (new_value !== undefined) { // reset selection this.$('input').prop('checked', false); - + // set value if (new_value !== null) { // check if its an array @@ -122,7 +122,7 @@ // refresh this._refresh(); - + // get and return value return this._getValue(); }, @@ -146,7 +146,7 @@ /** Return first available option */ first: function() { - var options = this.$('input'); + var options = this.$('input').first(); if (options.length > 0) { return options.val(); } else { diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e 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 @@ -87,21 +87,17 @@ } // validate and return value - var val = this.$select.val(); - if (!Utils.validate(val)) { - return null; - } - return val; + return this._getValue(); }, /** Return the first select option */ first: function() { - var options = this.$select.find('option'); + var options = this.$select.find('option').first(); if (options.length > 0) { return options.val(); } else { - return undefined; + return null; } }, @@ -182,7 +178,7 @@ */ update: function(options) { // backup current value - var current = this.$select.val(); + var current = this._getValue(); // remove all options this.$select.find('option').remove(); @@ -204,7 +200,7 @@ this.$select.val(current); // check if any value was set - if (!this.$select.val()) { + if (this._getValue() === null) { this.$select.val(this.first()); } @@ -232,10 +228,19 @@ */ _change: function() { if (this.options.onchange) { - this.options.onchange(this.$select.val()); + this.options.onchange(this._getValue()); } }, + /** Validate */ + _getValue: function() { + var val = this.$select.val(); + if (!Utils.validate(val)) { + return null; + } + return val; + }, + /** Refresh the select view */ _refresh: function() { diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e static/scripts/mvc/ui/ui-options.js --- a/static/scripts/mvc/ui/ui-options.js +++ b/static/scripts/mvc/ui/ui-options.js @@ -105,7 +105,7 @@ if (new_value !== undefined) { // reset selection this.$('input').prop('checked', false); - + // set value if (new_value !== null) { // check if its an array @@ -122,7 +122,7 @@ // refresh this._refresh(); - + // get and return value return this._getValue(); }, @@ -146,7 +146,7 @@ /** Return first available option */ first: function() { - var options = this.$('input'); + var options = this.$('input').first(); if (options.length > 0) { return options.val(); } else { diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e 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 @@ -87,21 +87,17 @@ } // validate and return value - var val = this.$select.val(); - if (!Utils.validate(val)) { - return null; - } - return val; + return this._getValue(); }, /** Return the first select option */ first: function() { - var options = this.$select.find('option'); + var options = this.$select.find('option').first(); if (options.length > 0) { return options.val(); } else { - return undefined; + return null; } }, @@ -182,7 +178,7 @@ */ update: function(options) { // backup current value - var current = this.$select.val(); + var current = this._getValue(); // remove all options this.$select.find('option').remove(); @@ -204,7 +200,7 @@ this.$select.val(current); // check if any value was set - if (!this.$select.val()) { + if (this._getValue() === null) { this.$select.val(this.first()); } @@ -232,10 +228,19 @@ */ _change: function() { if (this.options.onchange) { - this.options.onchange(this.$select.val()); + this.options.onchange(this._getValue()); } }, + /** Validate */ + _getValue: function() { + var val = this.$select.val(); + if (!Utils.validate(val)) { + return null; + } + return val; + }, + /** Refresh the select view */ _refresh: function() { diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e 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","mvc/ui/ui-button-check"],function(c,e){var b=Backbone.View.extend({initialize:function(i){this.optionsDefault={visible:true,data:[],id:c.uuid(),error_text:"No data available.",wait_text:"Please wait...",multiple:false};this.options=c.merge(i,this.optionsDefault);this.setElement('<div class="ui-options"/>');this.$message=$("<div/>");this.$options=$(this._template(i));this.$menu=$('<div class="ui-options-menu"/>');this.$el.append(this.$message);this.$el.append(this.$menu);this.$el.append(this.$options);if(this.options.multiple){this.select_button=new e({onclick:function(){h.$("input").prop("checked",h.select_button.value()!==0);h._change()}});this.$menu.addClass("ui-margin-bottom");this.$menu.append(this.select_button.$el);this.$menu.append("Select/Unselect all")}if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var h=this;this.on("change",function(){h._change()})},update:function(i){var l=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(i))}else{for(var j in i){var k=$(this._templateOption(i[j]));k.addClass("ui-option");k.tooltip({title:i[j].tooltip,placement:"bottom"});this.$options.append(k)}}var h=this;this.$("input").on("change",function(){h.value(h._getValue());h._change()});this.value(l)},value:function(j){if(j!==undefined){this.$("input").prop("checked",false);if(j!==null){if(!(j instanceof Array)){j=[j]}for(var h in j){this.$('input[value="'+j[h]+'"]').first().prop("checked",true)}}}this._refresh();return this._getValue()},exists:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}for(var h in j){if(this.$('input[value="'+j[h]+'"]').length>0){return true}}}return false},first:function(){var h=this.$("input");if(h.length>0){return h.val()}else{return null}},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide();this.$menu.hide()}},unwait:function(){this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide();this.$menu.hide()}else{this._messageHide();this.$options.css("display","inline-block");this.$menu.show()}if(this.select_button){var h=this._size();var i=this._getValue();if(!(i instanceof Array)){this.select_button.value(0)}else{if(i.length!==h){this.select_button.value(1)}else{this.select_button.value(2)}}}},_getValue:function(){var h=[];this.$(":checked").each(function(){h.push($(this).val())});if(!c.validate(h)){return null}if(this.options.multiple){return h}else{return h[0]}},_size:function(){return this.$(".ui-option").length},_messageShow:function(i,h){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+h);this.$message.html(i)},_messageHide:function(){this.$message.hide()},_template:function(){return'<div class="ui-options-list"/>'}});var a=b.extend({_templateOption:function(h){var i=c.uuid();return'<div class="ui-option"><input id="'+i+'" type="'+this.options.type+'" name="'+this.options.id+'" value="'+h.value+'"/><label class="ui-options-label" for="'+i+'">'+h.label+"</label></div>"}});var f={};f.View=a.extend({initialize:function(h){h.type="radio";a.prototype.initialize.call(this,h)}});var d={};d.View=a.extend({initialize:function(h){h.multiple=true;h.type="checkbox";a.prototype.initialize.call(this,h)}});var g={};g.View=b.extend({initialize:function(h){b.prototype.initialize.call(this,h)},value:function(h){if(h!==undefined){this.$("input").prop("checked",false);this.$("label").removeClass("active");this.$('[value="'+h+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(j){var h="fa "+j.icon;if(!j.label){h+=" no-padding"}var i='<label class="btn btn-default">';if(j.icon){i+='<i class="'+h+'"/>'}i+='<input type="radio" name="'+this.options.id+'" value="'+j.value+'"/>';if(j.label){i+=j.label}i+="</label>";return i},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:b,BaseIcons:a,Radio:f,RadioButton:g,Checkbox:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-button-check"],function(c,e){var b=Backbone.View.extend({initialize:function(i){this.optionsDefault={visible:true,data:[],id:c.uuid(),error_text:"No data available.",wait_text:"Please wait...",multiple:false};this.options=c.merge(i,this.optionsDefault);this.setElement('<div class="ui-options"/>');this.$message=$("<div/>");this.$options=$(this._template(i));this.$menu=$('<div class="ui-options-menu"/>');this.$el.append(this.$message);this.$el.append(this.$menu);this.$el.append(this.$options);if(this.options.multiple){this.select_button=new e({onclick:function(){h.$("input").prop("checked",h.select_button.value()!==0);h._change()}});this.$menu.addClass("ui-margin-bottom");this.$menu.append(this.select_button.$el);this.$menu.append("Select/Unselect all")}if(!this.options.visible){this.$el.hide()}this.update(this.options.data);if(this.options.value!==undefined){this.value(this.options.value)}var h=this;this.on("change",function(){h._change()})},update:function(i){var l=this._getValue();this.$options.empty();if(this._templateOptions){this.$options.append(this._templateOptions(i))}else{for(var j in i){var k=$(this._templateOption(i[j]));k.addClass("ui-option");k.tooltip({title:i[j].tooltip,placement:"bottom"});this.$options.append(k)}}var h=this;this.$("input").on("change",function(){h.value(h._getValue());h._change()});this.value(l)},value:function(j){if(j!==undefined){this.$("input").prop("checked",false);if(j!==null){if(!(j instanceof Array)){j=[j]}for(var h in j){this.$('input[value="'+j[h]+'"]').first().prop("checked",true)}}}this._refresh();return this._getValue()},exists:function(j){if(j!==undefined){if(!(j instanceof Array)){j=[j]}for(var h in j){if(this.$('input[value="'+j[h]+'"]').length>0){return true}}}return false},first:function(){var h=this.$("input").first();if(h.length>0){return h.val()}else{return null}},wait:function(){if(this._size()==0){this._messageShow(this.options.wait_text,"info");this.$options.hide();this.$menu.hide()}},unwait:function(){this._refresh()},_change:function(){if(this.options.onchange){this.options.onchange(this._getValue())}},_refresh:function(){if(this._size()==0){this._messageShow(this.options.error_text,"danger");this.$options.hide();this.$menu.hide()}else{this._messageHide();this.$options.css("display","inline-block");this.$menu.show()}if(this.select_button){var h=this._size();var i=this._getValue();if(!(i instanceof Array)){this.select_button.value(0)}else{if(i.length!==h){this.select_button.value(1)}else{this.select_button.value(2)}}}},_getValue:function(){var h=[];this.$(":checked").each(function(){h.push($(this).val())});if(!c.validate(h)){return null}if(this.options.multiple){return h}else{return h[0]}},_size:function(){return this.$(".ui-option").length},_messageShow:function(i,h){this.$message.show();this.$message.removeClass();this.$message.addClass("ui-message alert alert-"+h);this.$message.html(i)},_messageHide:function(){this.$message.hide()},_template:function(){return'<div class="ui-options-list"/>'}});var a=b.extend({_templateOption:function(h){var i=c.uuid();return'<div class="ui-option"><input id="'+i+'" type="'+this.options.type+'" name="'+this.options.id+'" value="'+h.value+'"/><label class="ui-options-label" for="'+i+'">'+h.label+"</label></div>"}});var f={};f.View=a.extend({initialize:function(h){h.type="radio";a.prototype.initialize.call(this,h)}});var d={};d.View=a.extend({initialize:function(h){h.multiple=true;h.type="checkbox";a.prototype.initialize.call(this,h)}});var g={};g.View=b.extend({initialize:function(h){b.prototype.initialize.call(this,h)},value:function(h){if(h!==undefined){this.$("input").prop("checked",false);this.$("label").removeClass("active");this.$('[value="'+h+'"]').prop("checked",true).closest("label").addClass("active")}return this._getValue()},_templateOption:function(j){var h="fa "+j.icon;if(!j.label){h+=" no-padding"}var i='<label class="btn btn-default">';if(j.icon){i+='<i class="'+h+'"/>'}i+='<input type="radio" name="'+this.options.id+'" value="'+j.value+'"/>';if(j.label){i+=j.label}i+="</label>";return i},_template:function(){return'<div class="btn-group ui-radiobutton" data-toggle="buttons"/>'}});return{Base:b,BaseIcons:a,Radio:f,RadioButton:g,Checkbox:d}}); \ No newline at end of file diff -r 52e80be61a360ea2cf1387920ebdffdff5c0218c -r bbd5375d27aaeac049a37c29a3c7fa98e96f7e5e 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:"",error_text:"No data available",empty_text:"No selection",visible:true,wait:false,multiple:false,searchable:false,optional: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");this.$button=this.$el.find(".button");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.value!==undefined){this.value(this.options.value)}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){if(c===null){c="__null__"}this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}var d=this.$select.val();if(!a.validate(d)){return null}return d},first:function(){var c=this.$select.find("option");if(c.length>0){return c.val()}else{return undefined}},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},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();if(this.options.optional&&!this.options.multiple){this.$select.append(this._templateOption({value:"__null__",label:this.options.empty_text}))}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())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},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="__undefined__"]').remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"__undefined__",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></div>'}});return{View:b}}); \ No newline at end of file +define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{id:"",cls:"",error_text:"No data available",empty_text:"No selection",visible:true,wait:false,multiple:false,searchable:false,optional: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");this.$button=this.$el.find(".button");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.value!==undefined){this.value(this.options.value)}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){if(c===null){c="__null__"}this.$select.val(c);if(this.$select.select2){this.$select.select2("val",c)}}return this._getValue()},first:function(){var c=this.$select.find("option").first();if(c.length>0){return c.val()}else{return null}},text:function(){return this.$select.find("option:selected").text()},show:function(){this.unwait();this.$select.show();this.$el.show()},hide:function(){this.$el.hide()},wait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-spinner fa-spin")},unwait:function(){this.$icon.removeClass();this.$icon.addClass("fa fa-caret-down")},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._getValue();this.$select.find("option").remove();if(this.options.optional&&!this.options.multiple){this.$select.append(this._templateOption({value:"__null__",label:this.options.empty_text}))}for(var d in c){this.$select.append(this._templateOption(c[d]))}this._refresh();this.$select.val(e);if(this._getValue()===null){this.$select.val(this.first())}if(this.options.searchable){this.$button.hide();this.$select.select2("destroy");this.$select.select2()}},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._getValue())}},_getValue:function(){var c=this.$select.val();if(!a.validate(c)){return null}return c},_refresh:function(){this.$select.find('option[value="__undefined__"]').remove();var c=this.$select.find("option").length;if(c==0){this.disable();this.$select.append(this._templateOption({value:"__undefined__",label:this.options.error_text}))}else{this.enable()}},_templateOption:function(c){return'<option value="'+c.value+'">'+c.label+"</option>"},_template:function(c){return'<div id="'+c.id+'"><select id="select" class="select '+c.cls+" "+c.id+'"></select><div class="button"><i class="icon"/></div></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