Feature #6836
closedSort project list by Name instead of identifier
Added by Roger Mårtensson about 14 years ago. Updated over 9 years ago.
0%
Description
When listing subproject in a parent projects Overview and on the Projects page these sub-projects are sorted using the identifier. This is more noticable when changing name of a project.
Either it should be sorted by name, be able to choose on what keyword to sort or be able to change the identifier.
This is with version 1.0.2 of redmine.
Related issues
Updated by Joe Goloso almost 14 years ago
+1
Sorting projects by name would be a great feature. Especially when you have more than 70 projects to manage (our case).
Thank you four your work!
Updated by Remo Laubacher almost 14 years ago
+1
this is rather annoying, also found another issue #3722 which might be related to this.
Updated by Bernhard Sessler almost 14 years ago
+1
This is really one of the most annoying things in Redmine and one of the most wanted Redmine features in our company.
Updated by Andrey Turkin over 13 years ago
When listing subproject in a parent projects Overview and on the Projects page these sub-projects are sorted using the
identifier.
As of Redmine 1.1.1 projects are sorted by name and not identifier - so this feature is implemented already.
This is more noticable when changing name of a project.
This is where it gets funny; changing name of a project does not reorder its with its siblings - which can lead to incorrect ordering (not harmful but annoying). Moreover once ordering became incorrect new sibling projects may be ordered wrong too.
Project.update_all(:lft=>nil,:rgt=>nil); Project.rebuild!
workaround helps of course but still I suppose it is a bug caused by implementing this feature (after all you cannot change project identifier so it wasn't an issue)
Updated by alvis lee over 13 years ago
+1
i hope it support a single key(number) to sort projects.
i want list projects customize.
thanks!
Updated by Anonymous over 12 years ago
+1
Sorting by id (number) or reordering the nested sets
Updated by Ken Zalewski about 12 years ago
We are using Redmine at the New York State Senate as our primary project management and issue tracking tool. Like many people here, we find the sorting of parent projects by ID to be unwieldy when dealing with dozens of projects. We prefer to sort our projects by name.
My quick and dirty workaround is as follows (assumes Redmine 2.1.2):
Edit the file:<ROOT>/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb
Change line 189 so that "id" is replaced with "name". This line contains the WHERE and ORDER BY clauses for the root project nodes. By changing "id" to "name", you are reordering projects by name instead of ID.
The new line should look like this:root_nodes = where("#{quoted_parent_column_name} IS NULL").order("#{quoted_left_column_name}, #{quoted_right_column_name}, name").each do |root_node|
Rebuild the project nested set (aka the "lefts-and-rights", which are represented by the "lft" and "rgt" fields) by executing the following from the command line:
ruby script/rails runner 'Project.update_all(:lft=>nil,:rgt=>nil); Project.rebuild!'
That's it. Reloading the Projects page now displays all of our projects sorted alphabetically by root project name, with all subprojects sorted alphabetically per root project.
It would certainly be a bit easier if Redmine offered a configurable "sort by" option for Project nodes. Consider the NY Senate a +1 for this feature.
Updated by Ken Zalewski about 12 years ago
- Assignee set to Jean-Philippe Lang
Assigning to Jean-Philippe for review and comment.
This issue has been open for 2 years with no response.
Updated by Florian Reimair about 12 years ago
we have only a very limited number of projects. we love to create some sort of "archive"-root-project where closed projects are moved to and move the archive-project to the end of the list. simplest solution is to name it "zArchive". But in our case there is absolutely no sorting method identifiable. Neither the creation date, nor the project id (since the archive was the last project created and it resides somewhere in the middle of the list), nor name, nor identifier. Just not fun working with.
since years there is this request from a broad range of users and nothing has been done. is it really that hard to do?
add a dropdown field to the view and make the index-action sort in respect to the selection.
changes are necessary here [code]app/controllers/projects_controller.rb:55/60[/code] and in the correspondig view.
When you are short on resources I will do that for you. Just promise me that you will accept the pull request as I do not want to waste my resources.
Updated by Ken Zalewski about 12 years ago
Florian,
See my comment above (http://www.redmine.org/issues/6836#note-12).
I explained exactly how you can sort projects alphabetically.
We also created an "Archive" project. We named it "~Archive", since the tilde is further down in the ASCII character sequence than all alphabetic characters, which assures that it will be the last project in the list.
We then attach old projects as sub-projects of the ~Archive project.
Updated by Jean-Philippe Lang about 12 years ago
This was fixed in 2.1.0 (#11508). Ordering the project tree cannot be done using a simple ORDER BY projects.name
statement and would require some computation that is not required if lft and rgt values are properly set in the database. There may be some inconsistencies introduced in these values before 2.1 but they should be properly handled now (so that projects are sorted by name when sorting by lft value).
You can clean up your projects table by running the 2 following commands from the rails console (`ruby script/rails c production`
):
Project.update_all :lft => nil, :rgt => nil Project.rebuild!(false)
And after that, if you're using Redmine 2.1, projects will still be ordered by their names even if you rename them.
Updated by Ken Zalewski about 12 years ago
Jean-Philippe,
I don't think your solution will keep projects ordered alphabetically as new projects are added. My fix outlined above in http://www.redmine.org/issues/6836#note-12 modifies the actual the left/right rebuilder, which will keep projects sorted by name all the time, even as names change and projects are added/deleted.
I could be misunderstanding something, but it has worked for our organization so far.
Updated by Jean-Philippe Lang about 12 years ago
Ken Zalewski wrote:
I don't think your solution will keep projects ordered alphabetically as new projects are added.
Yes, it will keep them ordered. New projects are inserted in the proper lft/rgt position according to their names. And these values are also updated when a project is renamed. You can have a look at the tests that were added in 2.1: source:/tags/2.1.0/test/unit/project_nested_set_test.rb. On each test, we make sure that projects stay ordered alphabetically.
Edit: your change described in note-12 is now obsolete, have a look at source:/tags/2.1.0/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb#L182.
Updated by Florian Reimair about 12 years ago
man I did not expect such a prompt response on that one and sorry for the harsh tone in my previous post. redmine is great thats for sure.
now, what about sorting after other criteria such as creation date? what about filtering the project list? I think (among others) that the project list is a central tool in redmine and it needs a face lift. Sorting and filtering is common functionality on lists nowadays. So why not in redmine? Sorting and filtering may be adressed by a rather compact piece of code maybe - which is all about processing the project list. So why go for the alphabetical order only if one can get more functionality at same or slightly more cost?
I by the way forwarded the two lines mentioned above to our admin. Still pending.
I will or course help where I can.
Updated by Ken Zalewski about 12 years ago
Hi Jean-Philippe,
I cannot confirm that this is working.
I just upgraded from Redmine 2.1.2 to 2.1.3. I did not apply my patch to line 189 in awesome_nested_set.rb (as I described in http://www.redmine.org/issues/6836#note-12), since I wanted to see if it would just work "out of the box".
I cleared out my lefts and rights (Project.update_all :lft=>nil,:rgt=>nil), then rebuilt (Project.rebuild!(false)).
The root projects were then incorrectly ordered by ID, instead of alphabetically by name. This makes sense, because line 189 is ordering by ID, not by name.
When I applied my fix (changed "id" to "name" in line 189), then called Project.update_all and Project.rebuild, the root projects were properly ordered alphabetically.
I don't understand why you continue to claim that this is fixed, when the latest release of Redmine still orders projects by ID, not by name.
Maybe I am misunderstanding something.
Updated by Jean-Philippe Lang about 12 years ago
- Status changed from New to Closed
- Resolution set to Fixed
Ken Zalewski wrote:
When I applied my fix (changed "id" to "name" in line 189), then called Project.update_all and Project.rebuild, the root projects were properly ordered alphabetically.
A real patch would be usefull to see what you actually change. But clearly, you're using an obsolete version of awesome_nested_set.rb. In 2.1.x, there's no ORDER BY id
on line 189. The order is now specified with the :order option in the Project model.
Have a look at: source:/tags/2.1.3/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb#L182 and please use a fresh Redmine code base.
Updated by Ken Zalewski about 12 years ago
- Status changed from Closed to Reopened
I clearly stated in my first comment, as well as my last comment, what version of Redmine that I'm using.
In comment 12, I stated Redmine 2.1.2. In comment 20, I stated that I upgraded to 2.1.3.
In comment 12, I even included the exact line of code for line 189. It matches the line that you are referencing as well, other than I changed "id" to "name". That's it.
I am without question using the most recent version of the code base.
I would prefer to keep this open until this is actually resolved.
Updated by Ken Zalewski about 12 years ago
Jean-Philippe,
I think you are looking at line 182.
Line 189 is the line that sorts the root projects. The order() method is the ORDER BY, and there is clearly an "id" in the ORDER BY fields.
Changing "id" to "name" fixes this. I confirmed this again.
Updated by Jean-Philippe Lang about 12 years ago
- Status changed from Reopened to Closed
You're absolutely right, Project.rebuild!
was actually sorting root projects by id.
Now fixed for 2.1.4, see #12431. Thanks.
Updated by Jean-Philippe Lang about 12 years ago
BTW, I've added a handier method to rebuild the tree: Project.rebuild_tree!
. It clears and recalculates all lft, rgt values.
Updated by Ken Zalewski about 12 years ago
OK, fantastic! I'm glad to know that I'm not crazy. :-)
Thank you for listening.
Updated by Ken Zalewski almost 12 years ago
Updated by Igor Rybak almost 11 years ago
Due to a comment of Jean-Philippe projects are now sorted alphabetically!
Thank you very much!!!
Updated by Kevin Wojniak over 9 years ago
I recently updated a 1.x Redmine install to 2.6.1 stable and noticed projects aren't sorted by name.
I ran Project.rebuild_tree!
from within ruby script/rails c production
but now they are sorted differently and not by name. Every time I run that command the sort order changes.