Project

General

Profile

Actions

Patch #16730

open

Fix ordering in ApplicationHelper method principals_options_for_select

Added by Joseph Wang over 10 years ago. Updated over 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Issues
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

We experienced problems on assigning issues recently.
We have a lot of members for some projects (about 30+ people each project).
User's name (first name & last name) are in non-English.
The problem is seems Redmine does not sort users in Assignee drop down while editing a issue, so it is very hard to find a user.
We are wondering if Redmine could provide a search box like adding watchers do.

Actions #1

Updated by Jan Niggemann (redmine.org team member) over 10 years ago

I think that ApplicationHelpers' method principals_options_for_select does sort, perhaps it's not properly working for foreign locales?
source:trunk/app/helpers/application_helper.rb#L375

Actions #2

Updated by Joseph Wang over 10 years ago

Jan Niggemann (redmine.org team member) wrote:

I think that ApplicationHelpers' method principals_options_for_select does sort, perhaps it's not properly working for foreign locales?
source:trunk/app/helpers/application_helper.rb#L375

My locale is zh. User names are in Chinese.

Actions #3

Updated by Joseph Wang over 10 years ago

Jan Niggemann (redmine.org team member) wrote:

I think that ApplicationHelpers' method principals_options_for_select does sort, perhaps it's not properly working for foreign locales?
source:trunk/app/helpers/application_helper.rb#L375

I totally don't have experience on Ruby, but seems this line is a problem:

collection.sort.each do |element|

collection contains User objects? Doesn't the sort method sort elements by address? or something else?

I googled "Ruby sort collection" and got this:
http://stackoverflow.com/questions/882070/sorting-an-array-of-objects-in-ruby-by-object-attribute

Then I changed the line to following:

collection.sort_by{|user|user.lastname}.each do |element|

Then glad to see it works. Redmine sorted Assignees by last name even in Chinese.

Hope that won't bring side effect.

Actions #4

Updated by Jan Niggemann (redmine.org team member) over 10 years ago

  • Subject changed from Needs easy way to pick assignee to Fix ordering in ApplicationHelper method principals_options_for_select
  • Category set to Issues
Actions #5

Updated by Jan Niggemann (redmine.org team member) over 10 years ago

  • Tracker changed from Feature to Patch
Actions #6

Updated by Toshi MARUYAMA over 10 years ago

"User" has order attribute.
source:tags/2.5.1/app/models/user.rb#L24

Actions #7

Updated by Mr. Míng over 2 years ago

+1. This problem is very unbearable.

Currently, I must configure to displaying login as user name - which is hard to read. But, sorting by user `login` is what we need - at least for Chinese.

Actions

Also available in: Atom PDF