Project

General

Profile

Feature #9445 » 0001-Add-Issue-custom-fields-of-User-format-to-the-cross-.patch

Patch for 2.6-stable branch - Anders Thomsen, 2015-08-07 16:47

View differences:

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

  
236
    add_custom_fields_filters(issue_custom_fields)
236
    add_custom_fields_filters(issue_custom_fields, nil, users)
237 237

  
238 238
    add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version
239 239

  
app/models/query.rb
780 780
  end
781 781

  
782 782
  # Adds a filter for the given custom field
783
  def add_custom_field_filter(field, assoc=nil)
783
  def add_custom_field_filter(field, assoc=nil, valid_users=nil)
784 784
    options = field.format.query_filter_options(field, self)
785 785
    if field.format.target_class && field.format.target_class <= User
786 786
      if options[:values].is_a?(Array) && User.current.logged?
787 787
        options[:values].unshift ["<< #{l(:label_me)} >>", "me"]
788 788
      end
789
      if options[:values].is_a?(Array) && project.nil? && !valid_users.nil?
790
        options[:values] += valid_users.collect {|u| [u.name, u.id.to_s]}
791
      end
789 792
    end
790 793

  
791 794
    filter_id = "cf_#{field.id}"
......
801 804
  end
802 805

  
803 806
  # Adds filters for the given custom fields scope
804
  def add_custom_fields_filters(scope, assoc=nil)
807
  def add_custom_fields_filters(scope, assoc=nil, valid_users=nil)
805 808
    scope.visible.where(:is_filter => true).sorted.each do |field|
806
      add_custom_field_filter(field, assoc)
809
      add_custom_field_filter(field, assoc, valid_users)
807 810
    end
808 811
  end
809 812

  
(2-2/3)