Commit 69e7724c authored by jplang's avatar jplang

Don't preload custom field filter values (#24787).

git-svn-id: https://svn.redmine.org/redmine/trunk@16173 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 51ce7161
......@@ -1111,11 +1111,6 @@ class Query < ActiveRecord::Base
# Adds a filter for the given custom field
def add_custom_field_filter(field, assoc=nil)
options = field.query_filter_options(self)
if field.format.target_class && field.format.target_class <= User
if options[:values].is_a?(Array) && User.current.logged?
options[:values].unshift ["<< #{l(:label_me)} >>", "me"]
end
end
filter_id = "cf_#{field.id}"
filter_name = field.name
......
......@@ -552,7 +552,7 @@ module Redmine
end
def query_filter_options(custom_field, query)
{:type => :list_optional, :values => query_filter_values(custom_field, query)}
{:type => :list_optional, :values => lambda { query_filter_values(custom_field, query) }}
end
protected
......@@ -810,6 +810,10 @@ module Redmine
custom_field.user_role.map!(&:to_s).reject!(&:blank?)
end
end
def query_filter_values(*args)
[["<< #{l(:label_me)} >>", "me"]] + super
end
end
class VersionFormat < RecordList
......
......@@ -83,6 +83,6 @@ class Redmine::VersionFieldFormatTest < ActionView::TestCase
query = Query.new(:project => project)
assert_not_include version.name, field.possible_values_options(project).map(&:first)
assert_include version.name, field.query_filter_options(query)[:values].map(&:first)
assert_include version.name, field.query_filter_options(query)[:values].call.map(&:first)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment