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

[#57814] added predicate for field_format

Eric Schubert6fdbc5991104
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index 873b78ff356..e8596a9e53e 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -293,6 +293,10 @@ class CustomField < ApplicationRecord
version? || user? || list?
end
+ def field_format_hierarchy?
+ field_format == "hierarchy"
+ end
+
def allow_non_open_versions_possible?
version?
end
diff --git a/app/services/custom_fields/create_service.rb b/app/services/custom_fields/create_service.rb
index f405956717c..5466f7cd28a 100644
--- a/app/services/custom_fields/create_service.rb
+++ b/app/services/custom_fields/create_service.rb
@@ -56,7 +56,7 @@ module CustomFields
if cf.is_a?(ProjectCustomField)
add_cf_to_visible_columns(cf)
- elsif cf.field_format == "hierarchy"
+ elsif cf.field_format_hierarchy?
# TODO: Use persistence service
CustomField::Hierarchy::Item.create(custom_field: cf,
label: nil,
diff --git a/app/views/custom_fields/edit.html.erb b/app/views/custom_fields/edit.html.erb
index dca852fc71d..b6741374f91 100644
--- a/app/views/custom_fields/edit.html.erb
+++ b/app/views/custom_fields/edit.html.erb
@@ -33,7 +33,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= error_messages_for 'custom_field' %>
-<% if @custom_field.field_format == "hierarchy" %>
+<% if @custom_field.field_format_hierarchy? %>
<%= render CustomFields::DetailsComponent.new(@custom_field) %>
<% else %>
<%= labelled_tabular_form_for @custom_field, as: :custom_field,