GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 768f58dd authored by jplang's avatar jplang

Makes author column sortable and groupable on the issue list (#1567).

git-svn-id: https://svn.redmine.org/redmine/trunk@7843 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 18668a72
...@@ -136,7 +136,7 @@ class Query < ActiveRecord::Base ...@@ -136,7 +136,7 @@ class Query < ActiveRecord::Base
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true), QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true), QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"), QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"),
QueryColumn.new(:author), QueryColumn.new(:author, :sortable => ["authors.lastname", "authors.firstname", "authors.id"], :groupable => true),
QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true), QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true),
QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'), QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'),
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true), QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
...@@ -554,10 +554,13 @@ class Query < ActiveRecord::Base ...@@ -554,10 +554,13 @@ class Query < ActiveRecord::Base
def issues(options={}) def issues(options={})
order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',') order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
order_option = nil if order_option.blank? order_option = nil if order_option.blank?
joins = (order_option && order_option.include?('authors')) ? "LEFT OUTER JOIN users authors ON authors.id = #{Issue.table_name}.author_id" : nil
Issue.visible.find :all, :include => ([:status, :project] + (options[:include] || [])).uniq, Issue.visible.find :all, :include => ([:status, :project] + (options[:include] || [])).uniq,
:conditions => Query.merge_conditions(statement, options[:conditions]), :conditions => Query.merge_conditions(statement, options[:conditions]),
:order => order_option, :order => order_option,
:joins => joins,
:limit => options[:limit], :limit => options[:limit],
:offset => options[:offset] :offset => options[:offset]
rescue ::ActiveRecord::StatementInvalid => e rescue ::ActiveRecord::StatementInvalid => e
......
...@@ -397,6 +397,16 @@ class IssuesControllerTest < ActionController::TestCase ...@@ -397,6 +397,16 @@ class IssuesControllerTest < ActionController::TestCase
assert !issues.empty? assert !issues.empty?
assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id) assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id)
end end
def test_index_sort_by_author
get :index, :sort => 'author'
assert_response :success
end
def test_index_group_by_author
get :index, :group_by => 'author', :sort => 'priority'
assert_response :success
end
def test_index_with_columns def test_index_with_columns
columns = ['tracker', 'subject', 'assigned_to'] columns = ['tracker', 'subject', 'assigned_to']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment