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

[59174] Fixed group row name rendering

Andreas Pfohl151dbff5514d
diff --git a/app/models/custom_field/hierarchy/hierarchy_item_adapter.rb b/app/models/custom_field/hierarchy/hierarchy_item_adapter.rb
index 7db6d539d3f..14cd4053bc7 100644
--- a/app/models/custom_field/hierarchy/hierarchy_item_adapter.rb
+++ b/app/models/custom_field/hierarchy/hierarchy_item_adapter.rb
@@ -29,14 +29,11 @@
#++
class CustomField::Hierarchy::HierarchyItemAdapter
- attr_reader :name
-
delegate :id, :label, :short, :to_s, to: :item
- def initialize(item:)
- @item = item
- @name = item.label
- end
+ def initialize(item:) = @item = item
+
+ def name = @item.label
private
diff --git a/app/models/custom_field/hierarchy/item.rb b/app/models/custom_field/hierarchy/item.rb
index 19bc4a7dd78..7bfd41af215 100644
--- a/app/models/custom_field/hierarchy/item.rb
+++ b/app/models/custom_field/hierarchy/item.rb
@@ -36,5 +36,5 @@ class CustomField::Hierarchy::Item < ApplicationRecord
scope :including_children, -> { includes(children: :children) }
- def to_s = label
+ def to_s = short.nil? ? label : "#{label} (#{short})"
end
diff --git a/app/models/query/results/group_by.rb b/app/models/query/results/group_by.rb
index ed741e8f255..efe8d4f1811 100644
--- a/app/models/query/results/group_by.rb
+++ b/app/models/query/results/group_by.rb
@@ -101,9 +101,7 @@ module ::Query::Results::GroupBy
groups.transform_keys do |key|
if custom_field.multi_value?
- (key ? key.split(".") : []).map do |subkey|
- items[subkey]
- end
+ Array(key&.split(".")).map { |subkey| items[subkey] }
else
items[key] || nil
end
@@ -118,8 +116,7 @@ module ::Query::Results::GroupBy
.new
.get_descendants(item: custom_field.hierarchy_root, include_self: false)
.fmap do |list|
- list.map { |item| CustomField::Hierarchy::HierarchyItemAdapter.new(item:) }
- .filter { |item| keys.include?(item.label) }
+ list.filter_map { |item| CustomField::Hierarchy::HierarchyItemAdapter.new(item:) if keys.include?(item.label) }
.index_by(&:label)
end
.either(
@@ -138,9 +135,7 @@ module ::Query::Results::GroupBy
groups.transform_keys do |key|
if custom_field.multi_value?
- (key ? key.split(".") : []).map do |subkey|
- options[subkey].first
- end
+ Array(key&.split(".")).map.map { |subkey| options[subkey].first }
else
options[key]&.first
end
diff --git a/lib/api/decorators/aggregation_group.rb b/lib/api/decorators/aggregation_group.rb
index c3f066747a6..ec343ba83bb 100644
--- a/lib/api/decorators/aggregation_group.rb
+++ b/lib/api/decorators/aggregation_group.rb
@@ -33,11 +33,9 @@ module API
@count = count
@query = query
- if group_key.is_a?(Array)
- group_key = set_links!(group_key)
- end
-
- @link = ::API::V3::Utilities::ResourceLinkGenerator.make_link(group_key)
+ @link = ::API::V3::Utilities::ResourceLinkGenerator.make_link(
+ group_key.is_a?(Array) ? set_links!(group_key) : group_key
+ )
super(group_key, current_user:)
end
@@ -86,10 +84,13 @@ module API
end
def value
- if represented == true || represented == false
+ case represented
+ when TrueClass, FalseClass
represented
+ when Array
+ represented.empty? ? nil : represented.map(&:to_s).sort.join(", ")
else
- represented ? represented.to_s : nil
+ represented&.to_s
end
end