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

remove additional Hierarchy nesting

as-opf1e63c4d3964
diff --git a/app/models/exports/formatters/custom_field.rb b/app/models/exports/formatters/custom_field.rb
index 3c536bcafd7..f5e22a932cb 100644
--- a/app/models/exports/formatters/custom_field.rb
+++ b/app/models/exports/formatters/custom_field.rb
@@ -59,7 +59,7 @@ module Exports
when "text"
object.typed_custom_value_for(custom_field)
when "hierarchy"
- ::Exports::Formatters::Hierarchy::HierarchyFormatter.new.format(object, custom_field)
+ HierarchyFormatter.new.format(object, custom_field)
else
object.formatted_custom_value_for(custom_field)
end
diff --git a/app/models/exports/formatters/hierarchy/hierarchy_formatter.rb b/app/models/exports/formatters/hierarchy_formatter.rb
similarity index 63%
rename from app/models/exports/formatters/hierarchy/hierarchy_formatter.rb
rename to app/models/exports/formatters/hierarchy_formatter.rb
index 8fb68da56cd..e401b832a7b 100644
--- a/app/models/exports/formatters/hierarchy/hierarchy_formatter.rb
+++ b/app/models/exports/formatters/hierarchy_formatter.rb
@@ -30,30 +30,28 @@
module Exports
module Formatters
- module Hierarchy
- class HierarchyFormatter
- def format(object, custom_field)
- cvs = object.custom_value_for(custom_field)
- case cvs
- when Array
- cvs.map { |item| format_hierarchy_item_for_export(item) }.join(", ")
- when CustomValue
- format_hierarchy_item_for_export(cvs)
- else
- cvs
- end
+ class HierarchyFormatter
+ def format(object, custom_field)
+ cvs = object.custom_value_for(custom_field)
+ case cvs
+ when Array
+ cvs.map { |item| format_hierarchy_item_for_export(item) }.join(", ")
+ when CustomValue
+ format_hierarchy_item_for_export(cvs)
+ else
+ cvs
end
+ end
- def format_hierarchy_item_for_export(item_value)
- item = ::CustomField::Hierarchy::Item.find_by(id: item_value.to_s)
- return "#{item_value} #{I18n.t(:label_not_found)}" if item.nil?
+ def format_hierarchy_item_for_export(item_value)
+ item = ::CustomField::Hierarchy::Item.find_by(id: item_value.to_s)
+ return "#{item_value} #{I18n.t(:label_not_found)}" if item.nil?
- item.ancestry_path
- end
+ item.ancestry_path
+ end
- def hierarchy_item_service
- ::CustomFields::Hierarchy::HierarchicalItemService.new
- end
+ def hierarchy_item_service
+ ::CustomFields::Hierarchy::HierarchicalItemService.new
end
end
end