Project

General

Profile

Actions

Feature #23641

open

Increase the number of sort columns in custom queries

Added by Anton Kalinin over 7 years ago. Updated over 7 years ago.

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

0%

Estimated time:
Resolution:

Description

It would be great to be able to set more than 3 sort columns in custom queries. Maybe, 10 might be enough?

Here is a scenario to sort issues I'm going to use in my organization, it lacks the amount of sort columns:

  1. Group issues by the priority field;
  2. Sort by the Parent task field to visualize the issue hierarchy;
  3. Sort by the Status field descending. The nearer an issue is to be done, the higher it should be in the list. It can help not to keep a lot of incomplete issues.
  4. Sort by the % Done field descending due to the consideration above.
  5. Sort by the # field ascending to order them in the creation order.
Actions #1

Updated by Toshi MARUYAMA over 7 years ago

  • Description updated (diff)
Actions #2

Updated by Andrey Lobanov (RedSoft) over 7 years ago

Anton Kalinin wrote:

It would be great to be able to set more than 3 sort columns in custom queries. Maybe, 10 might be enough?

Here is a scenario to sort issues I'm going to use in my organization, it lacks the amount of sort columns:

  1. Group issues by the priority field;
  2. Sort by the Parent task field to visualize the issue hierarchy;
  3. Sort by the Status field descending. The nearer an issue is to be done, the higher it should be in the list. It can help not to keep a lot of incomplete issues.
  4. Sort by the % Done field descending due to the consideration above.
  5. Sort by the # field ascending to order them in the creation order.

You can change it easily in your redmine copy.

In your app/models/query.rb (changed : .slice(0, 3) to .slice(0, arg.length))

  def sort_criteria=(arg)
    c = []
    if arg.is_a?(Hash)
      arg = arg.keys.sort.collect { |k| arg[k] }
    end
    if arg
      c = arg.select { |k, o| !k.to_s.blank? }.slice(0, arg.length).collect { |k, o| [k.to_s, (o == 'desc' || o == false) ? 'desc' : 'asc'] }
    end
    write_attribute(:sort_criteria, c)
  end

And in app/views/queries/_form.html.erb:
change 3 to any number

<fieldset><legend><%= l(:label_sort) %></legend>
<% 3.times do |i| %>

Actions

Also available in: Atom PDF