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

Show the project autocompelter also when initially adding the project filter where `f_inst` is nil. Furhter let the filter be able to deal with multiple projects selected.

Henriette Darge335d6551b904
diff --git a/modules/reporting/lib/widget/filters.rb b/modules/reporting/lib/widget/filters.rb
index ce0e392db0b..0c42f9a1101 100644
--- a/modules/reporting/lib/widget/filters.rb
+++ b/modules/reporting/lib/widget/filters.rb
@@ -84,6 +84,7 @@ class Widget::Filters < ::Widget::Base
html = ''.html_safe
render_widget Label, f, to: html
render_widget Operators, f, to: html
+
if f_cls.heavy?
render_widget Heavy, f, to: html
elsif engine::Operator.string_operators.all? { |o| f_cls.available_operators.include? o }
@@ -98,7 +99,7 @@ class Widget::Filters < ::Widget::Base
end
elsif f_cls.is_multiple_choice?
render_widget MultiChoice, f, to: html
- elsif f_inst.instance_of?(CostQuery::Filter::ProjectId)
+ elsif f_cls == CostQuery::Filter::ProjectId
render_widget Project, f, to: html, lazy: true
else
render_widget MultiValues, f, to: html, lazy: true
diff --git a/modules/reporting/lib/widget/filters/project.rb b/modules/reporting/lib/widget/filters/project.rb
index 94232adfa19..ca381ce540a 100644
--- a/modules/reporting/lib/widget/filters/project.rb
+++ b/modules/reporting/lib/widget/filters/project.rb
@@ -60,9 +60,15 @@ class Widget::Filters::Project < Widget::Filters::Base
end
def map_filter_values
+ # In case the filter values are all written in a single string (e.g. ["12, 33"])
+ if filter.values.length === 1 && filter.values[0].instance_of?(String)
+ filter.values = filter.values[0].split(',')
+ end
+
filter.values.each.map do |id|
# When live testing, these IDs came out as integers.
# However, when running the specs, they came out as strings.
+
int_id = Integer(id)
available_value = filter_class.available_values.detect { |val| Integer(val[1]) === int_id }