diff --git a/client/galaxy/scripts/mvc/form/form-parameters.js b/client/galaxy/scripts/mvc/form/form-parameters.js index c0446e8f4d0..77be8498e1e 100644 --- a/client/galaxy/scripts/mvc/form/form-parameters.js +++ b/client/galaxy/scripts/mvc/form/form-parameters.js @@ -105,7 +105,6 @@ define(['utils/utils', error_text : input_def.error_text || 'No options available', multiple : input_def.multiple, optional : input_def.optional, - searchable : input_def.searchable, onchange : function() { self.app.trigger( 'change' ); } @@ -126,6 +125,7 @@ define(['utils/utils', id : 'field-' + input_def.id, data : input_def.options, display : input_def.display, + optional : input_def.optional, onchange : function() { self.app.trigger( 'change' ); } diff --git a/client/galaxy/scripts/mvc/form/form-section.js b/client/galaxy/scripts/mvc/form/form-section.js index 88c9653f478..09495f379ad 100644 --- a/client/galaxy/scripts/mvc/form/form-section.js +++ b/client/galaxy/scripts/mvc/form/form-section.js @@ -73,7 +73,7 @@ define(['utils/utils', var field = this._addRow( input_def.test_param ); // set onchange event for test parameter - field.options.onchange = function(value) { + field.model && field.model.set( 'onchange', function( value ) { var selectedCase = self.app.data.matchCase(input_def, value); for (var i in input_def.cases) { var case_def = input_def.cases[i]; @@ -93,7 +93,7 @@ define(['utils/utils', } } self.app.trigger('change'); - }; + }); // add conditional sub sections for (var i in input_def.cases) { diff --git a/client/galaxy/scripts/mvc/ui/ui-drilldown.js b/client/galaxy/scripts/mvc/ui/ui-drilldown.js index c5adaf005bc..71627f2e651 100644 --- a/client/galaxy/scripts/mvc/ui/ui-drilldown.js +++ b/client/galaxy/scripts/mvc/ui/ui-drilldown.js @@ -1,134 +1,91 @@ -// dependencies -define(['utils/utils', 'mvc/ui/ui-options'], function(Utils, Options) { +/** This class creates/wraps a drill down element. */ +define([ 'utils/utils', 'mvc/ui/ui-options' ], function( Utils, Options ) { -/** - * This class creates/wraps a drill down element. - */ var View = Options.BaseIcons.extend({ - // initialize - initialize: function(options) { + initialize: function( options ) { options.type = options.display || 'checkbox'; - options.multiple = (options.display == 'checkbox'); - Options.BaseIcons.prototype.initialize.call(this, options); - this.initial = true; + options.multiple = ( options.type == 'checkbox' ); + Options.BaseIcons.prototype.initialize.call( this, options ); }, - // set expand states for initial value - value: function (new_val) { - var val = Options.BaseIcons.prototype.value.call(this, new_val); - if (this.initial && val !== null && this.header_index) { - this.initial = false; - var values = val; - if (!$.isArray(values)) { - values = [values]; - } - for (var i in values) { - var list = this.header_index[values[i]]; - for (var j in list) { - this._setState(list[j], true); - } - } + /** Set states for selected values */ + _setValue: function ( new_value ) { + Options.BaseIcons.prototype._setValue.call( this, new_value ); + if ( new_value !== undefined && new_value !== null && this.header_index ) { + var self = this; + var values = $.isArray( new_value ) ? new_value : [ new_value ]; + _.each( values, function( v ) { + var list = self.header_index[ v ]; + _.each( list, function( element ) { + self._setState( element, true ); + }); + }); } - return val; }, - /** 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('fa-plus-square'); - $button.addClass('fa-minus-square'); + /** 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.show(); + $button.removeClass( 'fa-plus-square' ).addClass( 'fa-minus-square' ); } else { $subgroup.hide(); - $button.removeClass('fa-minus-square'); - $button.addClass('fa-plus-square'); + $button.removeClass( 'fa-minus-square' ).addClass( 'fa-plus-square' ); } }, - /** Template to create options tree - */ - _templateOptions: function(options) { - // link this + /** Template to create options tree */ + _templateOptions: function() { var self = this; - - // link data this.header_index = {}; - + // attach event handler - function attach($el, header_id) { - var $button = $el.find('.button-' + header_id); - $button.on('click', function() { - self._setState(header_id, !$button.data('is_expanded')); + function attach( $el, header_id ) { + var $button = $el.find( '.button-' + header_id ); + $button.on( 'click', function() { + self._setState( header_id, !$button.data( 'is_expanded' ) ); }); } // recursive function which iterates through options - function iterate ($tmpl, options, header) { + function iterate ( $tmpl, options, header ) { header = header || []; - for (i in options) { - // current option level in hierarchy - var level = options[i]; - - // check for options - var has_options = level.options.length > 0; - - // copy current header list - var new_header = header.slice(0); - - // keep track of header list - self.header_index[level.value] = new_header.slice(0); - - // build template - var $group = $('
'); - if (has_options) { - // create button and subgroup + for ( i in options ) { + var level = options[ i ]; + var has_options = level.options && level.options.length > 0; + var new_header = header.slice( 0 ); + self.header_index[ level.value ] = new_header.slice( 0 ); + var $group = $( '
' ); + if ( has_options ) { var header_id = Utils.uid(); - var $button = $(''); - var $subgroup = $('