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

[#57813] amend custom field code to allow creation

Eric Schubert02d120766410
diff --git a/app/services/custom_fields/create_service.rb b/app/services/custom_fields/create_service.rb
index 4d08c8aaba4..f405956717c 100644
--- a/app/services/custom_fields/create_service.rb
+++ b/app/services/custom_fields/create_service.rb
@@ -56,6 +56,14 @@ module CustomFields
if cf.is_a?(ProjectCustomField)
add_cf_to_visible_columns(cf)
+ elsif cf.field_format == "hierarchy"
+ # TODO: Use persistence service
+ CustomField::Hierarchy::Item.create(custom_field: cf,
+ label: nil,
+ parent: nil,
+ short: nil,
+ sort_order: 0)
+ .save
end
call
diff --git a/lib/open_project/custom_field_format_dependent.rb b/lib/open_project/custom_field_format_dependent.rb
index e307dba16ab..937920c6606 100644
--- a/lib/open_project/custom_field_format_dependent.rb
+++ b/lib/open_project/custom_field_format_dependent.rb
@@ -32,11 +32,11 @@ module OpenProject
allowNonOpenVersions: [:only, %w[version]],
defaultBool: [:only, %w[bool]],
defaultLongText: [:only, %w[text]],
- defaultText: [:except, %w[list bool date text user version]],
- length: [:except, %w[list bool date user version link]],
- multiSelect: [:only, %w[list user version]],
+ defaultText: [:except, %w[list bool date text user version hierarchy]],
+ length: [:except, %w[list bool date user version link hierarchy]],
+ multiSelect: [:only, %w[list user version hierarchy]],
possibleValues: [:only, %w[list]],
- regexp: [:except, %w[list bool date user version]],
+ regexp: [:except, %w[list bool date user version hierarchy]],
searchable: [:except, %w[bool date float int user version]],
textOrientation: [:only, %w[text]]
}.freeze