]> source.dussan.org Git - redmine.git/commitdiff
Don't preload custom field filter values (#24787).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 12 Jan 2017 20:19:45 +0000 (20:19 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 12 Jan 2017 20:19:45 +0000 (20:19 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16173 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/query.rb
lib/redmine/field_format.rb
test/unit/lib/redmine/field_format/version_field_format_test.rb

index 1e2263d77a824250ab0389e9eada762107f9828a..fea958631157b4570eb64ed2f7547f95f082144c 100644 (file)
@@ -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
index 4e31b1330f73ffeb23be2c665ccd05710dd57583..dd467db8c51c50f87c231559ca612b3b8cb55e9c 100644 (file)
@@ -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
index 0b3006c65d968f7f201e9ff8f8a735426117a654..e6e9d1d00008587fef4504d4b78ba85fef555aa8 100644 (file)
@@ -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