Skip to content

Commit

Permalink
* Filter on root_tracker
Browse files Browse the repository at this point in the history
* Filter on `root_status`
  • Loading branch information
Jan Catrysse committed Aug 7, 2023
1 parent 9b931a8 commit fd00b7d
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 53 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CHANGELOG
### 0.0.3
* Filter on `root_issue`
* Filter on `root`
* Filter on `root_tracker`
* Filter on `root_status`
* Operator `not equal to` on `start_date` and `end_date`
* Resolved issue: `SystemStackError (stack level too deep)`
Converted `initialize_available_filters` to use `alias_method`
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Link to Redmine plugin page: https://www.redmine.org/plugins/redmine_parent_chil
* Version 0.0.1 >= Redmine 4 (including Redmine 5)

## Features
* Filter on `root_issue`
* Filter on `root`
* Filter on `root_tracker`
* Filter on `root_status`
* Filter on `parent_tracker`
* Filter on `parent_status`
* Filter on `child_tracker`
Expand Down
15 changes: 9 additions & 6 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
de:
label_group_parent_child: Eltern und Kind
child_status_id: Status des Kindes
child_tracker_id: Tracker des Kindes
child_tracker_status_id: Tracker un Status des Kindes
parent_status_id: Status des Elternteils
parent_tracker_id: Tracker des Elternteils
label_filter_group_parent_child: Eltern und Kind
label_filter_child_status_id: Status des Kindes
label_filter_child_tracker_id: Verfolgung des Kindes
label_filter_child_tracker_status_id: Verfolgung und Status des Kindes
label_filter_parent_status_id: Status der Eltern
label_filter_parent_tracker_id: Verfolgung der Eltern
label_filter_root: Hauptticket
label_filter_root_status_id: Status des Haupttickets
label_filter_root_tracker_id: Verfolgung des Haupttickets
15 changes: 9 additions & 6 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
en:
label_group_parent_child: Parent and child
child_status_id: Child status
child_tracker_id: Child tracker
child_tracker_status_id: Child tracker and status
parent_status_id: Parent status
parent_tracker_id: Parent tracker
label_filter_group_parent_child: Parent and child
label_filter_child_status_id: Child status
label_filter_child_tracker_id: Child tracker
label_filter_child_tracker_status_id: Child tracker and status
label_filter_parent_status_id: Parent status
label_filter_parent_tracker_id: Parent tracker
label_filter_root: Root
label_filter_root_status_id: Root status
label_filter_root_tracker_id: Root tracker
15 changes: 9 additions & 6 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
es:
label_group_parent_child: Padre y hijo
child_status_id: Estado del hijo
child_tracker_id: Tracker del hijo
child_tracker_status_id: Tracker y estado del hijo
parent_status_id: Estado del padre
parent_tracker_id: Tracker del padre
label_filter_group_parent_child: Padre e hijo
label_filter_child_status_id: Estado del hijo
label_filter_child_tracker_id: Seguimiento del hijo
label_filter_child_tracker_status_id: Seguimiento y estado del hijo
label_filter_parent_status_id: Estado del padre
label_filter_parent_tracker_id: Seguimiento del padre
label_filter_root: Ticket raíz
label_filter_root_status_id: Estado del ticket raíz
label_filter_root_tracker_id: Seguimiento del ticket raíz
15 changes: 9 additions & 6 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
fr:
label_group_parent_child: Parent et enfant
child_status_id: Statut de l'enfant
child_tracker_id: Tracker de l'enfant
child_tracker_status_id: Tracker et statut de l'enfant
parent_status_id: Statut du parent
parent_tracker_id: Tracker du parent
label_filter_group_parent_child: Parent et enfant
label_filter_child_status_id: Statut de l'enfant
label_filter_child_tracker_id: Suivi de l'enfant
label_filter_child_tracker_status_id: Tracker et statut de l'enfant
label_filter_parent_status_id: Statut du parent
label_filter_parent_tracker_id: Tracker du parent
label_filter_root: Ticket racine
label_filter_root_status_id: Statut du ticket racine
label_filter_root_tracker_id: Tracker du ticket racine
15 changes: 9 additions & 6 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
nl:
label_group_parent_child: Parent en child
child_status_id: Child status
child_tracker_id: Child tracker
child_tracker_status_id: Child tracker and status
parent_status_id: Parent status
parent_tracker_id: Parent tracker
label_filter_group_parent_child: Parent en child
label_filter_child_status_id: Child status
label_filter_child_tracker_id: Child tracker
label_filter_child_tracker_status_id: Child tracker and status
label_filter_parent_status_id: Parent status
label_filter_parent_tracker_id: Parent tracker
label_filter_root: Root
label_filter_root_status_id: Root status
label_filter_root_tracker_id: Root tracker
15 changes: 9 additions & 6 deletions config/locales/ro.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ro:
label_group_parent_child: Părinte și copil
child_status_id: Stare copil
child_tracker_id: Tracker copil
child_tracker_status_id: Tracker și stare copil
parent_status_id: Stare părinte
parent_tracker_id: Tracker părinte
label_filter_group_parent_child: Părinte și copil
label_filter_child_status_id: Starea copilului
label_filter_child_tracker_id: Urmărirea copilului
label_filter_child_tracker_status_id: Urmărirea și starea copilului
label_filter_parent_status_id: Starea părintelui
label_filter_parent_tracker_id: Urmărirea părintelui
label_filter_root: Tichet principal
label_filter_root_status_id: Starea tichetului principal
label_filter_root_tracker_id: Urmărirea tichetului principal
15 changes: 9 additions & 6 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
zh:
label_group_parent_child: 父母和子女
child_status_id: 子状态
child_tracker_id: 子追踪器
child_tracker_status_id: 子追踪器和状态
parent_status_id: 父母状态
parent_tracker_id: 父母追踪器
label_filter_group_parent_child: 父与子
label_filter_child_status_id: 子状态
label_filter_child_tracker_id: 子票据追踪
label_filter_child_tracker_status_id: 子票据追踪及状态
label_filter_parent_status_id: 父状态
label_filter_parent_tracker_id: 父票据追踪
label_filter_root: 根票据
label_filter_root_status_id: 根票据状态
label_filter_root_tracker_id: 根票据追踪
49 changes: 42 additions & 7 deletions lib/redmine_parent_child_filters/patches/issue_query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@ module InstanceMethods
def initialize_available_filters_with_pcf
initialize_available_filters_without_pcf
add_available_filter(
"rootissue_id",
:type => :tree, :label => :label_rootissue)
"root_id",
:type => :tree, :label => :label_filter_root)
add_available_filter(
"root_tracker_id",
type: :list, values: trackers.collect { |s| [s.name, s.id.to_s] }, label: :label_filter_root_tracker_id
)
add_available_filter(
"root_status_id",
type: :list_status, values: lambda { issue_statuses_values }, label: :label_filter_root_status_id
)
add_available_filter(
"parent_tracker_id",
type: :list, values: trackers.collect { |s| [s.name, s.id.to_s] }, label: :parent_tracker_id
type: :list, values: trackers.collect { |s| [s.name, s.id.to_s] }, label: :label_filter_parent_tracker_id
)
add_available_filter(
"parent_status_id",
type: :list_status, values: lambda { issue_statuses_values }, label: :parent_status_id
type: :list_status, values: lambda { issue_statuses_values }, label: :label_filter_parent_status_id
)
add_available_filter(
"child_tracker_id",
type: :list, values: trackers.collect { |s| [s.name, s.id.to_s] }, label: :child_tracker_id
type: :list, values: trackers.collect { |s| [s.name, s.id.to_s] }, label: :label_filter_child_tracker_id
)
add_available_filter(
"child_status_id",
type: :list_status, values: lambda { issue_statuses_values }, label: :child_status_id
type: :list_status, values: lambda { issue_statuses_values }, label: :label_filter_child_status_id
)
end

def sql_for_rootissue_id_field(field, operator, value)
def sql_for_root_id_field(field, operator, value)
case operator
when "="
# accepts a comma separated list of ids
Expand All @@ -45,6 +53,33 @@ def sql_for_rootissue_id_field(field, operator, value)
end
end

def sql_for_root_tracker_id_field(field, operator, value)
if operator == '='
# Include issues which are their own root and match the tracker condition
# OR include issues where their root matches the tracker condition
"((#{Issue.table_name}.id = #{Issue.table_name}.root_id AND #{Issue.table_name}.tracker_id IN (#{value.join(',')})) OR (#{Issue.table_name}.root_id IN (SELECT id FROM #{Issue.table_name} WHERE tracker_id IN (#{value.join(',')}))))"
elsif operator == '!'
# Exclude issues which are their own root and match the tracker condition
# OR exclude issues where their root matches the tracker condition
"NOT ((#{Issue.table_name}.id = #{Issue.table_name}.root_id AND #{Issue.table_name}.tracker_id IN (#{value.join(',')})) OR (#{Issue.table_name}.root_id IN (SELECT id FROM #{Issue.table_name} WHERE tracker_id IN (#{value.join(',')}))))"
end
end

def sql_for_root_status_id_field(field, operator, value)
case operator
when '='
"((#{Issue.table_name}.id = #{Issue.table_name}.root_id AND #{Issue.table_name}.status_id IN (#{value.join(',')})) OR (#{Issue.table_name}.root_id IN (SELECT id FROM #{Issue.table_name} WHERE status_id IN (#{value.join(',')}))))"
when '!'
"NOT ((#{Issue.table_name}.id = #{Issue.table_name}.root_id AND #{Issue.table_name}.status_id IN (#{value.join(',')})) OR (#{Issue.table_name}.root_id IN (SELECT id FROM #{Issue.table_name} WHERE status_id IN (#{value.join(',')}))))"
when 'o'
"((#{Issue.table_name}.id = #{Issue.table_name}.root_id AND #{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed = #{ActiveRecord::Base.connection.quoted_false})) OR (#{Issue.table_name}.root_id IN (SELECT id FROM #{Issue.table_name} WHERE status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed = #{ActiveRecord::Base.connection.quoted_false}))))"
when 'c'
"((#{Issue.table_name}.id = #{Issue.table_name}.root_id AND #{Issue.table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed = #{ActiveRecord::Base.connection.quoted_true})) OR (#{Issue.table_name}.root_id IN (SELECT id FROM #{Issue.table_name} WHERE status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed = #{ActiveRecord::Base.connection.quoted_true}))))"
when '*'
"(#{Issue.table_name}.id != #{Issue.table_name}.root_id)"
end
end

def sql_for_parent_tracker_id_field(field, operator, value)
if operator == '='
"(#{Issue.table_name}.parent_id IN (SELECT id FROM #{Issue.table_name} WHERE tracker_id IN (#{value.join(',')})))"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Patches
module QueriesHelperPatch
module InstanceMethods
def filters_options_for_select(query)
new_filters = %w[rootissue_id parent_tracker_id parent_status_id child_tracker_id child_status_id child_tracker_status_id]
new_group = :label_group_parent_child
new_filters = %w[root_id root_tracker_id root_status_id parent_tracker_id parent_status_id child_tracker_id child_status_id child_tracker_status_id]
new_group = :label_filter_group_parent_child
ungrouped = []
grouped = {}
query.available_filters.map do |field, field_options|
Expand Down

0 comments on commit fd00b7d

Please sign in to comment.