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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use hierarchy format as blueprint for moving to primer forms
ulferts84ea15fa6171
diff --git a/app/components/custom_fields/details_component.html.erb b/app/components/custom_fields/details_component.html.erbindex 6bdd6fe91c1..227877525f9 100644--- a/app/components/custom_fields/details_component.html.erb+++ b/app/components/custom_fields/details_component.html.erb@@ -1,7 +1,7 @@<%=component_wrapper doflex_layout do |content|- if has_no_items_or_projects?+ if persisted_cf_has_no_items_or_projects?content.with_row(mb: 3) dorender Primer::Alpha::Banner.new(scheme: :default,@@ -19,8 +19,8 @@model:,scope: :custom_field,id: "custom_field_form",- url: custom_field_path(model),- method: :put+ url: form_url,+ method: form_method) { |form| render CustomFields::DetailsForm.new(form) }endenddiff --git a/app/components/custom_fields/details_component.rb b/app/components/custom_fields/details_component.rbindex dd258b29326..98493124464 100644--- a/app/components/custom_fields/details_component.rb+++ b/app/components/custom_fields/details_component.rb@@ -36,10 +36,19 @@ module CustomFieldsalias_method :custom_field, :model- def has_no_items_or_projects?+ def persisted_cf_has_no_items_or_projects?+ custom_field.persisted? &&custom_field.field_format_hierarchy? &&custom_field.hierarchy_root.children.empty? &&custom_field.projects.empty?end++ def form_url+ model.new_record? ? custom_fields_path : custom_field_path(model)+ end++ def form_method+ model.new_record? ? :post : :put+ endendenddiff --git a/app/forms/custom_fields/details_form.rb b/app/forms/custom_fields/details_form.rbindex a73381e8cd3..889fba281e9 100644--- a/app/forms/custom_fields/details_form.rb+++ b/app/forms/custom_fields/details_form.rb@@ -31,6 +31,17 @@module CustomFieldsclass DetailsForm < ApplicationFormform do |details_form|+ if model.new_record?+ details_form.hidden(+ name: :type,+ scope_name_to_model: false+ )++ details_form.hidden(+ name: :field_format+ )+ end+details_form.text_field(name: :name,label: I18n.t(:label_name),diff --git a/app/views/custom_fields/edit.html.erb b/app/views/custom_fields/edit.html.erbindex 50680dbae1d..78a61bde421 100644--- a/app/views/custom_fields/edit.html.erb+++ b/app/views/custom_fields/edit.html.erb@@ -31,15 +31,15 @@ See COPYRIGHT and LICENSE files for more details.<%= render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field, selected: :edit)) %>-<%= error_messages_for "custom_field" %>--<% content_controller "admin--custom-fields",- "admin--custom-fields-format-config-value": OpenProject::CustomFieldFormatDependent.stimulus_config,- "admin--custom-fields-format-value": @custom_field.field_format %>-<% if @custom_field.field_format_hierarchy? %><%= render CustomFields::DetailsComponent.new(@custom_field) %><% else %>+ <%= error_messages_for "custom_field" %>++ <% content_controller "admin--custom-fields",+ "admin--custom-fields-format-config-value": OpenProject::CustomFieldFormatDependent.stimulus_config,+ "admin--custom-fields-format-value": @custom_field.field_format %>+<%= labelled_tabular_form_for @custom_field,as: :custom_field,url: custom_field_path(@custom_field),diff --git a/app/views/custom_fields/new.html.erb b/app/views/custom_fields/new.html.erbindex f1bd20b59ad..e26bae36fee 100644--- a/app/views/custom_fields/new.html.erb+++ b/app/views/custom_fields/new.html.erb@@ -41,21 +41,26 @@ See COPYRIGHT and LICENSE files for more details.end%>-<%= error_messages_for "custom_field" %>--<% content_controller "admin--custom-fields",- "admin--custom-fields-format-config-value": OpenProject::CustomFieldFormatDependent.stimulus_config,- "admin--custom-fields-format-value": @custom_field.field_format,- "admin--custom-fields-hierarchy-enabled-value": EnterpriseToken.allows_to?(:custom_field_hierarchies) %>--<%= labelled_tabular_form_for @custom_field, as: :custom_field,- url: custom_fields_path,- html: { id: "custom_field_form", class: "-wide-labels" } do |f| %>- <%= render partial: "form", locals: { f: f } %>- <%= hidden_field_tag "type", @custom_field.type %>- <%= styled_button_tag t(:button_save),- class: "-primary -with-icon icon-checkmark",- data: {- "admin--custom-fields-target": "submitButton"- } %>+<% if @custom_field.field_format_hierarchy? %>+ <%= render CustomFields::DetailsComponent.new(@custom_field) %>+<% else %>+ <%= error_messages_for "custom_field" %>++ <% content_controller "admin--custom-fields",+ "admin--custom-fields-format-config-value": OpenProject::CustomFieldFormatDependent.stimulus_config,+ "admin--custom-fields-format-value": @custom_field.field_format,+ "admin--custom-fields-hierarchy-enabled-value": EnterpriseToken.allows_to?(:custom_field_hierarchies) %>++ <%= labelled_tabular_form_for @custom_field,+ as: :custom_field,+ url: custom_fields_path,+ html: { id: "custom_field_form", class: "-wide-labels" } do |f| %>+ <%= render partial: "form", locals: { f: f } %>+ <%= hidden_field_tag "type", @custom_field.type %>+ <%= styled_button_tag t(:button_save),+ class: "-primary -with-icon icon-checkmark",+ data: {+ "admin--custom-fields-target": "submitButton"+ } %>+ <% end %><% end %>