Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'Descendant of' filter for issues to show all descendants #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ en:

label_all_relations: "All related to"

label_descendant_of: "Descendant of"

field_root: "Root"
11 changes: 11 additions & 0 deletions lib/redmine_more_filters/patches/issue_query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ def initialize_available_filters_with_more_filters
:type => :integer,
:label => :label_all_relations


add_available_filter("descendant_of",
:type => :integer,
:label => :label_descendant_of
)

add_available_filter("created_on_by_clock_time",
:type => :time_past
)
Expand Down Expand Up @@ -210,6 +216,11 @@ def sql_for_all_relations_field(field, operator, value, options={})
end
"(#{sql})"
end

def sql_for_descendant_of_field(field, operator, value)
sql = "#{Issue.table_name}.id IN ( SELECT DISTINCT i.id FROM #{Issue.table_name} i INNER JOIN #{Issue.table_name} j ON i.root_id = j.root_id AND i.lft > j.lft AND i.rgt < j.rgt WHERE #{sql_for_field("id", "=", value, "j", "id")} )"
"(#{sql})"
end

end #module
end #module
Expand Down
2 changes: 1 addition & 1 deletion lib/redmine_more_filters/patches/queries_helper_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def filters_options_for_select_with_more_filters(query)
group = :label_relations
elsif field_options[:type] == :tree
group = query.is_a?(IssueQuery) ? :label_relations : nil
elsif field =~ /root_id|all_relations/
elsif field =~ /root_id|all_relations|descendant_of/
group = :label_relations
elsif field =~ /^cf_\d+\./
group = (field_options[:through] || field_options[:field]).try(:name)
Expand Down