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

Updates components and controller to deal with turbo updates and navigation down the tree

Marcello Rochadf8802d43ad5
diff --git a/app/components/admin/custom_fields/hierarchy/delete_item_dialog_component.html.erb b/app/components/admin/custom_fields/hierarchy/delete_item_dialog_component.html.erb
index 1d4a054a67f..6c2d6b0e2b2 100644
--- a/app/components/admin/custom_fields/hierarchy/delete_item_dialog_component.html.erb
+++ b/app/components/admin/custom_fields/hierarchy/delete_item_dialog_component.html.erb
@@ -28,9 +28,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%=
- render(Primer::Alpha::Dialog.new(id: DIALOG_ID,
- title: "Delete item",
- data: { test_selector: TEST_SELECTOR })) do |dialog|
+ render(Primer::Alpha::Dialog.new(id: DIALOG_ID, title: "Delete item", test_selector: TEST_SELECTOR)) do |dialog|
dialog.with_header(variant: :large)
dialog.with_body do
"Are you sure you want to delete this item from the current hierarchy level?"
@@ -42,14 +40,12 @@ See COPYRIGHT and LICENSE files for more details.
end)
concat(primer_form_with(
- model: @custom_field,
- url: custom_field_item_path(custom_field_id: @custom_field.id, id: @hierarchy_item.id),
- method: :delete,
- data: { turbo: true }
- ) do
- render(Primer::ButtonComponent.new(scheme: :danger,
- type: :submit,
- data: { "close-dialog-id": DIALOG_ID })) do
+ model: @custom_field,
+ url: custom_field_item_path(custom_field_id: @custom_field.id, id: @hierarchy_item.id),
+ method: :delete,
+ data: { turbo: true }
+ ) do
+ render(Primer::ButtonComponent.new(scheme: :danger, type: :submit, data: { "close-dialog-id": DIALOG_ID })) do
I18n.t(:button_delete)
end
end)
diff --git a/app/components/admin/custom_fields/hierarchy/item_component.html.erb b/app/components/admin/custom_fields/hierarchy/item_component.html.erb
index c9095d506b8..e2f4d08109f 100644
--- a/app/components/admin/custom_fields/hierarchy/item_component.html.erb
+++ b/app/components/admin/custom_fields/hierarchy/item_component.html.erb
@@ -28,42 +28,37 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%=
- component_wrapper(data: { test_selector: "op-custom-fields--hierarchy-item" }) do
+ component_wrapper(tag: "turbo-frame", refresh: :morph) do
if show_edit_form?
render Admin::CustomFields::Hierarchy::ItemFormComponent.new(
- custom_field: @custom_field,
- hierarchy_item: @hierarchy_item,
- url: custom_field_item_path(@custom_field, @hierarchy_item),
- method: :put,
- label: @edit_item_form_data.fetch(:label, nil),
- short: @edit_item_form_data.fetch(:short, nil)
+ target_item: model,
+ url: custom_field_item_path(@root.custom_field_id, model),
+ method: :put
)
else
- flex_layout(align_items: :center, justify_content: :space_between) do |item_container|
+ flex_layout(align_items: :center, justify_content: :space_between, test_selector: "op-custom-fields--hierarchy-item") do |item_container|
item_container.with_column(flex_layout: true) do |item_information|
item_information.with_column(mr: 2) do
- render(Primer::Beta::Link.new(href: custom_field_item_path(@hierarchy_item.root, @hierarchy_item), underline: false)) do
- render(Primer::Beta::Text.new(font_weight: :bold)) do
- @hierarchy_item.label
- end
+ render(Primer::Beta::Link.new(href: custom_field_item_path(model.root.custom_field_id, model), underline: false)) do
+ render(Primer::Beta::Text.new(font_weight: :bold)) { model.label }
end
end
- unless @hierarchy_item.short.nil?
+ if model.short.present?
item_information.with_column(mr: 2) do
render(Primer::Beta::Text.new(color: :subtle)) { short_text }
end
end
- end
- if @hierarchy_item.children.exists?
- item_information.with_column(mr: 2) do
- render(Primer::Beta::Text.new) { children_count }
+ if model.children.any?
+ item_information.with_column(mr: 2) do
+ render(Primer::Beta::Text.new) { children_count }
+ end
end
end
item_container.with_column do
- render(Primer::Alpha::ActionMenu.new(data: { test_selector: "op-hierarchy-item--action-menu" })) do |menu|
+ render(Primer::Alpha::ActionMenu.new(test_selector: "op-hierarchy-item--action-menu")) do |menu|
menu.with_show_button(icon: "kebab-horizontal",
scheme: :invisible,
"aria-label": I18n.t("custom_fields.admin.items.actions"))
diff --git a/app/components/admin/custom_fields/hierarchy/item_component.rb b/app/components/admin/custom_fields/hierarchy/item_component.rb
index 0183d55a25d..980fc9307e4 100644
--- a/app/components/admin/custom_fields/hierarchy/item_component.rb
+++ b/app/components/admin/custom_fields/hierarchy/item_component.rb
@@ -35,35 +35,31 @@ module Admin
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(custom_field:, hierarchy_item:, edit_item_form_data: { show: false })
- super
- @custom_field = custom_field
- @hierarchy_item = hierarchy_item
- @edit_item_form_data = edit_item_form_data
- end
-
- def short_text
- "(#{@hierarchy_item.short})"
+ def initialize(item:, show_edit_form: false)
+ super(item)
+ @show_edit_form = show_edit_form
+ @root = item.root
end
def wrapper_uniq_by
- @hierarchy_item.id
+ model.id
end
- def show_edit_form?
- @edit_item_form_data.fetch(:show, false)
+ def short_text
+ "(#{model.short})"
end
+ def show_edit_form? = @show_edit_form
+
def children_count
- pluralize(@hierarchy_item.children.count, "sub-item")
+ I18n.t("custom_fields.admin.hierarchy.subitems", count: model.children.count)
end
def deletion_action_item(menu)
menu.with_item(label: I18n.t(:button_delete),
scheme: :danger,
tag: :a,
- href: deletion_dialog_custom_field_item_path(custom_field_id: @custom_field.id,
- id: @hierarchy_item.id),
+ href: deletion_dialog_custom_field_item_path(custom_field_id: @root.custom_field_id, id: model.id),
content_arguments: { data: { controller: "async-dialog" } }) do |item|
item.with_leading_visual_icon(icon: :trash)
end
@@ -72,8 +68,7 @@ module Admin
def edit_action_item(menu)
menu.with_item(label: I18n.t(:button_edit),
tag: :a,
- content_arguments: { data: { turbo_stream: true } },
- href: edit_custom_field_item_path(@custom_field, @hierarchy_item)) do |item|
+ href: edit_custom_field_item_path(@root.custom_field_id, model)) do |item|
item.with_leading_visual_icon(icon: :pencil)
end
end
diff --git a/app/components/admin/custom_fields/hierarchy/item_form_component.html.erb b/app/components/admin/custom_fields/hierarchy/item_form_component.html.erb
index 4a6d893b280..19e98ea72e8 100644
--- a/app/components/admin/custom_fields/hierarchy/item_form_component.html.erb
+++ b/app/components/admin/custom_fields/hierarchy/item_form_component.html.erb
@@ -28,13 +28,7 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%=
- primer_form_with(url: @url, method: @method, data: { test_selector: "op-custom-fields--new-item-form" }) do |f|
- render(CustomFields::Hierarchy::ItemForm.new(
- f,
- custom_field: @custom_field,
- hierarchy_item: @hierarchy_item,
- label: @label,
- short: @short
- ))
+ primer_form_with(url: @url, method: @method, test_selector: "op-custom-fields--new-item-form") do |f|
+ render(CustomFields::Hierarchy::ItemForm.new(f, target_item: model))
end
%>
diff --git a/app/components/admin/custom_fields/hierarchy/item_form_component.rb b/app/components/admin/custom_fields/hierarchy/item_form_component.rb
index ce21618f638..779b15079c1 100644
--- a/app/components/admin/custom_fields/hierarchy/item_form_component.rb
+++ b/app/components/admin/custom_fields/hierarchy/item_form_component.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -32,18 +34,10 @@ module Admin
class ItemFormComponent < ApplicationComponent
include OpTurbo::Streamable
- def initialize(custom_field:, hierarchy_item:, url:, method:, label: nil, short: nil)
- super
- @custom_field = custom_field
- @hierarchy_item = hierarchy_item
+ def initialize(target_item:, url:, method:)
+ super(target_item)
@url = url
@method = method
- @label = label || @hierarchy_item.label
- @short = short || @hierarchy_item.short
- end
-
- def items_path
- custom_field_items_path(@custom_field)
end
end
end
diff --git a/app/components/admin/custom_fields/hierarchy/items_component.html.erb b/app/components/admin/custom_fields/hierarchy/items_component.html.erb
index 801d68b0422..2339427ab7a 100644
--- a/app/components/admin/custom_fields/hierarchy/items_component.html.erb
+++ b/app/components/admin/custom_fields/hierarchy/items_component.html.erb
@@ -28,42 +28,33 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
<%=
- component_wrapper(tag: "turbo-frame") do
+ component_wrapper(tag: "turbo-frame", refresh: :morph, data: { turbo_action: :advance }) do
flex_layout do |container|
- if items.empty? && !show_new_item_form?
- container.with_row(mb: 3) do
- render Primer::Beta::Blankslate.new(
- border: true,
- test_selector: "op-custom-fields--hierarchy-items-blankslate"
- ) do |component|
- component.with_visual_icon(icon: "list-ordered")
- component.with_heading(tag: :h3).with_content(I18n.t("custom_fields.admin.items.blankslate.title"))
- component.with_description { I18n.t("custom_fields.admin.items.blankslate.description") }
- end
- end
- else
- container.with_row(mb: 3) do
- render(Primer::Beta::BorderBox.new) do |item_box|
- item_box.with_header { @custom_field.name }
+ container.with_row(mb: 3) do
+ render(Primer::Beta::BorderBox.new) do |box|
+ box.with_header { item_header }
- items.each do |item|
- item_box.with_row do
- render Admin::CustomFields::Hierarchy::ItemComponent.new(
- custom_field: @custom_field,
- hierarchy_item: item
- )
+ if children.empty? && !show_new_item_form?
+ box.with_row do
+ render(Primer::Beta::Blankslate.new(test_selector: "op-custom-fields--hierarchy-items-blankslate")) do |component|
+ component.with_visual_icon(icon: "list-ordered")
+ component.with_heading(tag: :h3).with_content(I18n.t("custom_fields.admin.items.blankslate.title"))
+ component.with_description { I18n.t("custom_fields.admin.items.blankslate.description") }
+ end
+ end
+ else
+ children.each do |item|
+ box.with_row do
+ render Admin::CustomFields::Hierarchy::ItemComponent.new(item: item)
end
end
if show_new_item_form?
- item_box.with_footer do
+ box.with_footer(test_selector: "op-custom-fields--new-item-form") do
render Admin::CustomFields::Hierarchy::ItemFormComponent.new(
- custom_field: @custom_field,
- hierarchy_item: CustomField::Hierarchy::Item.new,
- url: custom_field_items_path(@custom_field),
- method: :post,
- label: @new_item_form_data[:label],
- short: @new_item_form_data[:short]
+ target_item: @new_item,
+ url: new_child_custom_field_item_path(model.root.custom_field_id, model),
+ method: :post
)
end
end
@@ -74,8 +65,7 @@ See COPYRIGHT and LICENSE files for more details.
container.with_row do
render Primer::Beta::Button.new(scheme: :primary,
tag: :a,
- data: { turbo_stream: true },
- href: new_custom_field_item_path(@custom_field)) do |button|
+ href: new_child_custom_field_item_path(model.root.custom_field_id, model)) do |button|
button.with_leading_visual_icon(icon: :plus)
I18n.t(:label_item)
end
diff --git a/app/components/admin/custom_fields/hierarchy/items_component.rb b/app/components/admin/custom_fields/hierarchy/items_component.rb
index a0c91411f7d..bfa1e335ed5 100644
--- a/app/components/admin/custom_fields/hierarchy/items_component.rb
+++ b/app/components/admin/custom_fields/hierarchy/items_component.rb
@@ -35,19 +35,42 @@ module Admin
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(custom_field:, new_item_form_data: { show: false })
- super
- @custom_field = custom_field
- @new_item_form_data = new_item_form_data
+ property :children
+
+ def initialize(item:, new_item: nil)
+ super(item)
+ @new_item = new_item
end
- def items
- # TODO: This must be context aware (breadcrumbs)
- @custom_field.hierarchy_root.children
+ def branch_root = model
+ def show_new_item_form? = @new_item
+
+ def root
+ return model if model.root?
+
+ @root ||= model.root
end
- def show_new_item_form?
- @new_item_form_data[:show] || false
+ def item_header
+ render(Primer::Beta::Breadcrumbs.new) do |loaf|
+ slices.each do |slice|
+ loaf.with_item(href: slice[:href], target: nil) { slice[:label] }
+ end
+ end
+ end
+
+ private
+
+ def slices
+ nodes = ::CustomFields::Hierarchy::HierarchicalItemService.new.get_branch(item: model).value!
+
+ nodes.map do |item|
+ if item.root?
+ { href: custom_field_items_path(root.custom_field_id), label: root.custom_field.name }
+ else
+ { href: custom_field_item_path(root.custom_field_id, item), label: item.label }
+ end
+ end
end
end
end
diff --git a/app/contracts/custom_fields/hierarchy/update_item_contract.rb b/app/contracts/custom_fields/hierarchy/update_item_contract.rb
index e3d139bdcc4..8899cfb8a44 100644
--- a/app/contracts/custom_fields/hierarchy/update_item_contract.rb
+++ b/app/contracts/custom_fields/hierarchy/update_item_contract.rb
@@ -45,12 +45,7 @@ module CustomFields
rule(:label) do
next unless key?
- label_already_exists = CustomField::Hierarchy::Item
- .where(parent_id: values[:item].parent_id, label: value)
- .where.not(id: values[:item].id)
- .exists?
-
- if label_already_exists
+ if values[:item].siblings.where(label: value).any?
key.failure("must be unique at the same hierarchical level")
end
end
diff --git a/app/controllers/admin/custom_fields/hierarchy/items_controller.rb b/app/controllers/admin/custom_fields/hierarchy/items_controller.rb
index e4676c34737..b40a44c5706 100644
--- a/app/controllers/admin/custom_fields/hierarchy/items_controller.rb
+++ b/app/controllers/admin/custom_fields/hierarchy/items_controller.rb
@@ -35,122 +35,114 @@ module Admin
include OpTurbo::ComponentStream
include OpTurbo::DialogStreamHelper
- layout "admin"
-
+ layout :admin_or_frame_layout
model_object CustomField
- before_action :require_admin
- before_action :find_model_object, except: %i[destroy deletion_dialog]
- before_action :find_custom_field_and_item, only: %i[destroy deletion_dialog edit update]
+ before_action :require_admin, :find_model_object, :find_active_item
menu_item :custom_fields
- def index; end
+ # See https://github.com/hotwired/turbo-rails?tab=readme-ov-file#a-note-on-custom-layouts
+ def admin_or_frame_layout
+ return "turbo_rails/frame" if turbo_frame_request?
- def new
- update_via_turbo_stream(component: ItemsComponent.new(custom_field: @custom_field,
- new_item_form_data: { show: true }))
- respond_with_turbo_streams
+ "admin"
end
- def edit
- update_via_turbo_stream(
- component: ItemComponent.new(
- custom_field: @custom_field,
- hierarchy_item: @hierarchy_item,
- edit_item_form_data: { show: true }
- )
- )
+ def index; end
- respond_with_turbo_streams
+ def show
+ render action: :index
end
+ def new
+ @new_item = ::CustomField::Hierarchy::Item.new(parent: @active_item)
+ end
+
+ def edit; end
+
def create
- ::CustomFields::Hierarchy::HierarchicalItemService
- .new
+ item_service
.insert_item(**item_input)
.either(
- ->(_) do
- update_via_turbo_stream(component: ItemsComponent.new(custom_field: @custom_field,
- new_item_form_data: { show: true }))
- end,
- ->(validation_result) { add_errors_to_new_form(validation_result) }
+ ->(_) { redirect_to(new_child_custom_field_item_path(@custom_field, @active_item), status: :see_other) },
+ ->(validation_result) do
+ add_errors_to_form(validation_result)
+ render action: :new
+ end
)
-
- respond_with_turbo_streams
end
def update
- ::CustomFields::Hierarchy::HierarchicalItemService
- .new
- .update_item(item: @hierarchy_item, label: item_input[:label], short: item_input[:short])
+ item_service
+ .update_item(item: @active_item, label: item_input[:label], short: item_input[:short])
.either(
->(_) do
- update_via_turbo_stream(component: ItemComponent.new(custom_field: @custom_field,
- hierarchy_item: @hierarchy_item))
+ redirect_to(custom_field_item_path(@custom_field, @active_item.parent), status: :see_other)
end,
- ->(validation_result) { add_errors_to_edit_form(validation_result) }
+ ->(validation_result) do
+ add_errors_to_edit_form(validation_result)
+ render action: :edit
+ end
)
-
- respond_with_turbo_streams
end
def destroy
- ::CustomFields::Hierarchy::HierarchicalItemService
- .new
- .delete_branch(item: @hierarchy_item)
+ item_service
+ .delete_branch(item: @active_item)
.either(
- ->(_) { update_via_turbo_stream(component: ItemsComponent.new(custom_field: @custom_field)) },
+ ->(_) { update_via_turbo_stream(component: ItemsComponent.new(item: @active_item.parent)) },
->(errors) { update_flash_message_via_turbo_stream(message: errors.full_messages, scheme: :danger) }
)
- respond_with_turbo_streams
+ respond_with_turbo_streams(&:html)
end
def deletion_dialog
- respond_with_dialog DeleteItemDialogComponent.new(custom_field: @custom_field,
- hierarchy_item: @hierarchy_item)
+ respond_with_dialog DeleteItemDialogComponent.new(custom_field: @custom_field, hierarchy_item: @active_item)
end
private
+ def item_service
+ ::CustomFields::Hierarchy::HierarchicalItemService.new
+ end
+
def item_input
- input = { parent: @custom_field.hierarchy_root, label: params[:label] }
- input[:short] = params[:short] unless params[:short].empty?
+ input = { parent: @active_item, label: params[:label] }
+ input[:short] = params[:short] if params[:short].present?
input
end
- def add_errors_to_new_form(validation_result)
+ def add_errors_to_form(validation_result)
+ @new_item = ::CustomField::Hierarchy::Item.new(parent: @active_item, **validation_result.to_h)
validation_result.errors(full: true).to_h.each do |attribute, errors|
- @custom_field.errors.add(attribute, errors.join(", "))
+ @new_item.errors.add(attribute, errors.join(", "))
end
-
- new_item_form_data = { show: true, label: validation_result[:label], short: validation_result[:short] }
- update_via_turbo_stream(component: ItemsComponent.new(custom_field: @custom_field, new_item_form_data:),
- status: :unprocessable_entity)
end
def add_errors_to_edit_form(validation_result)
+ @active_item.assign_attributes(**validation_result.to_h.slice(:label, :short))
+
validation_result.errors(full: true).to_h.each do |attribute, errors|
- @hierarchy_item.errors.add(attribute, errors.join(", "))
+ @active_item.errors.add(attribute, errors.join(", "))
end
-
- edit_item_form_data = { show: true, label: validation_result[:label], short: validation_result[:short] }
- update_via_turbo_stream(
- component: ItemComponent.new(custom_field: @custom_field, hierarchy_item: @hierarchy_item, edit_item_form_data:),
- status: :unprocessable_entity
- )
end
- def find_model_object(object_id = :custom_field_id)
- super
+ def find_model_object
+ @object = CustomField.hierarchy_root_and_children.find(params[:custom_field_id])
@custom_field = @object
+ rescue ActiveRecord::RecordNotFound
+ render_404
end
- def find_custom_field_and_item
- @custom_field = CustomField.find(params[:custom_field_id])
- @hierarchy_item = CustomField::Hierarchy::Item.find(params[:id])
+ def find_active_item
+ @active_item = if params[:id].present?
+ CustomField::Hierarchy::Item.including_children.find(params[:id])
+ else
+ @object.hierarchy_root
+ end
rescue ActiveRecord::RecordNotFound
render_404
end
diff --git a/app/forms/custom_fields/hierarchy/item_form.rb b/app/forms/custom_fields/hierarchy/item_form.rb
index e75cb4ea48b..988c3a3b0a3 100644
--- a/app/forms/custom_fields/hierarchy/item_form.rb
+++ b/app/forms/custom_fields/hierarchy/item_form.rb
@@ -34,16 +34,17 @@ module CustomFields
input_group.text_field(
name: :label,
label: "Label",
- value: @label,
+ value: @target_item.label,
visually_hide_label: true,
required: true,
placeholder: I18n.t("custom_fields.admin.items.placeholder.label"),
validation_message: validation_message_for(:label)
)
+
input_group.text_field(
name: :short,
label: "Short",
- value: @short,
+ value: @target_item.short,
visually_hide_label: true,
full_width: false,
required: false,
@@ -56,25 +57,34 @@ module CustomFields
tag: :a,
label: I18n.t(:button_cancel),
scheme: :default,
- data: { turbo_stream: true },
- href: url_helpers.custom_field_items_path(@custom_field))
+ data: { turbo_target: "admin-custom-fields-hierarchy-items-component" },
+ href: cancel_href)
button_group.submit(name: :submit, label: I18n.t(:button_save), scheme: :primary)
end
end
- def initialize(custom_field:, hierarchy_item:, label:, short:)
+ # @param target_item [CustomField::Hierarchy::Item] item that will be acted upon
+ def initialize(target_item:)
super()
- @custom_field = custom_field
- @hierarchy_item = hierarchy_item
- @label = label
- @short = short
+ @target_item = target_item
end
private
+ def root
+ @root ||= @target_item.parent.root
+ end
+
+ def cancel_href
+ if @target_item.parent.root?
+ url_helpers.custom_field_items_path(root.custom_field_id)
+ else
+ url_helpers.custom_field_item_path(root.custom_field_id, @target_item.parent)
+ end
+ end
+
def validation_message_for(attribute)
- @hierarchy_item.errors.messages_for(attribute).to_sentence.presence ||
- @custom_field.errors.messages_for(attribute).to_sentence.presence
+ @target_item.errors.messages_for(attribute).to_sentence.presence
end
end
end
diff --git a/app/views/admin/custom_fields/hierarchy/items/show.html.erb b/app/views/admin/custom_fields/hierarchy/items/edit.html.erb
similarity index 88%
rename from app/views/admin/custom_fields/hierarchy/items/show.html.erb
rename to app/views/admin/custom_fields/hierarchy/items/edit.html.erb
index 4bff0023c4e..647a0e468ee 100644
--- a/app/views/admin/custom_fields/hierarchy/items/show.html.erb
+++ b/app/views/admin/custom_fields/hierarchy/items/edit.html.erb
@@ -31,6 +31,4 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field, selected: :items)) %>
-<%= turbo_frame_tag :hierarchy_list, data: { turbo_action: :advance } do %>
- <%= render(Admin::CustomFields::Hierarchy::ItemsComponent.new(item: @hierarchy_item)) %>
-<% end %>
+<%= render(Admin::CustomFields::Hierarchy::ItemComponent.new(item: @active_item, show_edit_form: true)) %>
diff --git a/app/views/admin/custom_fields/hierarchy/items/index.html.erb b/app/views/admin/custom_fields/hierarchy/items/index.html.erb
index f491a1448b0..b9b6d5af06f 100644
--- a/app/views/admin/custom_fields/hierarchy/items/index.html.erb
+++ b/app/views/admin/custom_fields/hierarchy/items/index.html.erb
@@ -31,6 +31,4 @@ See COPYRIGHT and LICENSE files for more details.
<%= render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field, selected: :items)) %>
-<%= turbo_frame_tag :hierarchy_list, data: { turbo_action: :advance } do %>
- <%= render(Admin::CustomFields::Hierarchy::ItemsComponent.new(custom_field: @custom_field)) %>
-<% end %>
+<%= render(Admin::CustomFields::Hierarchy::ItemsComponent.new(item: @active_item)) %>
diff --git a/app/views/admin/custom_fields/hierarchy/items/new.html.erb b/app/views/admin/custom_fields/hierarchy/items/new.html.erb
new file mode 100644
index 00000000000..9980df69e41
--- /dev/null
+++ b/app/views/admin/custom_fields/hierarchy/items/new.html.erb
@@ -0,0 +1,34 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<% html_title t(:label_administration), "#{CustomField.model_name.human} #{h @custom_field.name}", t(:label_item_plural) %>
+
+<%= render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field, selected: :items)) %>
+
+<%= render(Admin::CustomFields::Hierarchy::ItemsComponent.new(item: @active_item, new_item: @new_item)) %>
diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb
index e1401e38cea..0895f2c65f5 100644
--- a/app/views/layouts/base.html.erb
+++ b/app/views/layouts/base.html.erb
@@ -40,7 +40,6 @@ See COPYRIGHT and LICENSE files for more details.
<meta name="current_menu_item" content="<%= current_menu_item %>"/>
<%# Disable prefetching while we have data-turbo=false on body %>
<meta name="turbo-prefetch" content="false">
- <meta name="turbo-refresh-method" content="morph">
</head>
<body
class="<%= body_css_classes %> __overflowing_element_container __overflowing_body"
diff --git a/config/routes.rb b/config/routes.rb
index 9dac6ae20b7..e7a185ba077 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -172,14 +172,9 @@ Rails.application.routes.draw do
scope module: :admin do
scope module: :custom_fields do
- resources :projects,
- controller: "/admin/custom_fields/custom_field_projects",
- only: %i[index new create]
- resource :project,
- controller: "/admin/custom_fields/custom_field_projects",
- only: :destroy
- resources :items,
- controller: "/admin/custom_fields/hierarchy/items" do
+ resources :projects, controller: "/admin/custom_fields/custom_field_projects", only: %i[index new create]
+ resource :project, controller: "/admin/custom_fields/custom_field_projects", only: :destroy
+ resources :items, controller: "/admin/custom_fields/hierarchy/items" do
get :deletion_dialog, on: :member
get :new_child, on: :member, action: :new
post :new_child, on: :member, action: :create