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
[#64557] update tree view, when cf hierarchy items are updated
Eric Schubertf2c335883399
diff --git a/app/components/admin/custom_fields/hierarchy/item_form_component.rb b/app/components/admin/custom_fields/hierarchy/item_form_component.rbindex 816ff30c795..3df11f8ccab 100644--- a/app/components/admin/custom_fields/hierarchy/item_form_component.rb+++ b/app/components/admin/custom_fields/hierarchy/item_form_component.rb@@ -36,7 +36,7 @@ module Admindef item_optionsoptions = { url:, method: http_verb, data: { test_selector: "op-custom-fields--new-item-form" } }- options[:data][:turbo_frame] = ItemsComponent.wrapper_key if model.new_record?+ options[:data][:turbo_frame] = ItemsComponent.wrapper_keyoptionsenddiff --git a/app/components/admin/custom_fields/hierarchy/items_component.html.erb b/app/components/admin/custom_fields/hierarchy/items_component.html.erbindex e26ba1a85e6..50c30bb2fb1 100644--- a/app/components/admin/custom_fields/hierarchy/items_component.html.erb+++ b/app/components/admin/custom_fields/hierarchy/items_component.html.erb@@ -31,62 +31,73 @@ 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,- leading_icon: :plus,- label: t(:label_item),- href: new_item_path) do- I18n.t(:label_item)+ render(Primer::Alpha::Layout.new(stacking_breakpoint: :md, classes: "custom-fields-hierarchy-page")) do |content|+ content.with_main do+ flex_layout do |container|+ container.with_row do+ render(Primer::OpenProject::SubHeader.new) do |subheader|+ subheader.with_action_button(+ tag: :a,+ scheme: :primary,+ leading_icon: :plus,+ label: t(:label_item),+ href: new_item_path+ ) do+ I18n.t(:label_item)+ end+ endend- end- end- container.with_row(mb: 3) do- render(Primer::Beta::BorderBox.new) do |box|- box.with_header { item_header }- if children.empty?- box.with_row do- render(Primer::Beta::Blankslate.new(test_selector: "op-custom-fields--hierarchy-items-blankslate")) do |component|- component.with_visual_icon(icon: blank_icon)+ container.with_row(mb: 3) do+ render(Primer::Beta::BorderBox.new) do |box|+ box.with_header { item_header }++ if children.empty?+ box.with_row do+ render(Primer::Beta::Blankslate.new(test_selector: "op-custom-fields--hierarchy-items-blankslate")) do |component|+ component.with_visual_icon(icon: blank_icon)- component.with_heading(tag: :h3).with_content(I18n.t(blank_header_text))- component.with_description { I18n.t(blank_description_text) }- component.with_primary_action(tag: :a, href: new_item_path) do |button|- button.with_leading_visual_icon(icon: :plus)- I18n.t(:label_item)+ component.with_heading(tag: :h3).with_content(I18n.t(blank_header_text))+ component.with_description { I18n.t(blank_description_text) }+ component.with_primary_action(tag: :a, href: new_item_path) do |button|+ button.with_leading_visual_icon(icon: :plus)+ I18n.t(:label_item)+ end+ endend- end- end- else- children.each do |item|- drag_controls = if item.persisted?- {- "data-controller": "admin--hierarchy-item",- "data-action": "dragstart->admin--hierarchy-item#dragstart+ else+ children.each do |item|+ drag_controls = if item.persisted?+ {+ "data-controller": "admin--hierarchy-item",+ "data-action": "dragstart->admin--hierarchy-item#dragstartdragenter->admin--hierarchy-item#dragenterdragleave->admin--hierarchy-item#dragleavedragend->admin--hierarchy-item#dragenddrop->admin--hierarchy-item#drop",- "data-hierarchy-item-id": item.id,- "data-sort-order": item.sort_order,- "data-frame-id": Admin::CustomFields::Hierarchy::ItemsComponent.wrapper_key,- "data-move-url": move_custom_field_item_url(root.custom_field_id, item),- "data-index-url": custom_field_item_url(root.custom_field_id, item.parent)- }- else- {}- end+ "data-hierarchy-item-id": item.id,+ "data-sort-order": item.sort_order,+ "data-frame-id": Admin::CustomFields::Hierarchy::ItemsComponent.wrapper_key,+ "data-move-url": move_custom_field_item_url(root.custom_field_id, item),+ "data-index-url": custom_field_item_url(root.custom_field_id, item.parent)+ }+ else+ {}+ end- box.with_row(**drag_controls) do- render Admin::CustomFields::Hierarchy::ItemComponent.new(item: item)+ box.with_row(**drag_controls) do+ render Admin::CustomFields::Hierarchy::ItemComponent.new(item: item)+ end+ endendendendendend++ content.with_sidebar(row_placement: :start, col_placement: :start, border: true, border_bottom: 0, p: 3, classes: "custom-fields-hierarchy-page--sidebar") do+ render Admin::CustomFields::Hierarchy::TreeViewComponent.new(custom_field: root.custom_field, active_item: model)+ endendend%>diff --git a/app/components/admin/custom_fields/hierarchy/tree_view_component.rb b/app/components/admin/custom_fields/hierarchy/tree_view_component.rbindex e99ab023524..fee4975405b 100644--- a/app/components/admin/custom_fields/hierarchy/tree_view_component.rb+++ b/app/components/admin/custom_fields/hierarchy/tree_view_component.rb@@ -50,7 +50,7 @@ module Adminif child_hash.empty?tree.with_leaf(**item_options(item))else- expanded = child_hash.any? { |child, _| current?(child) }+ expanded = current?(item) || child_hash.any? { |child, _| current?(child) }tree.with_sub_tree(expanded: expanded, **item_options(item)) do |sub_tree|add_sub_tree(sub_tree, child_hash)diff --git a/app/views/admin/custom_fields/hierarchy/items/index.html.erb b/app/views/admin/custom_fields/hierarchy/items/index.html.erbindex a3c594e1347..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,14 +31,4 @@ See COPYRIGHT and LICENSE files for more details.<%= render(Admin::CustomFields::EditFormHeaderComponent.new(custom_field: @custom_field, selected: :items)) %>-<%=- render(Primer::Alpha::Layout.new(stacking_breakpoint: :md, classes: "custom-fields-hierarchy-page")) do |content|- content.with_main do- render(Admin::CustomFields::Hierarchy::ItemsComponent.new(item: @active_item))- end-- content.with_sidebar(row_placement: :start, col_placement: :start, border: true, border_bottom: 0, p: 3, classes: "custom-fields-hierarchy-page--sidebar") do- render(Admin::CustomFields::Hierarchy::TreeViewComponent.new(custom_field: @custom_field, active_item: @active_item))- end- end-%>+<%= render(Admin::CustomFields::Hierarchy::ItemsComponent.new(item: @active_item)) %>