diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-21 18:01:11 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-21 18:01:11 +0000 |
commit | 828e8111cc772111bc156924a985e01221f9e76a (patch) | |
tree | 1daa93e7f3e74ff9e92245636917d815c3bf36ec /app | |
parent | 6e7e2ef59b594e3d76305ddb986ce17d63ac1a66 (diff) | |
download | redmine-828e8111cc772111bc156924a985e01221f9e76a.tar.gz redmine-828e8111cc772111bc156924a985e01221f9e76a.zip |
Add users to assignee/author filters if they are missing (#3398).
git-svn-id: http://svn.redmine.org/redmine/trunk@14722 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue_query.rb | 5 | ||||
-rw-r--r-- | app/models/query.rb | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index e208b64ad..b167c5d9f 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -544,6 +544,11 @@ class IssueQuery < Query "(#{sql})" end + def find_assigned_to_id_filter_values(values) + Principal.visible.where(:id => values).map {|p| [p.name, p.id.to_s]} + end + alias :find_author_id_filter_values :find_assigned_to_id_filter_values + IssueRelation::TYPES.keys.each do |relation_type| alias_method "sql_for_#{relation_type}_field".to_sym, :sql_for_relations end diff --git a/app/models/query.rb b/app/models/query.rb index fbcf2e646..ed59c5526 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -311,7 +311,14 @@ class Query < ActiveRecord::Base def available_filters_as_json json = {} available_filters.each do |field, options| - json[field] = options.slice(:type, :name, :values).stringify_keys + options = options.slice(:type, :name, :values) + if options[:values] && values_for(field) + missing = Array(values_for(field)).select(&:present?) - options[:values].map(&:last) + if missing.any? && respond_to?(method = "find_#{field}_filter_values") + options[:values] += send(method, missing) + end + end + json[field] = options.stringify_keys end json end |