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

[chore] render item shorts in value selector

Eric Schubertce1500cd468e
diff --git a/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer.rb b/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer.rb
index c978dd7993c..fc527c011e9 100644
--- a/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer.rb
+++ b/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer.rb
@@ -36,7 +36,13 @@ module API
end
self_link path: :custom_field_item,
- title_getter: ->(*) { represented.label }
+ title_getter: ->(*) do
+ if represented.short.nil?
+ represented.label
+ else
+ "#{represented.label} (#{represented.short})"
+ end
+ end
property :id
diff --git a/spec/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer_rendering_spec.rb b/spec/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer_rendering_spec.rb
index 933145199a6..4a33d86b16e 100644
--- a/spec/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/custom_fields/hierarchy/hierarchy_item_representer_rendering_spec.rb
@@ -121,7 +121,7 @@ RSpec.describe API::V3::CustomFields::Hierarchy::HierarchyItemRepresenter, "rend
it_behaves_like "has a titled link" do
let(:link) { "self" }
let(:href) { api_v3_paths.custom_field_item(item.id) }
- let(:title) { item.label }
+ let(:title) { "#{item.label} (#{item.short})" }
end
it_behaves_like "has a titled link" do
@@ -171,7 +171,7 @@ RSpec.describe API::V3::CustomFields::Hierarchy::HierarchyItemRepresenter, "rend
it_behaves_like "has a titled link" do
let(:link) { "self" }
let(:href) { api_v3_paths.custom_field_item(item.id) }
- let(:title) { item.label }
+ let(:title) { "#{item.label} (#{item.short})" }
end
it_behaves_like "has a titled link" do