Change assignee list to order Groups first.

Added by Stefan W about 1 year ago

Hi all, as the subject states I'm looking to swap the assignee list around so Groups come first and Users come after.

Our environment is a bit older:
Redmine version 3.4.6.stable
Ruby version 2.4.4-p296 (2018-03-28) [i386-mingw32]
Rails version 4.2.8
Environment development
Database adapter mysql2

Looking into it, I'm assuming it has something to do with the following lines from application_helper.rb
Code:

 # Returns a string for users/groups option tags
  def principals_options_for_select(collection, selected=nil)
    s = ''
    if collection.include?(User.current)
      s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
    end
    groups = ''
    collection.sort.each do |element|
      selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected
      (element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
    end
    unless groups.empty?
      s << %(<optgroup label="#{h(l(:label_group_plural))}">#{groups}</optgroup>)
    end
    s.html_safe
  end

Though I could be entirely wrong, I'm not that familiar with Ruby unfortunately.
I've tried modifying the code above but either the groups are missing entirely or the site won't load, meaning the code must be wrong.
If anyone could help me see what I'm missing, it would be appreciated.