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
Normalizes form URL
Marcello Rochafbe039332593
diff --git a/app/components/admin/custom_fields/hierarchy/item_component.html.erb b/app/components/admin/custom_fields/hierarchy/item_component.html.erbindex eabc0eea2cc..8cf7afea3a1 100644--- a/app/components/admin/custom_fields/hierarchy/item_component.html.erb+++ b/app/components/admin/custom_fields/hierarchy/item_component.html.erb@@ -29,15 +29,14 @@ See COPYRIGHT and LICENSE files for more details.<%=component_wrapper(tag: "turbo-frame", refresh: :morph) do- if show_edit_form?- render Admin::CustomFields::Hierarchy::ItemFormComponent.new(- target_item: model,- url: custom_field_item_path(@root.custom_field_id, model),- method: :put- )+ if show_form?+ render Admin::CustomFields::Hierarchy::ItemFormComponent.new(model)elseflex_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::OpenProject::DragHandle.new)+ enditem_information.with_column(mr: 2) dorender(Primer::Beta::Link.new(href: custom_field_item_path(@root.custom_field_id, model), underline: false)) dorender(Primer::Beta::Text.new(font_weight: :bold)) { model.label }@@ -62,8 +61,7 @@ See COPYRIGHT and LICENSE files for more details.menu.with_show_button(icon: "kebab-horizontal",scheme: :invisible,"aria-label": I18n.t("custom_fields.admin.items.actions"))- edit_action_item(menu)- deletion_action_item(menu)+ menu_items(menu)endendenddiff --git a/app/components/admin/custom_fields/hierarchy/item_component.rb b/app/components/admin/custom_fields/hierarchy/item_component.rbindex 980fc9307e4..579a16e8a65 100644--- a/app/components/admin/custom_fields/hierarchy/item_component.rb+++ b/app/components/admin/custom_fields/hierarchy/item_component.rb@@ -38,7 +38,7 @@ module Admindef initialize(item:, show_edit_form: false)super(item)@show_edit_form = show_edit_form- @root = item.root+ @root = item.root || item.parent.rootenddef wrapper_uniq_by@@ -49,12 +49,24 @@ module Admin"(#{model.short})"end- def show_edit_form? = @show_edit_form+ def show_form? = @show_edit_form || model.new_record?def children_countI18n.t("custom_fields.admin.hierarchy.subitems", count: model.children.count)end+ def menu_items(menu)+ edit_action_item(menu)+ menu.with_divider+ add_above_action_item(menu)+ add_below_action_item(menu)+ add_sub_item_action_item(menu)+ menu.with_divider+ deletion_action_item(menu)+ end++ private+def deletion_action_item(menu)menu.with_item(label: I18n.t(:button_delete),scheme: :danger,@@ -72,6 +84,33 @@ module Adminitem.with_leading_visual_icon(icon: :pencil)endend++ def add_above_action_item(menu)+ menu.with_item(+ label: I18n.t(:button_add_item_above),+ tag: :a,+ content_arguments: { data: { turbo_frame: ItemsComponent.wrapper_key } },+ href: new_child_custom_field_item_path(@root.custom_field_id, model.parent, position: model.sort_order)+ ) { _1.with_leading_visual_icon(icon: "fold-up") }+ end++ def add_below_action_item(menu)+ menu.with_item(+ label: I18n.t(:button_add_item_below),+ tag: :a,+ content_arguments: { data: { turbo_frame: ItemsComponent.wrapper_key } },+ href: new_child_custom_field_item_path(@root.custom_field_id, model.parent, position: model.sort_order + 1)+ ) { _1.with_leading_visual_icon(icon: "fold-down") }+ end++ def add_sub_item_action_item(menu)+ menu.with_item(+ label: I18n.t(:button_add_sub_item),+ tag: :a,+ content_arguments: { data: { turbo_frame: ItemsComponent.wrapper_key } },+ href: new_child_custom_field_item_path(@root.custom_field_id, model)+ ) { _1.with_leading_visual_icon(icon: "op-arrow-in") }+ endendendenddiff --git a/app/components/admin/custom_fields/hierarchy/item_form_component.rb b/app/components/admin/custom_fields/hierarchy/item_form_component.rbindex bf1ce2b250a..49db3f4deb5 100644--- a/app/components/admin/custom_fields/hierarchy/item_form_component.rb+++ b/app/components/admin/custom_fields/hierarchy/item_form_component.rb@@ -47,7 +47,7 @@ module Admindef urlif model.new_record?- new_child_custom_field_item_path(root.custom_field_id, model.parent, position: model.sort_order)+ new_child_custom_field_item_path(root.custom_field_id, model.parent)elsecustom_field_item_path(root.custom_field_id, model)enddiff --git a/app/components/admin/custom_fields/hierarchy/items_component.rb b/app/components/admin/custom_fields/hierarchy/items_component.rbindex b505999f19c..1b519236754 100644--- a/app/components/admin/custom_fields/hierarchy/items_component.rb+++ b/app/components/admin/custom_fields/hierarchy/items_component.rb@@ -45,7 +45,7 @@ module Adminenddef new_item_path- position = children.any? ? children.last.sort_order + 1 : 0+ position = model.children.any? ? children.last.sort_order + 1 : 0new_child_custom_field_item_path(root.custom_field_id, model, position:)enddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex a752108b58e..d59da529359 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1474,6 +1474,9 @@ en:button_actions: "Actions"button_add: "Add"button_add_comment: "Add comment"+ button_add_item_above: "Add item above"+ button_add_item_below: "Add item below"+ button_add_sub_item: "Add sub-item"button_add_member: Add memberbutton_add_watcher: "Add watcher"button_annotate: "Annotate"