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

Simplify `each_filter` method in the FiltersComponent

Klaus Zanders1890c266be64
diff --git a/app/components/filters_component.rb b/app/components/filters_component.rb
index 2fb96da0548..4b745217f4f 100644
--- a/app/components/filters_component.rb
+++ b/app/components/filters_component.rb
@@ -44,15 +44,9 @@ class FiltersComponent < ApplicationComponent
# Returns filters, active and inactive.
# In case a filter is active, the active one will be preferred over the inactive one.
def each_filter
- allowed_filters.map do |filter|
+ allowed_filters.each do |filter|
active_filter = query.find_active_filter(filter.name)
- filter_active = active_filter.present?
-
- if filter_active
- yield active_filter, filter_active
- else
- yield filter, filter_active
- end
+ yield active_filter.presence || filter, active_filter.present?
end
end