Project

General

Profile

Actions

Patch #44157

open

Add parent issue as a groupable column in issue query

Added by Yasu Saku about 11 hours ago. Updated about 11 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Issues filter
Target version:
-

Description

Problem

The parent issue column (:parent) in IssueQuery is not available as a grouping option. Users who manage issues with parent-child relationships cannot group issue lists by parent issue, which would be useful for tracking work broken down from epics or stories.

Solution

This patch adds grouping support for the parent issue column by introducing a QueryParentIssueColumn subclass, following the same pattern used by TimestampQueryColumn.

Changes

app/models/query.rb

Add a new QueryParentIssueColumn class:

class QueryParentIssueColumn < QueryColumn
  def groupable?
    true
  end

  def group_by_statement
    "#{Issue.table_name}.parent_id" 
  end

  def group_value(object)
    object.parent
  end
end

Extend group_by_sort_order to handle QueryParentIssueColumn, so that grouping sorts by parent_id while leaving the original sortable (used for column header sorting) unchanged:

      column_sortable = column.sortable
      if column.is_a?(TimestampQueryColumn)
        column_sortable = Redmine::Database.timestamp_to_date(column.sortable, User.current.time_zone)
      elsif column.is_a?(QueryParentIssueColumn)
        column_sortable = "#{Issue.table_name}.parent_id" 
      end

app/models/issue_query.rb

Replace QueryColumn.new(:parent, ...) with QueryParentIssueColumn.new(:parent, ...):

    QueryParentIssueColumn.new(:parent,
                    :sortable => ["#{Issue.table_name}.root_id", "#{Issue.table_name}.lft ASC"],
                    :default_order => 'desc', :caption => :field_parent_issue),

Notes

  • Grouping is based on the direct parent only. Multi-level ancestor grouping is not supported.
  • Issues without a parent are grouped under (blank), consistent with other groupable columns.
  • Tested on PostgreSQL with latest trunk ( r24718 ).

Preview


Files

Actions

Also available in: Atom PDF