Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Extract user filter checking into a helper

Klaus Zandersdbfe5db1df98
diff --git a/modules/reporting/lib/widget/filters.rb b/modules/reporting/lib/widget/filters.rb
index 2117840bed4..c10544f7e9c 100644
--- a/modules/reporting/lib/widget/filters.rb
+++ b/modules/reporting/lib/widget/filters.rb
@@ -100,8 +100,7 @@ class Widget::Filters < Widget::Base
# Handling for custom widgets first
if f_cls == CostQuery::Filter::ProjectId
render_widget Project, f, to: html
- elsif f_cls.in?([CostQuery::Filter::UserId, CostQuery::Filter::LoggedById, CostQuery::Filter::AssignedToId,
- CostQuery::Filter::ResponsibleId, CostQuery::Filter::AuthorId])
+ elsif user_filter?(f_cls)
render_widget User, f, to: html
elsif f_cls == CostQuery::Filter::WorkPackageId
render_widget WorkPackage, f, to: html
@@ -126,6 +125,16 @@ class Widget::Filters < Widget::Base
render_widget RemoveButton, f, to: html
end
# rubocop:enable Metrics/PerceivedComplexity
+
+ def user_filter?(f_cls)
+ f_cls.in?([
+ CostQuery::Filter::UserId,
+ CostQuery::Filter::LoggedById,
+ CostQuery::Filter::AssignedToId,
+ CostQuery::Filter::ResponsibleId,
+ CostQuery::Filter::AuthorId
+ ])
+ end
end
# rubocop:enable Metrics/AbcSize