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
Fix error when moving item to empty meeting
Mir Bhatia4cfe606a9eff
diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex da4bf5a3cd3..3b9d7855ba9 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -285,15 +285,17 @@ module Meetings# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexitydef move_item_to_other_section_via_turbo_stream(old_section:, current_section:, meeting_agenda_item: @meeting_agenda_item,collapsed: nil)- move_item_via_turbo_stream(meeting_agenda_item:)+ # old_section.meeting and current_section.meeting are different when items are moved to/from a series backlog+ current_section_meeting = current_section.meeting+ old_section_meeting = old_section.meeting- # Update the header for updated timestamp- update_header_component_via_turbo_stream+ move_item_via_turbo_stream(meeting_agenda_item:)# update the old sectionif old_section.backlog?- update_backlog_via_turbo_stream(meeting: current_section.meeting, collapsed:)+ update_backlog_via_turbo_stream(meeting: current_section_meeting, collapsed:)else+ update_header_component_via_turbo_stream(meeting: old_section_meeting)update_section_header_via_turbo_stream(meeting_section: old_section)if old_section.agenda_items.empty?@@ -305,8 +307,13 @@ module Meetings# update the new sectionif current_section.backlog?- update_backlog_via_turbo_stream(meeting: old_section.meeting, collapsed:)+ update_backlog_via_turbo_stream(meeting: old_section_meeting, collapsed:)+ elsif current_section_meeting.sections.count == 1 && current_section_meeting.agenda_items.count == 1+ # Special case when first item is being moved from backlog to empty meeting+ update_list_via_turbo_stream(meeting: current_section_meeting)+ update_header_component_via_turbo_stream(meeting: current_section_meeting)else+ update_header_component_via_turbo_stream(meeting: current_section_meeting)update_section_header_via_turbo_stream(meeting_section: current_section)if current_section.agenda_items.count == 1diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 3eda8a7c3a7..1ff96059ad5 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -174,18 +174,25 @@ class MeetingAgendaItemsController < ApplicationControllerenddef drop # rubocop:disable Metrics/AbcSize- call = ::MeetingAgendaItems::DropService.new(- user: current_user, meeting_agenda_item: @meeting_agenda_item- ).call(- target_id: @target_id,- position: @position- )+ meeting_agenda_item_section = @meeting_agenda_item.meeting_section++ call = if @target_id.nil?+ ::MeetingAgendaItems::UpdateService+ .new(user: current_user, model: @meeting_agenda_item)+ .call(meeting_id: params[:current_meeting_id], meeting_section: nil)+ else+ ::MeetingAgendaItems::DropService+ .new(user: current_user, meeting_agenda_item: @meeting_agenda_item)+ .call(target_id: @target_id, position: @position)+ endif call.success?- if call.result[:section_changed]+ old_section, current_section, section_changed = assign_drop_results(call, meeting_agenda_item_section)++ if section_changedmove_item_to_other_section_via_turbo_stream(- old_section: call.result[:old_section],- current_section: call.result[:current_section],+ old_section:,+ current_section:,collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed]))else@@ -317,4 +324,18 @@ class MeetingAgendaItemsController < ApplicationController[params[:target_id], params[:position]]endend++ def assign_drop_results(call, meeting_agenda_item_section)+ if @target_id.nil?+ old_section = meeting_agenda_item_section+ current_section = call.result.meeting_section+ section_changed = true+ else+ old_section = call.result[:old_section]+ current_section = call.result[:current_section]+ section_changed = call.result[:section_changed]+ end++ [old_section, current_section, section_changed]+ endend