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
preserving as much of the UI state as possible when changing section positions
Jonas Jabari7e5ab5c9da67
diff --git a/modules/meeting/app/components/meeting_sections/show_component.html.erb b/modules/meeting/app/components/meeting_sections/show_component.html.erbindex a5db188bd6c..4fe0a73f24f 100644--- a/modules/meeting/app/components/meeting_sections/show_component.html.erb+++ b/modules/meeting/app/components/meeting_sections/show_component.html.erb@@ -1,6 +1,6 @@<%=component_wrapper(class: "op-meeting-section-container", data: { test_selector: "meeting-section-container-#{@meeting_section.id}" }.merge(draggable_item_config)) do- render(Primer::Beta::BorderBox.new(mt: top_margin, data: drag_and_drop_target_config)) do |component|+ render(Primer::Beta::BorderBox.new(mt: 3, data: drag_and_drop_target_config)) do |component|if render_section_wrapper?component.with_header(font_weight: :bold, pl: 0) dorender(MeetingSections::HeaderComponent.new(meeting_section: @meeting_section))diff --git a/modules/meeting/app/components/meeting_sections/show_component.rb b/modules/meeting/app/components/meeting_sections/show_component.rbindex 9fc298faf58..6cef52287b4 100644--- a/modules/meeting/app/components/meeting_sections/show_component.rb+++ b/modules/meeting/app/components/meeting_sections/show_component.rb@@ -34,7 +34,7 @@ module MeetingSectionswith_collection_parameter :meeting_section- def initialize(meeting_section:, first_and_last: [], form_hidden: true, form_type: :simple)+ def initialize(meeting_section:, first_and_last: [], form_hidden: true, form_type: :simple, insert_target_modified: true)super@meeting = meeting_section.meeting@@ -43,6 +43,7 @@ module MeetingSections@first_and_last = first_and_last@form_hidden = form_hidden@form_type = form_type+ @insert_target_modified = insert_target_modifiedendprivate@@ -52,7 +53,7 @@ module MeetingSectionsenddef insert_target_modified?- true+ @insert_target_modifiedenddef insert_target_modifier_id@@ -72,14 +73,6 @@ module MeetingSections@meeting_agenda_items.empty? && @form_hidden && editable?end- def top_margin- if @meeting_section.id == @first_and_last&.first&.id- 1- else- 3- end- end-def draggable_item_config{"draggable-id": @meeting_section.id,diff --git a/modules/meeting/app/components/meetings/sidebar/details_component.html.erb b/modules/meeting/app/components/meetings/sidebar/details_component.html.erbindex a14094b5c16..f95c064a587 100644--- a/modules/meeting/app/components/meetings/sidebar/details_component.html.erb+++ b/modules/meeting/app/components/meetings/sidebar/details_component.html.erb@@ -1,6 +1,6 @@<%=component_wrapper do- flex_layout do |details_container|+ flex_layout(mt: 3) do |details_container|details_container.with_row doflex_layout(align_items: :center, justify_content: :space_between) do |heading|heading.with_column(flex: 1) dodiff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex 3d956864803..f1ffebcc29e 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -369,6 +369,36 @@ module Meetingsendend+ def move_section_via_turbo_stream(meeting_section: @meeting_section)+ # Note: The `remove_component` and the `component` are pointing to the same+ # component, but we still need to instantiate them separately, otherwise re-adding+ # of the item will render and empty component.+ remove_component = MeetingSections::ShowComponent.new(meeting_section:)+ remove_via_turbo_stream(component: remove_component)++ component = MeetingSections::ShowComponent.new(meeting_section:)++ if meeting_section.lower_item+ add_before_via_turbo_stream(+ component:,+ target_component: MeetingSections::ShowComponent.new(+ meeting_section: meeting_section.lower_item,+ insert_target_modified: false+ # insert target is modified for agenda items in this section, but not for sections+ )+ )+ else+ append_via_turbo_stream(+ component: MeetingSections::ShowComponent.new(+ meeting_section:+ ),+ target_component: MeetingAgendaItems::ListComponent.new(+ meeting: meeting_section.meeting+ )+ )+ end+ end+def update_all_via_turbo_streamupdate_header_component_via_turbo_streamupdate_sidebar_component_via_turbo_streamdiff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex c6772387d7e..2a4c5859ae4 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -183,7 +183,7 @@ class MeetingAgendaItemsController < ApplicationController.call(move_to: params[:move_to]&.to_sym)if call.success?- move_item_via_turbo_stream+ move_item_within_section_via_turbo_streamupdate_header_component_via_turbo_streamelsegeneric_call_failure_response(call)diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rbindex 641e7571b7c..afd8921b0d6 100644--- a/modules/meeting/app/controllers/meeting_sections_controller.rb+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb@@ -125,10 +125,11 @@ class MeetingSectionsController < ApplicationController.call(position: params[:position].to_i)if call.success?- update_list_via_turbo_stream+ # the DOM is already updated on the client-side through the drag+ # in order to preserve an edit state within the section, we don't send a server-side rendered updateupdate_header_component_via_turbo_stream- # having a more specific update is not that easy as the reordering impacts- # the time slot calculations of potentially all agenda items+ # update all time slots as a section position change affects potentially all time slots+ update_show_items_via_turbo_streamelsegeneric_call_failure_response(call)end@@ -142,10 +143,13 @@ class MeetingSectionsController < ApplicationController.call(move_to: params[:move_to]&.to_sym)if call.success?- update_list_via_turbo_stream+ move_section_via_turbo_stream+ # CODE MAINTENANCE: edit state within the moved section potentially gets lost+ # unlike at the drop action, we need to send server-side rendered updates in order to reflect the new position+ # thus an edit state inside the section gets lostupdate_header_component_via_turbo_stream- # having a more specific update is not that easy as the reordering impacts- # the time slot calculations of potentially all agenda items+ # update all time slots as a section position change affects potentially all time slots+ update_show_items_via_turbo_streamelsegeneric_call_failure_response(call)end