Project

General

Profile

Feature #9445 » issue_9445_user_custom_field_global_queries.diff

patch against trunk (as of 2015/12/02) - Jens Krämer, 2015-12-02 05:17

View differences:

app/models/issue_query.rb
235 235
        :values => subprojects.collect{|s| [s.name, s.id.to_s] }
236 236
    end
237 237

  
238
    add_custom_fields_filters(issue_custom_fields)
238
    add_custom_fields_filters(issue_custom_fields, nil, users)
239 239

  
240 240
    add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
241 241

  
app/models/query.rb
924 924
  end
925 925

  
926 926
  # Adds a filter for the given custom field
927
  def add_custom_field_filter(field, assoc=nil)
927
  def add_custom_field_filter(field, assoc=nil, valid_users=nil)
928 928
    options = field.query_filter_options(self)
929 929
    if field.format.target_class && field.format.target_class <= User
930 930
      if options[:values].is_a?(Array) && User.current.logged?
931 931
        options[:values].unshift ["<< #{l(:label_me)} >>", "me"]
932 932
      end
933
      if options[:values].is_a?(Array) && project.nil? && !valid_users.nil?
934
        options[:values] += valid_users.collect {|u| [u.name, u.id.to_s]}
935
      end
933 936
    end
934 937

  
935 938
    filter_id = "cf_#{field.id}"
......
945 948
  end
946 949

  
947 950
  # Adds filters for the given custom fields scope
948
  def add_custom_fields_filters(scope, assoc=nil)
951
  def add_custom_fields_filters(scope, assoc=nil, valid_users=nil)
949 952
    scope.visible.where(:is_filter => true).sorted.each do |field|
950
      add_custom_field_filter(field, assoc)
953
      add_custom_field_filter(field, assoc, valid_users)
951 954
    end
952 955
  end
953 956

  
(3-3/3)