1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/15cd0c4f1a40/ Changeset: 15cd0c4f1a40 User: guerler Date: 2015-02-11 16:03:22+00:00 Summary: ToolForm: Move forward with drill down element, simplify validation Affected #: 21 files diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/tools/tools-input.js --- a/client/galaxy/scripts/mvc/tools/tools-input.js +++ b/client/galaxy/scripts/mvc/tools/tools-input.js @@ -34,9 +34,9 @@ this.field.skip = false; var v = this.field.value && this.field.value(); this.field.skip = Boolean(options.optional && - (((this.field.validate && !this.field.validate()) || !v || - (v == this.default_value) || (Number(v) == Number(this.default_value)) || - (JSON.stringify(v) == JSON.stringify(this.default_value))))); + ((v === null || (v == this.default_value) || + (Number(v) == Number(this.default_value)) || + (JSON.stringify(v) == JSON.stringify(this.default_value))))); // refresh view this._refresh(); diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/tools/tools-select-content.js --- a/client/galaxy/scripts/mvc/tools/tools-select-content.js +++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js @@ -233,18 +233,28 @@ console.debug('tools-select-content::value() - Skipped.'); } } else { - this.select_single && this.select_single.value('__null__'); - this.select_multiple && this.select_multiple.value('__null__'); - this.select_collection && this.select_collection.value('__null__'); + this.select_single && this.select_single.value(null); + this.select_multiple && this.select_multiple.value(null); + this.select_collection && this.select_collection.value(null); } this.refresh(); } + // validate value + var id_list = this._select().value(); + if (id_list === null) { + return null; + } + // transform into an array - var id_list = this._select().value(); if (!(id_list instanceof Array)) { id_list = [id_list]; } + + // check if value exists + if (id_list.length === 0) { + return null; + } // prepare result dict var result = { @@ -264,12 +274,6 @@ return result; }, - /** Validate current selection - */ - validate: function() { - return this._select().validate(); - }, - /** Refreshes data selection view */ refresh: function() { this.button_type.value(this.current); diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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 @@ -118,9 +118,6 @@ if (field && field.value) { // validate field value var value = field.value(); - if (field.validate && !field.validate()) { - value = null; - } // get and patch field value if (patch[input.type]) { @@ -128,7 +125,7 @@ } // ignore certain values - if (input.ignore === undefined || (value !== null && input.ignore != value)) { + if (input.ignore === undefined || input.ignore != value) { // add value to submission add (job_input_id, input.id, value); diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/mvc/ui/ui-drilldown.js --- a/client/galaxy/scripts/mvc/ui/ui-drilldown.js +++ b/client/galaxy/scripts/mvc/ui/ui-drilldown.js @@ -12,33 +12,44 @@ Options.BaseIcons.prototype.initialize.call(this, options); }, + /** Expand/collapse a sub group + */ + _setState: function (header_id, is_expanded) { + var $button = this.$('#button-' + header_id); + var $subgroup = this.$('#subgroup-' + header_id); + $button.data('is_expanded', is_expanded); + if (is_expanded) { + $subgroup.fadeIn('fast') + $button.removeClass('toggle-expand'); + $button.addClass('toggle'); + } else { + $subgroup.hide(); + $button.removeClass('toggle'); + $button.addClass('toggle-expand'); + } + }, + /** Template to create options tree */ _templateOptions: function(options) { // link this var self = this; - // attach show/hide event - function attachEvents($button, $subgroup) { - function setVisibility (visible) { - if (visible) { - $subgroup.fadeIn('fast') - $button.removeClass('toggle-expand'); - $button.addClass('toggle'); - $button.is_expanded = true; - } else { - $subgroup.hide(); - $button.removeClass('toggle'); - $button.addClass('toggle-expand'); - $button.is_expanded = false; - } - }; + + // link data + this.header_index = {}; + this.header_list = []; + + // attach event handler + function attach($el, header_id) { + var $button = $el.find('#button-' + header_id); $button.on('click', function() { - setVisibility(!$button.is_expanded); + self._setState(header_id, !$button.data('is_expanded')); }); } // recursive function which iterates through options - function iterate ($tmpl, options) { + function iterate ($tmpl, options, header) { + header = header || []; for (i in options) { // current option level in hierarchy var level = options[i]; @@ -46,13 +57,21 @@ // check for options var has_options = level.options.length > 0; + // copy current header list + var new_header = header.slice(0); + // build template var $group = $('<div/>'); if (has_options) { - // create button and add flag - var $button = $('<span class="ui-drilldown-button form-toggle icon-button toggle-expand"/>'); + // create button and subgroup + var header_id = Utils.uuid(); + var $button = $('<span id="button-' + header_id + '" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>'); + var $subgroup = $('<div id="subgroup-' + header_id + '" style="display: none; margin-left: 25px;"/>'); - // add expand group + // keep track of button and subgroup + new_header.push(header_id); + + // create expandable header section var $buttongroup = $('<div/>'); $buttongroup.append($button); $buttongroup.append(self._templateOption({ @@ -60,19 +79,17 @@ value: level.value })); $group.append($buttongroup); - - // add sub group - var $subgroup = $('<div style="display: none; margin-left: 25px;"/>'); - iterate($subgroup, level.options); + iterate($subgroup, level.options, new_header); $group.append($subgroup); - - // attach click event to collapse/expand hierarchy - attachEvents($button, $subgroup); } else { + // append child options $group.append(self._templateOption({ label: level.name, value: level.value })); + + // keep track of header list + self.header_index[level.value] = new_header; } $tmpl.append($group); } @@ -81,6 +98,18 @@ // iterate through options and create dom var $tmpl = $('<div/>'); iterate($tmpl, options); + + // merge index to create a non-duplicate list of headers + for (var i in this.header_index) { + this.header_list = _.uniq(this.header_list.concat(this.header_index[i])); + } + + // attach expand/collapse events + for (var i in this.header_list) { + attach($tmpl, this.header_list[i]); + } + + // return template return $tmpl; }, diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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 @@ -101,19 +101,22 @@ /** Return/Set current value */ value: function (new_value) { - // set new value if provided + // set new value if available if (new_value !== undefined) { - // check if its an array - if (!(new_value instanceof Array)) { - new_value = [new_value]; - } - // reset selection this.$('input').prop('checked', false); + + // set value + if (new_value !== null) { + // check if its an array + if (!(new_value instanceof Array)) { + new_value = [new_value]; + } - // update to new selection - for (var i in new_value) { - this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true); + // update to new selection + for (var i in new_value) { + this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true); + } }; } @@ -147,16 +150,10 @@ if (options.length > 0) { return options.val(); } else { - return undefined; + return null; } }, - /** Validate the selected option/options - */ - validate: function() { - return Utils.validate(this.value()); - }, - /** Wait message during request processing */ wait: function() { @@ -213,21 +210,22 @@ /** Return current selection */ _getValue: function() { - // get selected values - var selected = this.$(':checked'); - if (selected.length == 0) { - return '__null__'; + // track values in array + var selected = []; + this.$(':checked').each(function() { + selected.push($(this).val()); + }); + + // get selected elements + if (!Utils.validate(selected)) { + return null; } - + // return multiple or single value if (this.options.multiple) { - var values = []; - selected.each(function() { - values.push($(this).val()); - }); - return values; + return selected; } else { - return selected.val(); + return selected[0]; } }, diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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 @@ -75,13 +75,23 @@ /** Return/Set current selection */ value : function (new_value) { + // set new value if (new_value !== undefined) { + if (new_value === null) { + new_value = '__null__'; + } this.$select.val(new_value); if (this.$select.select2) { this.$select.select2('val', new_value); } } - return this.$select.val(); + + // validate and return value + var val = this.$select.val(); + if (!Utils.validate(val)) { + return null; + } + return val; }, /** Return the first select option @@ -95,12 +105,6 @@ } }, - /** Validate the current selection - */ - validate: function() { - return Utils.validate(this.value()); - }, - /** Return the label/text of the current selection */ text : function () { diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 client/galaxy/scripts/utils/utils.js --- a/client/galaxy/scripts/utils/utils.js +++ b/client/galaxy/scripts/utils/utils.js @@ -35,6 +35,9 @@ if (!(value instanceof Array)) { value = [value]; } + if (value.length === 0) { + return false; + } for (var i in value) { if (['__null__', '__undefined__', 'None', null, undefined].indexOf(value[i]) > -1) { return false; diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/tools/tools-input.js --- a/static/scripts/mvc/tools/tools-input.js +++ b/static/scripts/mvc/tools/tools-input.js @@ -34,9 +34,9 @@ this.field.skip = false; var v = this.field.value && this.field.value(); this.field.skip = Boolean(options.optional && - (((this.field.validate && !this.field.validate()) || !v || - (v == this.default_value) || (Number(v) == Number(this.default_value)) || - (JSON.stringify(v) == JSON.stringify(this.default_value))))); + ((v === null || (v == this.default_value) || + (Number(v) == Number(this.default_value)) || + (JSON.stringify(v) == JSON.stringify(this.default_value))))); // refresh view this._refresh(); diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/tools/tools-select-content.js --- a/static/scripts/mvc/tools/tools-select-content.js +++ b/static/scripts/mvc/tools/tools-select-content.js @@ -233,18 +233,28 @@ console.debug('tools-select-content::value() - Skipped.'); } } else { - this.select_single && this.select_single.value('__null__'); - this.select_multiple && this.select_multiple.value('__null__'); - this.select_collection && this.select_collection.value('__null__'); + this.select_single && this.select_single.value(null); + this.select_multiple && this.select_multiple.value(null); + this.select_collection && this.select_collection.value(null); } this.refresh(); } + // validate value + var id_list = this._select().value(); + if (id_list === null) { + return null; + } + // transform into an array - var id_list = this._select().value(); if (!(id_list instanceof Array)) { id_list = [id_list]; } + + // check if value exists + if (id_list.length === 0) { + return null; + } // prepare result dict var result = { @@ -264,12 +274,6 @@ return result; }, - /** Validate current selection - */ - validate: function() { - return this._select().validate(); - }, - /** Refreshes data selection view */ refresh: function() { this.button_type.value(this.current); diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/tools/tools-tree.js --- a/static/scripts/mvc/tools/tools-tree.js +++ b/static/scripts/mvc/tools/tools-tree.js @@ -118,9 +118,6 @@ if (field && field.value) { // validate field value var value = field.value(); - if (field.validate && !field.validate()) { - value = null; - } // get and patch field value if (patch[input.type]) { @@ -128,7 +125,7 @@ } // ignore certain values - if (input.ignore === undefined || (value !== null && input.ignore != value)) { + if (input.ignore === undefined || input.ignore != value) { // add value to submission add (job_input_id, input.id, value); diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/ui/ui-drilldown.js --- a/static/scripts/mvc/ui/ui-drilldown.js +++ b/static/scripts/mvc/ui/ui-drilldown.js @@ -12,33 +12,44 @@ Options.BaseIcons.prototype.initialize.call(this, options); }, + /** Expand/collapse a sub group + */ + _setState: function (header_id, is_expanded) { + var $button = this.$('#button-' + header_id); + var $subgroup = this.$('#subgroup-' + header_id); + $button.data('is_expanded', is_expanded); + if (is_expanded) { + $subgroup.fadeIn('fast') + $button.removeClass('toggle-expand'); + $button.addClass('toggle'); + } else { + $subgroup.hide(); + $button.removeClass('toggle'); + $button.addClass('toggle-expand'); + } + }, + /** Template to create options tree */ _templateOptions: function(options) { // link this var self = this; - // attach show/hide event - function attachEvents($button, $subgroup) { - function setVisibility (visible) { - if (visible) { - $subgroup.fadeIn('fast') - $button.removeClass('toggle-expand'); - $button.addClass('toggle'); - $button.is_expanded = true; - } else { - $subgroup.hide(); - $button.removeClass('toggle'); - $button.addClass('toggle-expand'); - $button.is_expanded = false; - } - }; + + // link data + this.header_index = {}; + this.header_list = []; + + // attach event handler + function attach($el, header_id) { + var $button = $el.find('#button-' + header_id); $button.on('click', function() { - setVisibility(!$button.is_expanded); + self._setState(header_id, !$button.data('is_expanded')); }); } // recursive function which iterates through options - function iterate ($tmpl, options) { + function iterate ($tmpl, options, header) { + header = header || []; for (i in options) { // current option level in hierarchy var level = options[i]; @@ -46,13 +57,21 @@ // check for options var has_options = level.options.length > 0; + // copy current header list + var new_header = header.slice(0); + // build template var $group = $('<div/>'); if (has_options) { - // create button and add flag - var $button = $('<span class="ui-drilldown-button form-toggle icon-button toggle-expand"/>'); + // create button and subgroup + var header_id = Utils.uuid(); + var $button = $('<span id="button-' + header_id + '" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>'); + var $subgroup = $('<div id="subgroup-' + header_id + '" style="display: none; margin-left: 25px;"/>'); - // add expand group + // keep track of button and subgroup + new_header.push(header_id); + + // create expandable header section var $buttongroup = $('<div/>'); $buttongroup.append($button); $buttongroup.append(self._templateOption({ @@ -60,19 +79,17 @@ value: level.value })); $group.append($buttongroup); - - // add sub group - var $subgroup = $('<div style="display: none; margin-left: 25px;"/>'); - iterate($subgroup, level.options); + iterate($subgroup, level.options, new_header); $group.append($subgroup); - - // attach click event to collapse/expand hierarchy - attachEvents($button, $subgroup); } else { + // append child options $group.append(self._templateOption({ label: level.name, value: level.value })); + + // keep track of header list + self.header_index[level.value] = new_header; } $tmpl.append($group); } @@ -81,6 +98,18 @@ // iterate through options and create dom var $tmpl = $('<div/>'); iterate($tmpl, options); + + // merge index to create a non-duplicate list of headers + for (var i in this.header_index) { + this.header_list = _.uniq(this.header_list.concat(this.header_index[i])); + } + + // attach expand/collapse events + for (var i in this.header_list) { + attach($tmpl, this.header_list[i]); + } + + // return template return $tmpl; }, diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/mvc/ui/ui-options.js --- a/static/scripts/mvc/ui/ui-options.js +++ b/static/scripts/mvc/ui/ui-options.js @@ -101,19 +101,22 @@ /** Return/Set current value */ value: function (new_value) { - // set new value if provided + // set new value if available if (new_value !== undefined) { - // check if its an array - if (!(new_value instanceof Array)) { - new_value = [new_value]; - } - // reset selection this.$('input').prop('checked', false); + + // set value + if (new_value !== null) { + // check if its an array + if (!(new_value instanceof Array)) { + new_value = [new_value]; + } - // update to new selection - for (var i in new_value) { - this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true); + // update to new selection + for (var i in new_value) { + this.$('input[value="' + new_value[i] + '"]').first().prop('checked', true); + } }; } @@ -147,16 +150,10 @@ if (options.length > 0) { return options.val(); } else { - return undefined; + return null; } }, - /** Validate the selected option/options - */ - validate: function() { - return Utils.validate(this.value()); - }, - /** Wait message during request processing */ wait: function() { @@ -213,21 +210,22 @@ /** Return current selection */ _getValue: function() { - // get selected values - var selected = this.$(':checked'); - if (selected.length == 0) { - return '__null__'; + // track values in array + var selected = []; + this.$(':checked').each(function() { + selected.push($(this).val()); + }); + + // get selected elements + if (!Utils.validate(selected)) { + return null; } - + // return multiple or single value if (this.options.multiple) { - var values = []; - selected.each(function() { - values.push($(this).val()); - }); - return values; + return selected; } else { - return selected.val(); + return selected[0]; } }, diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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 @@ -75,13 +75,23 @@ /** Return/Set current selection */ value : function (new_value) { + // set new value if (new_value !== undefined) { + if (new_value === null) { + new_value = '__null__'; + } this.$select.val(new_value); if (this.$select.select2) { this.$select.select2('val', new_value); } } - return this.$select.val(); + + // validate and return value + var val = this.$select.val(); + if (!Utils.validate(val)) { + return null; + } + return val; }, /** Return the first select option @@ -95,12 +105,6 @@ } }, - /** Validate the current selection - */ - validate: function() { - return Utils.validate(this.value()); - }, - /** Return the label/text of the current selection */ text : function () { diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/tools/tools-input.js --- a/static/scripts/packed/mvc/tools/tools-input.js +++ b/static/scripts/packed/mvc/tools/tools-input.js @@ -1,1 +1,1 @@ -define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&(((this.field.validate&&!this.field.validate())||!b||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})}); \ No newline at end of file +define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$title_optional=this.$el.find(".ui-table-form-title-optional");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&((b===null||(b==this.default_value)||(Number(b)==Number(this.default_value))||(JSON.stringify(b)==JSON.stringify(this.default_value)))));this._refresh();var a=this;this.$title_optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){if(!this.field.skip){this.$field.fadeIn("fast");this.$title_optional.html(this.text_disable)}else{this.reset();this.$field.hide();this.$title_optional.html(this.text_enable);this.field.value&&this.field.value(this.default_value)}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title-strong">';if(a.optional){b+=a.label+'<span> [<span class="ui-table-form-title-optional"/>]</span>'}else{b+=a.label}b+='</div><div class="ui-table-form-field">';if(a.help){b+='<div class="ui-table-form-info">'+a.help+"</div>"}b+="</div></div>";return b}})}); \ No newline at end of file diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/tools/tools-select-content.js --- a/static/scripts/packed/mvc/tools/tools-select-content.js +++ b/static/scripts/packed/mvc/tools/tools-select-content.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(g,p){this.app=g;this.options=p;var o=this;this.setElement('<div class="ui-select-content"/>');this.list={};var m=[];if(p.type=="data_collection"){this.mode="collection"}else{if(p.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var k=c.textify(p.extensions);var j="No dataset available.";if(k){j="No "+k+" dataset available."}var l="No dataset list available.";if(k){l="No "+k+" dataset collection available."}if(this.mode=="single"){m.push({icon:"fa-file-o",value:"single",tooltip:"Single dataset"});this.select_single=new e.Select.View({optional:p.optional,error_text:j,onchange:function(){o.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",value:"multiple",tooltip:"Multiple datasets"});this.select_multiple=new e.Select.View({multiple:true,error_text:j,onchange:function(){o.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",value:"collection",tooltip:"Dataset collection"});this.select_collection=new e.Select.View({error_text:l,optional:p.optional,onchange:function(){o.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){o.current=i;o.refresh();o.trigger("change")}});this.$batch=$(a.batchMode());var f=_.size(this.list);var n=0;if(f>1){this.$el.append(this.button_type.$el);n=Math.max(0,_.size(this.list)*35)+"px"}for(var h in this.list){this.$el.append(this.list[h].field.$el.css({"margin-left":n}))}this.$el.append(this.$batch.css({"margin-left":n}));this.update(p.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(p.onchange){p.onchange(o.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(h){if(h!==undefined){if(h&&h.values){try{var l=[];for(var g in h.values){l.push(h.values[g].id)}if(h&&h.values.length>0&&h.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}else{this.select_single&&this.select_single.value("__null__");this.select_multiple&&this.select_multiple.value("__null__");this.select_collection&&this.select_collection.value("__null__")}this.refresh()}var j=this._select().value();if(!(j instanceof Array)){j=[j]}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var g in j){f.values.push({id:j[g],src:this.list[this.current].type})}return f},validate:function(){return this._select().validate()},refresh:function(){this.button_type.value(this.current);for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(g,p){this.app=g;this.options=p;var o=this;this.setElement('<div class="ui-select-content"/>');this.list={};var m=[];if(p.type=="data_collection"){this.mode="collection"}else{if(p.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var k=c.textify(p.extensions);var j="No dataset available.";if(k){j="No "+k+" dataset available."}var l="No dataset list available.";if(k){l="No "+k+" dataset collection available."}if(this.mode=="single"){m.push({icon:"fa-file-o",value:"single",tooltip:"Single dataset"});this.select_single=new e.Select.View({optional:p.optional,error_text:j,onchange:function(){o.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",value:"multiple",tooltip:"Multiple datasets"});this.select_multiple=new e.Select.View({multiple:true,error_text:j,onchange:function(){o.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="collection"){m.push({icon:"fa-folder-o",value:"collection",tooltip:"Dataset collection"});this.select_collection=new e.Select.View({error_text:l,optional:p.optional,onchange:function(){o.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){o.current=i;o.refresh();o.trigger("change")}});this.$batch=$(a.batchMode());var f=_.size(this.list);var n=0;if(f>1){this.$el.append(this.button_type.$el);n=Math.max(0,_.size(this.list)*35)+"px"}for(var h in this.list){this.$el.append(this.list[h].field.$el.css({"margin-left":n}))}this.$el.append(this.$batch.css({"margin-left":n}));this.update(p.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(p.onchange){p.onchange(o.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(g){var l=[];for(var j in g.hda){var k=g.hda[j];l.push({label:k.hid+": "+k.name,value:k.id})}var f=[];for(var j in g.hdca){var h=g.hdca[j];f.push({label:h.hid+": "+h.name,value:h.id})}this.select_single&&this.select_single.update(l);this.select_multiple&&this.select_multiple.update(l);this.select_collection&&this.select_collection.update(f);this.app.content.add(g)},value:function(h){if(h!==undefined){if(h&&h.values){try{var l=[];for(var g in h.values){l.push(h.values[g].id)}if(h&&h.values.length>0&&h.values[0].src=="hcda"){this.current="collection";this.select_collection.value(l[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(l)}else{this.current="single";this.select_single.value(l[0])}}}catch(k){console.debug("tools-select-content::value() - Skipped.")}}else{this.select_single&&this.select_single.value(null);this.select_multiple&&this.select_multiple.value(null);this.select_collection&&this.select_collection.value(null)}this.refresh()}var j=this._select().value();if(j===null){return null}if(!(j instanceof Array)){j=[j]}if(j.length===0){return null}var f={batch:this.mode=="single"&&this.current!="single",values:[]};for(var g in j){f.values.push({id:j[g],src:this.list[this.current].type})}return f},refresh:function(){this.button_type.value(this.current);for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this.mode=="single"&&this.current!="single"){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field}});return{View:d}}); \ No newline at end of file diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(t.validate&&!t.validate()){v=null}if(g[u.type]){v=g[u.type](v)}if(u.ignore===undefined||(v!==null&&u.ignore!=v)){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})}); \ No newline at end of file +define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(g[u.type]){v=g[u.type](v)}if(u.ignore===undefined||u.ignore!=v){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})}); \ No newline at end of file diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/mvc/ui/ui-drilldown.js --- a/static/scripts/packed/mvc/ui/ui-drilldown.js +++ b/static/scripts/packed/mvc/ui/ui-drilldown.js @@ -1,1 +1,1 @@ -define(["utils/utils","mvc/ui/ui-options"],function(b,a){var c=a.BaseIcons.extend({initialize:function(d){d.type=d.display||"checkbox";d.multiple=(d.display=="checkbox");a.BaseIcons.prototype.initialize.call(this,d)},_templateOptions:function(f){var e=this;function g(k,l){function j(m){if(m){l.fadeIn("fast");k.removeClass("toggle-expand");k.addClass("toggle");k.is_expanded=true}else{l.hide();k.removeClass("toggle");k.addClass("toggle-expand");k.is_expanded=false}}k.on("click",function(){j(!k.is_expanded)})}function d(p,k){for(i in k){var q=k[i];var m=q.options.length>0;var l=$("<div/>");if(m){var n=$('<span class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');var j=$("<div/>");j.append(n);j.append(e._templateOption({label:q.name,value:q.value}));l.append(j);var o=$('<div style="display: none; margin-left: 25px;"/>');d(o,q.options);l.append(o);g(n,o)}else{l.append(e._templateOption({label:q.name,value:q.value}))}p.append(l)}}var h=$("<div/>");d(h,f);return h},_template:function(d){return'<div class="ui-options-list drilldown-container" id="'+d.id+'"/>'}});return{View:c}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-options"],function(b,a){var c=a.BaseIcons.extend({initialize:function(d){d.type=d.display||"checkbox";d.multiple=(d.display=="checkbox");a.BaseIcons.prototype.initialize.call(this,d)},_setState:function(d,e){var f=this.$("#button-"+d);var g=this.$("#subgroup-"+d);f.data("is_expanded",e);if(e){g.fadeIn("fast");f.removeClass("toggle-expand");f.addClass("toggle")}else{g.hide();f.removeClass("toggle");f.addClass("toggle-expand")}},_templateOptions:function(g){var f=this;this.header_index={};this.header_list=[];function e(k,i){var l=k.find("#button-"+i);l.on("click",function(){f._setState(i,!l.data("is_expanded"))})}function d(r,t,o){o=o||[];for(h in t){var k=t[h];var l=k.options.length>0;var q=o.slice(0);var s=$("<div/>");if(l){var n=b.uuid();var i=$('<span id="button-'+n+'" class="ui-drilldown-button form-toggle icon-button toggle-expand"/>');var m=$('<div id="subgroup-'+n+'" style="display: none; margin-left: 25px;"/>');q.push(n);var p=$("<div/>");p.append(i);p.append(f._templateOption({label:k.name,value:k.value}));s.append(p);d(m,k.options,q);s.append(m)}else{s.append(f._templateOption({label:k.name,value:k.value}));f.header_index[k.value]=q}r.append(s)}}var j=$("<div/>");d(j,g);for(var h in this.header_index){this.header_list=_.uniq(this.header_list.concat(this.header_index[h]))}for(var h in this.header_list){e(j,this.header_list[h])}return j},_template:function(d){return'<div class="ui-options-list drilldown-container" id="'+d.id+'"/>'}});return{View:c}}); \ No newline at end of file diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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){if(!(j instanceof Array)){j=[j]}this.$("input").prop("checked",false);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 undefined}},validate:function(){return c.validate(this.value())},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 i=this.$(":checked");if(i.length==0){return"__null__"}if(this.options.multiple){var h=[];i.each(function(){h.push($(this).val())});return h}else{return i.val()}},_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");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 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 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){this.$select.val(c);if(this.$select.select2){this.$select.select2("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(){return a.validate(this.value())},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)}}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 diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/packed/utils/utils.js --- a/static/scripts/packed/utils/utils.js +++ b/static/scripts/packed/utils/utils.js @@ -1,1 +1,1 @@ -define(["libs/underscore"],function(l){function m(q,p){for(var n in q){var o=q[n];if(o&&typeof(o)=="object"){p(o);m(o,p)}}}function c(n){return $("<div/>").text(n).html()}function k(o){if(!(o instanceof Array)){o=[o]}for(var n in o){if(["__null__","__undefined__","None",null,undefined].indexOf(o[n])>-1){return false}}return true}function g(n){var n=n.toString();if(n){n=n.replace(/,/g,", ");var o=n.lastIndexOf(", ");if(o!=-1){n=n.substr(0,o)+" or "+n.substr(o+1)}return n}return""}function d(n){top.__utils__get__=top.__utils__get__||{};if(n.cache&&top.__utils__get__[n.url]){n.success&&n.success(top.__utils__get__[n.url]);console.debug("utils.js::get() - Fetching from cache ["+n.url+"].")}else{h({url:n.url,data:n.data,success:function(o){top.__utils__get__[n.url]=o;n.success&&n.success(o)},error:function(o){n.error&&n.error(o)}})}}function h(o){var n={contentType:"application/json",type:o.type||"GET",data:o.data||{},url:o.url};if(n.type=="GET"||n.type=="DELETE"){if(n.url.indexOf("?")==-1){n.url+="?"}else{n.url+="&"}n.url=n.url+$.param(n.data,true);n.data=null}else{n.dataType="json";n.url=n.url;n.data=JSON.stringify(n.data)}$.ajax(n).done(function(p){if(typeof p==="string"){try{p=p.replace("Infinity,",'"Infinity",');p=jQuery.parseJSON(p)}catch(q){console.debug(q)}}o.success&&o.success(p)}).fail(function(q){var p=null;try{p=jQuery.parseJSON(q.responseText)}catch(r){p=q.responseText}o.error&&o.error(p,q)})}function i(q,n){var o=$('<div class="'+q+'"></div>');o.appendTo(":eq(0)");var p=o.css(n);o.remove();return p}function f(n){if(!$('link[href^="'+n+'"]').length){$('<link href="'+galaxy_config.root+n+'" rel="stylesheet">').appendTo("head")}}function j(n,o){if(n){return l.defaults(n,o)}else{return o}}function b(o,q){var p="";if(o>=100000000000){o=o/100000000000;p="TB"}else{if(o>=100000000){o=o/100000000;p="GB"}else{if(o>=100000){o=o/100000;p="MB"}else{if(o>=100){o=o/100;p="KB"}else{if(o>0){o=o*10;p="b"}else{return"<strong>-</strong>"}}}}}var n=(Math.round(o)/10);if(q){return n+" "+p}else{return"<strong>"+n+"</strong> "+p}}function a(){return"x"+Math.random().toString(36).substring(2,9)}function e(){var p=new Date();var n=(p.getHours()<10?"0":"")+p.getHours();var o=(p.getMinutes()<10?"0":"")+p.getMinutes();var q=p.getDate()+"/"+(p.getMonth()+1)+"/"+p.getFullYear()+", "+n+":"+o;return q}return{cssLoadFile:f,cssGetAttribute:i,get:d,merge:j,bytesToString:b,uuid:a,time:e,request:h,sanitize:c,textify:g,validate:k,deepeach:m}}); \ No newline at end of file +define(["libs/underscore"],function(l){function m(q,p){for(var n in q){var o=q[n];if(o&&typeof(o)=="object"){p(o);m(o,p)}}}function c(n){return $("<div/>").text(n).html()}function k(o){if(!(o instanceof Array)){o=[o]}if(o.length===0){return false}for(var n in o){if(["__null__","__undefined__","None",null,undefined].indexOf(o[n])>-1){return false}}return true}function g(n){var n=n.toString();if(n){n=n.replace(/,/g,", ");var o=n.lastIndexOf(", ");if(o!=-1){n=n.substr(0,o)+" or "+n.substr(o+1)}return n}return""}function d(n){top.__utils__get__=top.__utils__get__||{};if(n.cache&&top.__utils__get__[n.url]){n.success&&n.success(top.__utils__get__[n.url]);console.debug("utils.js::get() - Fetching from cache ["+n.url+"].")}else{h({url:n.url,data:n.data,success:function(o){top.__utils__get__[n.url]=o;n.success&&n.success(o)},error:function(o){n.error&&n.error(o)}})}}function h(o){var n={contentType:"application/json",type:o.type||"GET",data:o.data||{},url:o.url};if(n.type=="GET"||n.type=="DELETE"){if(n.url.indexOf("?")==-1){n.url+="?"}else{n.url+="&"}n.url=n.url+$.param(n.data,true);n.data=null}else{n.dataType="json";n.url=n.url;n.data=JSON.stringify(n.data)}$.ajax(n).done(function(p){if(typeof p==="string"){try{p=p.replace("Infinity,",'"Infinity",');p=jQuery.parseJSON(p)}catch(q){console.debug(q)}}o.success&&o.success(p)}).fail(function(q){var p=null;try{p=jQuery.parseJSON(q.responseText)}catch(r){p=q.responseText}o.error&&o.error(p,q)})}function i(q,n){var o=$('<div class="'+q+'"></div>');o.appendTo(":eq(0)");var p=o.css(n);o.remove();return p}function f(n){if(!$('link[href^="'+n+'"]').length){$('<link href="'+galaxy_config.root+n+'" rel="stylesheet">').appendTo("head")}}function j(n,o){if(n){return l.defaults(n,o)}else{return o}}function b(o,q){var p="";if(o>=100000000000){o=o/100000000000;p="TB"}else{if(o>=100000000){o=o/100000000;p="GB"}else{if(o>=100000){o=o/100000;p="MB"}else{if(o>=100){o=o/100;p="KB"}else{if(o>0){o=o*10;p="b"}else{return"<strong>-</strong>"}}}}}var n=(Math.round(o)/10);if(q){return n+" "+p}else{return"<strong>"+n+"</strong> "+p}}function a(){return"x"+Math.random().toString(36).substring(2,9)}function e(){var p=new Date();var n=(p.getHours()<10?"0":"")+p.getHours();var o=(p.getMinutes()<10?"0":"")+p.getMinutes();var q=p.getDate()+"/"+(p.getMonth()+1)+"/"+p.getFullYear()+", "+n+":"+o;return q}return{cssLoadFile:f,cssGetAttribute:i,get:d,merge:j,bytesToString:b,uuid:a,time:e,request:h,sanitize:c,textify:g,validate:k,deepeach:m}}); \ No newline at end of file diff -r 1bb9dcb87c4994b81a7dcdd825dd3ed91c767219 -r 15cd0c4f1a402d96c4d243b38ae71cb1c87978a0 static/scripts/utils/utils.js --- a/static/scripts/utils/utils.js +++ b/static/scripts/utils/utils.js @@ -35,6 +35,9 @@ if (!(value instanceof Array)) { value = [value]; } + if (value.length === 0) { + return false; + } for (var i in value) { if (['__null__', '__undefined__', 'None', null, undefined].indexOf(value[i]) > -1) { return false; 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.