1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/519797105a69/ Changeset: 519797105a69 User: guerler Date: 2014-02-03 22:21:12 Summary: Grids: Fix grids with preserved states Affected #: 3 files diff -r 37544732f61c32202d134c263c1257f0920e36a0 -r 519797105a694ac9044e5e6139380a51c5c5fc52 lib/galaxy/web/framework/helpers/grids.py --- a/lib/galaxy/web/framework/helpers/grids.py +++ b/lib/galaxy/web/framework/helpers/grids.py @@ -105,6 +105,7 @@ column_filter = kwargs.get( "f-" + column.key ) elif column.key in base_filter: column_filter = base_filter.get( column.key ) + # Method (1) combines a mix of strings and lists of strings into a single string and (2) attempts to de-jsonify all strings. def from_json_string_recurse(item): decoded_list = [] @@ -131,15 +132,24 @@ if len( column_filter ) == 1: column_filter = column_filter[0] # Interpret ',' as a separator for multiple terms. - if isinstance( column_filter, basestring ) and column_filter.find(',') != -1: + elif isinstance( column_filter, basestring ) and column_filter.find(',') != -1: column_filter = column_filter.split(',') - # If filter criterion is empty, do nothing. - if column_filter == '': - continue + + # Check if filter is empty + if isinstance( column_filter, list ): + # Remove empty strings from filter list + column_filter = [x for x in column_filter if x != ''] + if len(column_filter) == 0: + continue; + elif isinstance(column_filter, basestring): + # If filter criterion is empty, do nothing. + if column_filter == '': + continue + # Update query. query = column.filter( trans, trans.user, query, column_filter ) # Upate current filter dict. - #Column filters are rendered in various places, sanitize them all here. + # Column filters are rendered in various places, sanitize them all here. cur_filter_dict[ column.key ] = sanitize_text(column_filter) # Carry filter along to newly generated urls; make sure filter is a string so # that we can encode to UTF-8 and thus handle user input to filters. @@ -200,10 +210,7 @@ if page_num == 0: # Show all rows in page. total_num_rows = query.count() - # persistent page='all' page_num = 1 - #page_num = 'all' - #extra_url_args['page'] = page_num num_pages = 1 else: # Show a limited number of rows. Before modifying query, get the total number of rows that query diff -r 37544732f61c32202d134c263c1257f0920e36a0 -r 519797105a694ac9044e5e6139380a51c5c5fc52 static/scripts/mvc/grid/grid-model.js --- a/static/scripts/mvc/grid/grid-model.js +++ b/static/scripts/mvc/grid/grid-model.js @@ -37,8 +37,8 @@ if (cur_val === null || cur_val === undefined) { new_val = value; } - else if (typeof(cur_val) == "string") { - if (cur_val == "All") { + else if (typeof(cur_val) == 'string') { + if (cur_val == 'All') { new_val = value; } else { // Replace string with array. @@ -70,29 +70,16 @@ return false; } - var removed = true; - if (typeof(cur_val) === "string") { - if (cur_val == "All") { - // Unexpected. Throw error? - removed = false; - } - else { - // Remove condition. - delete this.attributes.filters[key]; + if (typeof(cur_val) === 'string') { + // overwrite/remove condition. + this.attributes.filters[key] = ''; + } else { + // filter contains an array of conditions. + var condition_index = _.indexOf(cur_val, condition); + if (condition_index !== -1) { + cur_val[condition_index] = ''; } } - else { - // Filter contains an array of conditions. - var condition_index = _.indexOf(cur_val, condition); - if (condition_index !== -1) { - cur_val.splice(condition_index, 1); - } - else { - removed = false; - } - } - - return removed; }, /** diff -r 37544732f61c32202d134c263c1257f0920e36a0 -r 519797105a694ac9044e5e6139380a51c5c5fc52 static/scripts/packed/mvc/grid/grid-model.js --- a/static/scripts/packed/mvc/grid/grid-model.js +++ b/static/scripts/packed/mvc/grid/grid-model.js @@ -1,1 +1,1 @@ -define([],function(){return Backbone.Model.extend({defaults:{url_base:"",async:false,async_ops:[],categorical_filters:[],filters:{},sort_key:null,show_item_checkboxes:false,advanced_search:false,cur_page:1,num_pages:1,operation:undefined,item_ids:undefined},can_async_op:function(a){return _.indexOf(this.attributes.async_ops,a)!==-1},add_filter:function(e,f,b){if(b){var c=this.attributes.filters[e],a;if(c===null||c===undefined){a=f}else{if(typeof(c)=="string"){if(c=="All"){a=f}else{var d=[];d[0]=c;d[1]=f;a=d}}else{a=c;a.push(f)}}this.attributes.filters[e]=a}else{this.attributes.filters[e]=f}},remove_filter:function(b,e){var a=this.attributes.filters[b];if(a===null||a===undefined){return false}var d=true;if(typeof(a)==="string"){if(a=="All"){d=false}else{delete this.attributes.filters[b]}}else{var c=_.indexOf(a,e);if(c!==-1){a.splice(c,1)}else{d=false}}return d},get_url_data:function(){var a={async:this.attributes.async,sort:this.attributes.sort_key,page:this.attributes.cur_page,show_item_checkboxes:this.attributes.show_item_checkboxes,advanced_search:this.attributes.advanced_search};if(this.attributes.operation){a.operation=this.attributes.operation}if(this.attributes.item_ids){a.id=this.attributes.item_ids}var b=this;_.each(_.pairs(b.attributes.filters),function(c){a["f-"+c[0]]=c[1]});return a},get_url:function(a){return this.get("url_base")+"?"+$.param(this.get_url_data())+"&"+$.param(a)}})}); \ No newline at end of file +define([],function(){return Backbone.Model.extend({defaults:{url_base:"",async:false,async_ops:[],categorical_filters:[],filters:{},sort_key:null,show_item_checkboxes:false,advanced_search:false,cur_page:1,num_pages:1,operation:undefined,item_ids:undefined},can_async_op:function(a){return _.indexOf(this.attributes.async_ops,a)!==-1},add_filter:function(e,f,b){if(b){var c=this.attributes.filters[e],a;if(c===null||c===undefined){a=f}else{if(typeof(c)=="string"){if(c=="All"){a=f}else{var d=[];d[0]=c;d[1]=f;a=d}}else{a=c;a.push(f)}}this.attributes.filters[e]=a}else{this.attributes.filters[e]=f}},remove_filter:function(b,d){var a=this.attributes.filters[b];if(a===null||a===undefined){return false}if(typeof(a)==="string"){this.attributes.filters[b]=""}else{var c=_.indexOf(a,d);if(c!==-1){a[c]=""}}},get_url_data:function(){var a={async:this.attributes.async,sort:this.attributes.sort_key,page:this.attributes.cur_page,show_item_checkboxes:this.attributes.show_item_checkboxes,advanced_search:this.attributes.advanced_search};if(this.attributes.operation){a.operation=this.attributes.operation}if(this.attributes.item_ids){a.id=this.attributes.item_ids}var b=this;_.each(_.pairs(b.attributes.filters),function(c){a["f-"+c[0]]=c[1]});return a},get_url:function(a){return this.get("url_base")+"?"+$.param(this.get_url_data())+"&"+$.param(a)}})}); \ 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.