Feature #5325 » 0001-groupable-by-parent-task.patch
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
!issue.is_descendant_of?(ancestors.last)
|
||
|
ancestors.pop
|
||
|
end
|
||
|
yield issue, ancestors.size, group_name, group_count, group_totals
|
||
|
level = (query.grouped? && query.group_by_column.name == :parent) ? 0 : ancestors.size
|
||
|
yield issue, level, group_name, group_count, group_totals
|
||
|
ancestors << issue unless issue.leaf?
|
||
|
end
|
||
|
end
|
||
| app/models/issue_query.rb | ||
|---|---|---|
|
QueryColumn.new(:tracker, :sortable => "#{Tracker.table_name}.position", :groupable => true),
|
||
|
QueryColumn.new(:parent,
|
||
|
:sortable => ["#{Issue.table_name}.root_id", "#{Issue.table_name}.lft ASC"],
|
||
|
:groupable => "#{Issue.table_name}.parent_id",
|
||
|
:default_order => 'desc', :caption => :field_parent_issue),
|
||
|
QueryAssociationColumn.new(:parent, :subject, :caption => :field_parent_issue_subject),
|
||
|
QueryColumn.new(:status, :sortable => "#{IssueStatus.table_name}.position", :groupable => true),
|
||
| app/models/query.rb | ||
|---|---|---|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
class QueryColumn
|
||
|
attr_accessor :name, :totalable, :default_order
|
||
|
attr_writer :sortable, :groupable
|
||
|
attr_accessor :name, :totalable, :default_order, :groupable
|
||
|
attr_writer :sortable
|
||
|
include Redmine::I18n
|
||
| ... | ... | |
|
if column.is_a?(TimestampQueryColumn)
|
||
|
column_sortable = Redmine::Database.timestamp_to_date(column.sortable, User.current.time_zone)
|
||
|
end
|
||
|
if column.name == :parent
|
||
|
column_sortable = Array(column.groupable)
|
||
|
end
|
||
|
Array(column_sortable).map {|s| Arel.sql("#{s} #{order}")}
|
||
|
end
|
||
|
end
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
assert_nil q.group_by_statement
|
||
|
end
|
||
|
def test_grouped_with_parent_task_should_sort_by_parent_id
|
||
|
Issue.delete_all
|
||
|
first, second, third = Issue.generate!, Issue.generate!, Issue.generate!
|
||
|
Issue.generate!(:parent_id => second.id)
|
||
|
Issue.generate!(:parent_id => third.id)
|
||
|
Issue.generate!(:parent_id => first.id)
|
||
|
q = IssueQuery.new(:group_by => 'parent')
|
||
|
assert_equal :parent, q.group_by_column.name
|
||
|
assert_equal ["#{Issue.table_name}.parent_id DESC"], q.group_by_sort_order
|
||
|
assert_equal [third.id, second.id, first.id, nil, nil, nil], q.issues.pluck(:parent_id)
|
||
|
end
|
||
|
def test_sortable_columns_should_sort_assignees_according_to_user_format_setting
|
||
|
with_settings :user_format => 'lastname_comma_firstname' do
|
||
|
q = IssueQuery.new
|
||
- « Previous
- 1
- 2
- 3
- 4
- Next »