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

Move the button to the top

Marcello Rochaeb5d4bcf41f1
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 2339427ab7a..ad31202add3 100644
--- a/app/components/admin/custom_fields/hierarchy/items_component.html.erb
+++ b/app/components/admin/custom_fields/hierarchy/items_component.html.erb
@@ -30,6 +30,14 @@ See COPYRIGHT and LICENSE files for more details.
<%=
component_wrapper(tag: "turbo-frame", refresh: :morph, data: { turbo_action: :advance }) do
flex_layout do |container|
+ container.with_row do
+ render(Primer::OpenProject::SubHeader.new) do |subheader|
+ subheader.with_action_button(tag: :a, scheme: :primary, href: new_item_path) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ I18n.t(:label_item)
+ end
+ end
+ end
container.with_row(mb: 3) do
render(Primer::Beta::BorderBox.new) do |box|
box.with_header { item_header }
@@ -53,7 +61,7 @@ See COPYRIGHT and LICENSE files for more details.
box.with_footer(test_selector: "op-custom-fields--new-item-form") do
render Admin::CustomFields::Hierarchy::ItemFormComponent.new(
target_item: @new_item,
- url: new_child_custom_field_item_path(model.root.custom_field_id, model),
+ url: new_child_custom_field_item_path(root.custom_field_id, model),
method: :post
)
end
@@ -61,15 +69,6 @@ See COPYRIGHT and LICENSE files for more details.
end
end
end
-
- container.with_row do
- render Primer::Beta::Button.new(scheme: :primary,
- tag: :a,
- 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
- end
end
end
%>
diff --git a/app/components/admin/custom_fields/hierarchy/items_component.rb b/app/components/admin/custom_fields/hierarchy/items_component.rb
index 65925a95263..94c31d83aef 100644
--- a/app/components/admin/custom_fields/hierarchy/items_component.rb
+++ b/app/components/admin/custom_fields/hierarchy/items_component.rb
@@ -45,9 +45,11 @@ module Admin
def show_new_item_form? = @new_item
def root
- return model if model.root?
+ @root ||= model.root? ? model : model.root
+ end
- @root ||= model.root
+ def new_item_path
+ new_child_custom_field_item_path(root.custom_field_id, model)
end
def item_header