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
preserve UI state when dragging agenda items
Jonas Jabarib932b64bc255
diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex 439231d2cd7..3d956864803 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -253,6 +253,35 @@ module Meetingsendend+ def move_item_within_section_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item)+ move_item_via_turbo_stream(meeting_agenda_item:)++ # update the displayed time slots of all other items in the section+ update_show_items_of_section_via_turbo_stream(meeting_section: meeting_agenda_item.meeting_section)+ end++ def move_item_to_other_section_via_turbo_stream(old_section:, current_section:, meeting_agenda_item: @meeting_agenda_item)+ move_item_via_turbo_stream(meeting_agenda_item:)++ # update the old section+ update_section_header_via_turbo_stream(meeting_section: old_section)++ if old_section.agenda_items.empty?+ update_section_via_turbo_stream(meeting_section: old_section)+ else+ update_show_items_of_section_via_turbo_stream(meeting_section: old_section)+ end++ # update the new section+ update_section_header_via_turbo_stream(meeting_section: current_section)++ if current_section.agenda_items.count == 1+ update_section_via_turbo_stream(meeting_section: current_section)+ else+ update_show_items_of_section_via_turbo_stream(meeting_section: current_section)+ end+ end+def move_item_via_turbo_stream(meeting_agenda_item: @meeting_agenda_item)# Note: The `remove_component` and the `component` are pointing to the same# component, but we still need to instantiate them separately, otherwise re-adding@@ -262,19 +291,18 @@ module Meetingscomponent = MeetingAgendaItems::ItemComponent.new(state: :show, meeting_agenda_item:)- target_component = if @meeting_agenda_item.lower_item+ target_component = if meeting_agenda_item.lower_itemMeetingAgendaItems::ItemComponent.new(state: :show,- meeting_agenda_item: @meeting_agenda_item.lower_item+ meeting_agenda_item: meeting_agenda_item.lower_item)elseMeetingSections::ShowComponent.new(- meeting_section: @meeting_agenda_item.meeting_section+ meeting_section: meeting_agenda_item.meeting_section)endadd_before_via_turbo_stream(component:, target_component:)- update_show_items_of_section_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)enddef render_base_error_in_flash_message_via_turbo_stream(errors)@@ -283,6 +311,12 @@ module Meetingsendend+ def update_section_headers_via_turbo_stream(meeting: @meeting)+ meeting.sections.each do |meeting_section|+ update_section_header_via_turbo_stream(meeting_section:)+ end+ end+def update_section_header_via_turbo_stream(meeting_section: @meeting_section, state: :show)update_via_turbo_stream(component: MeetingSections::HeaderComponent.new(diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 1c94b71951c..c6772387d7e 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -162,7 +162,14 @@ class MeetingAgendaItemsController < ApplicationController)if call.success?- update_all_via_turbo_stream # TODO: more specific UI update+ if call.result[:section_changed]+ move_item_to_other_section_via_turbo_stream(+ old_section: call.result[:old_section],+ current_section: call.result[:current_section]+ )+ else+ move_item_within_section_via_turbo_stream+ endelsegeneric_call_failure_response(call)end