From 8c7898bb5db0d29cd418eac3c6e27191cf3571ed Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 14 Mar 2017 18:18:19 +0000 Subject: Let user choose columns and sort order of issue lists on "My page" (#1565). git-svn-id: http://svn.redmine.org/redmine/trunk@16400 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/query.rb | 16 ++++++++++++++++ app/models/user_preference.rb | 1 + 2 files changed, 17 insertions(+) (limited to 'app/models') diff --git a/app/models/query.rb b/app/models/query.rb index 192502024..23eca0278 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -386,6 +386,22 @@ class Query < ActiveRecord::Base new(attributes).build_from_params(params) end + def as_params + params = {} + filters.each do |field, options| + params[:f] ||= [] + params[:f] << field + params[:op] ||= {} + params[:op][field] = options[:operator] + params[:v] ||= {} + params[:v][field] = options[:values] + end + params[:c] = column_names + params[:sort] = sort_criteria.to_param + params[:set_filter] = 1 + params + end + def validate_query_filters filters.each_key do |field| if values_for(field) diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 41c0f0b4b..0ebafa839 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -128,6 +128,7 @@ class UserPreference < ActiveRecord::Base end def update_block_settings(block, settings) + block = block.to_s block_settings = my_page_settings(block).merge(settings.symbolize_keys) my_page_settings[block] = block_settings end -- cgit v1.2.3