@@ -64,7 +64,7 class IssuesController < ApplicationController | |||
|
64 | 64 | @issue_count = Issue.count(:include => [:status, :project], :conditions => @query.statement) |
|
65 | 65 | @issue_pages = Paginator.new self, @issue_count, limit, params['page'] |
|
66 | 66 | @issues = Issue.find :all, :order => [@query.group_by_sort_order, sort_clause].compact.join(','), |
|
67 | :include => ([:status, :project, :priority] + @query.include_options), | |
|
67 | :include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ], | |
|
68 | 68 | :conditions => @query.statement, |
|
69 | 69 | :limit => limit, |
|
70 | 70 | :offset => @issue_pages.current.offset |
@@ -16,7 +16,7 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class QueryColumn |
|
19 |
attr_accessor :name, :sortable, :groupable, :default_order |
|
|
19 | attr_accessor :name, :sortable, :groupable, :default_order | |
|
20 | 20 | include Redmine::I18n |
|
21 | 21 | |
|
22 | 22 | def initialize(name, options={}) |
@@ -27,7 +27,6 class QueryColumn | |||
|
27 | 27 | self.groupable = name.to_s |
|
28 | 28 | end |
|
29 | 29 | self.default_order = options[:default_order] |
|
30 | self.include_options = options[:include] | |
|
31 | 30 | end |
|
32 | 31 | |
|
33 | 32 | def caption |
@@ -49,7 +48,6 class QueryCustomFieldColumn < QueryColumn | |||
|
49 | 48 | self.groupable = custom_field.order_statement |
|
50 | 49 | end |
|
51 | 50 | self.groupable ||= false |
|
52 | self.include_options = :custom_values | |
|
53 | 51 | @cf = custom_field |
|
54 | 52 | end |
|
55 | 53 | |
@@ -109,15 +107,15 class Query < ActiveRecord::Base | |||
|
109 | 107 | |
|
110 | 108 | @@available_columns = [ |
|
111 | 109 | QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true), |
|
112 |
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true |
|
|
110 | QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true), | |
|
113 | 111 | QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true), |
|
114 | 112 | QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true), |
|
115 | 113 | QueryColumn.new(:subject, :sortable => "#{Issue.table_name}.subject"), |
|
116 | 114 | QueryColumn.new(:author), |
|
117 |
QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true |
|
|
115 | QueryColumn.new(:assigned_to, :sortable => ["#{User.table_name}.lastname", "#{User.table_name}.firstname", "#{User.table_name}.id"], :groupable => true), | |
|
118 | 116 | QueryColumn.new(:updated_on, :sortable => "#{Issue.table_name}.updated_on", :default_order => 'desc'), |
|
119 |
QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true |
|
|
120 |
QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true |
|
|
117 | QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true), | |
|
118 | QueryColumn.new(:fixed_version, :sortable => ["#{Version.table_name}.effective_date", "#{Version.table_name}.name"], :default_order => 'desc', :groupable => true), | |
|
121 | 119 | QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date"), |
|
122 | 120 | QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date"), |
|
123 | 121 | QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours"), |
@@ -324,10 +322,6 class Query < ActiveRecord::Base | |||
|
324 | 322 | def group_by_statement |
|
325 | 323 | group_by_column.groupable |
|
326 | 324 | end |
|
327 | ||
|
328 | def include_options | |
|
329 | (columns << group_by_column).collect {|column| column && column.include_options}.flatten.compact.uniq | |
|
330 | end | |
|
331 | 325 | |
|
332 | 326 | def project_statement |
|
333 | 327 | project_clauses = [] |
@@ -202,15 +202,6 class QueryTest < ActiveSupport::TestCase | |||
|
202 | 202 | assert q.groupable_columns.detect {|c| c.is_a? QueryCustomFieldColumn} |
|
203 | 203 | end |
|
204 | 204 | |
|
205 | def test_include_options | |
|
206 | q = Query.new | |
|
207 | q.column_names = %w(subject tracker) | |
|
208 | assert_equal [:tracker], q.include_options | |
|
209 | ||
|
210 | q.group_by = 'category' | |
|
211 | assert_equal [:tracker, :category], q.include_options | |
|
212 | end | |
|
213 | ||
|
214 | 205 | def test_default_sort |
|
215 | 206 | q = Query.new |
|
216 | 207 | assert_equal [], q.sort_criteria |
General Comments 0
You need to be logged in to leave comments.
Login now