Skip to content

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

Use current_occurrence directly in 'move' actions

Mir Bhatiad04c84c9ff0d
diff --git a/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts b/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts
index b0dac604060..cff28f88e42 100644
--- a/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/meetings/add-params.controller.ts
@@ -34,14 +34,12 @@ import { appendCollapsedState } from '../../../helpers/collapsible-helper';
export default class extends ApplicationController {
private turboRequests:TurboRequestsService;
- static targets = ['container'];
-
- declare readonly containerTarget:HTMLElement;
static metaNames = ['csrf-token'];
declare readonly csrfToken:string;
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
async connect() {
useMeta(this, { suffix: false });
const context = await window.OpenProject.getPluginContext();
@@ -55,7 +53,6 @@ export default class extends ApplicationController {
const url = new URL(target.dataset.href!, window.location.origin);
appendCollapsedState(url.searchParams);
- url.searchParams.append('current_meeting_id', this.containerTarget.dataset.meeting!);
void this
.turboRequests
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb b/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb
index 83d60ba1d01..637f37e63a0 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/container_component.html.erb
@@ -1,5 +1,5 @@
<%=
- component_wrapper(data: wrapper_data_attributes) do
+ component_wrapper do
if show?
flex_layout(mb: 3) do |flex|
flex.with_row(mt: 3) do
diff --git a/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb b/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb
index ace1fc7a950..0b1979a7651 100644
--- a/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb
+++ b/modules/meeting/app/components/meeting_sections/backlogs/container_component.rb
@@ -47,12 +47,5 @@ module MeetingSections
def show?
end
-
- def wrapper_data_attributes
- {
- "meetings--add-params-target": "container",
- meeting: @meeting.id
- }
- end
end
end
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index 72650648943..c8a692fda82 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -184,38 +184,21 @@ class MeetingAgendaItemsController < ApplicationController
respond_with_turbo_streams
end
- def drop # rubocop:disable Metrics/AbcSize
+ def drop
current_occurrence = Meeting.find_by(id: params[:current_occurrence])
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)
+ .call(meeting: current_occurrence, meeting_section: nil)
else
::MeetingAgendaItems::DropService
.new(user: current_user, meeting_agenda_item: @meeting_agenda_item)
.call(target_id: @target_id, position: @position)
end
- if call.success?
- old_section, current_section, section_changed = assign_drop_results(call, meeting_agenda_item_section)
-
- if section_changed
- move_item_to_other_section_via_turbo_stream(
- old_section:,
- current_section:,
- collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed]),
- current_occurrence:
- )
- else
- move_item_within_section_via_turbo_stream(current_occurrence:)
- end
- else
- generic_call_failure_response(call)
- end
-
- respond_with_turbo_streams
+ handle_agenda_item_update_on_move(call, meeting_agenda_item_section, current_occurrence:)
end
def move
@@ -261,7 +244,8 @@ class MeetingAgendaItemsController < ApplicationController
end
def move_to_section_dialog
- meeting = params[:current_meeting_id].present? ? Meeting.find(params[:current_meeting_id]) : @meeting_agenda_item.meeting
+ meeting = params[:current_occurrence].present? ? Meeting.find(params[:current_occurrence]) : @meeting_agenda_item.meeting
+
respond_with_dialog MeetingAgendaItems::MoveToSectionDialogComponent.new(
agenda_item: @meeting_agenda_item,
meeting:
@@ -276,23 +260,7 @@ class MeetingAgendaItemsController < ApplicationController
.new(user: current_user, model: @meeting_agenda_item)
.call(meeting_section:)
- if call.success?
- old_section, current_section, section_changed = assign_drop_results(call, meeting_agenda_item_section)
-
- if section_changed
- move_item_to_other_section_via_turbo_stream(
- old_section:,
- current_section:,
- collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed])
- )
- else
- move_item_within_section_via_turbo_stream
- end
- else
- generic_call_failure_response(call)
- end
-
- respond_with_turbo_streams
+ handle_agenda_item_update_on_move(call, meeting_agenda_item_section, current_occurrence: nil)
end
private
@@ -371,7 +339,7 @@ class MeetingAgendaItemsController < ApplicationController
def assign_drop_params # rubocop:disable Metrics/AbcSize
@target_id, @position =
if params[:type] == "to_current"
- meeting = Meeting.find_by(id: params[:current_meeting_id])
+ meeting = Meeting.find_by(id: params[:current_occurrence])
section = meeting.sections.reorder(position: :desc).first
[section&.id, section&.last_position]
elsif params[:type] == "to_backlog"
@@ -394,4 +362,25 @@ class MeetingAgendaItemsController < ApplicationController
[old_section, current_section, section_changed]
end
+
+ def handle_agenda_item_update_on_move(call, meeting_agenda_item_section, current_occurrence:)
+ if call.success?
+ old_section, current_section, section_changed = assign_drop_results(call, meeting_agenda_item_section)
+
+ if section_changed
+ move_item_to_other_section_via_turbo_stream(
+ old_section:,
+ current_section:,
+ collapsed: ActiveModel::Type::Boolean.new.cast(params[:collapsed]),
+ current_occurrence:
+ )
+ else
+ move_item_within_section_via_turbo_stream(current_occurrence:)
+ end
+ else
+ generic_call_failure_response(call)
+ end
+
+ respond_with_turbo_streams
+ end
end
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
index 3ba4cb7cfa7..51f582df21a 100644
--- a/modules/meeting/spec/support/pages/meetings/show.rb
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -369,8 +369,10 @@ module Pages::Meetings
def expect_empty_backlog
within_backlog do
- expect(page).to have_text("Drag items here or create a new one")
- expect(page).to have_button("Add")
+ retry_block do
+ expect(page).to have_text("Drag items here or create a new one")
+ expect(page).to have_button("Add")
+ end
end
end