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

Move agenda items to next meeting

Oliver Güntherc219c4672511
diff --git a/app/controllers/concerns/op_turbo/flash_stream_helper.rb b/app/controllers/concerns/op_turbo/flash_stream_helper.rb
index fa743e4e376..64eda29c1da 100644
--- a/app/controllers/concerns/op_turbo/flash_stream_helper.rb
+++ b/app/controllers/concerns/op_turbo/flash_stream_helper.rb
@@ -37,5 +37,27 @@ module OpTurbo
yield(format) if format_block
end
end
+
+ def respond_with_flash_error(message:, status: :unprocessable_entity, &format_block)
+ respond_to do |format|
+ format.turbo_stream do
+ render_error_flash_message_via_turbo_stream(message:)
+ respond_with_turbo_streams(status:)
+ end
+
+ yield(format) if format_block
+ end
+ end
+
+ def respond_with_flash_success(message:, status: :ok, &format_block)
+ respond_to do |format|
+ format.turbo_stream do
+ render_success_flash_message_via_turbo_stream(message:)
+ respond_with_turbo_streams(status:)
+ end
+
+ yield(format) if format_block
+ end
+ end
end
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
index 897e09bf1e0..563231b3eda 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb
@@ -73,6 +73,12 @@
menu.with_divider
move_actions(menu)
end
+
+ if move_to_next_meeting_enabled?
+ menu.with_divider
+ move_to_next_meeting_action_item(menu)
+ end
+
menu.with_divider
copy_action_item(menu)
menu.with_divider
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
index 130d526a593..5297f93cc8f 100644
--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
@@ -34,12 +34,14 @@ module MeetingAgendaItems
include AvatarHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
+ include Redmine::I18n
def initialize(meeting_agenda_item:, first_and_last: [])
super
@meeting_agenda_item = meeting_agenda_item
@meeting = meeting_agenda_item.meeting
+ @series = @meeting.recurring_meeting
@first_and_last = first_and_last
end
@@ -83,6 +85,10 @@ module MeetingAgendaItems
end
+ def recurring_meeting?
+ @series.present?
+ end
+
def edit_action_item(menu)
menu.with_item(label: t("label_edit"),
href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
@@ -124,6 +130,32 @@ module MeetingAgendaItems
end
end
+ def move_to_next_meeting_action_item(menu)
+ return if @meeting.templated?
+ return if @series.nil?
+
+ next_date = @series.next_occurrence(from_time: @meeting.start_time)
+ return if next_date.nil?
+
+ menu.with_item(
+ label: t(:label_agenda_item_move_to_next),
+ href: move_to_next_meeting_agenda_item_path(@meeting_agenda_item.meeting,
+ @meeting_agenda_item,
+ datetime: next_date.iso8601),
+ form_arguments: {
+ method: :post,
+ data: {
+ confirm: t(:text_agenda_item_move_next_meeting,
+ date: format_date(next_date),
+ time: format_time(next_date, include_date: false)),
+ "turbo-stream": true
+ }
+ }
+ ) do |item|
+ item.with_leading_visual_icon(icon: "arrow-right")
+ end
+ end
+
def move_actions(menu)
move_action_item(menu, :highest, t("label_agenda_item_move_to_top"), "move-to-top") unless first?
move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless first?
@@ -169,5 +201,9 @@ module MeetingAgendaItems
"op-uc-container override muted-color"
end
end
+
+ def move_to_next_meeting_enabled?
+ edit_enabled? && @meeting.recurring? && @meeting.recurring_meeting&.next_occurrence.present?
+ 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 0bb1055efc8..4b90018ba0d 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -31,6 +31,7 @@
class MeetingAgendaItemsController < ApplicationController
include AttachableServiceCall
include OpTurbo::ComponentStream
+ include OpTurbo::FlashStreamHelper
include Meetings::AgendaComponentStreams
before_action :set_meeting
@@ -38,6 +39,7 @@ class MeetingAgendaItemsController < ApplicationController
before_action :set_meeting_agenda_item,
except: %i[new cancel_new create]
before_action :authorize
+ before_action :check_recurring_meeting_param, only: %i[move_to_next_meeting]
def new
if @meeting.closed?
@@ -193,8 +195,41 @@ class MeetingAgendaItemsController < ApplicationController
respond_with_turbo_streams
end
+ def move_to_next_meeting # rubocop:disable Metrics/AbcSize
+ next_occurrence = init_next_meeting_occurrence
+ return if next_occurrence.nil?
+
+ update_call = ::MeetingAgendaItems::UpdateService
+ .new(user: current_user, model: @meeting_agenda_item)
+ .call(meeting_id: next_occurrence.id, meeting_section: nil)
+
+ if update_call.success?
+ render_success_flash_message_via_turbo_stream(message: I18n.t(:notice_successful_update))
+ remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)
+ update_header_component_via_turbo_stream
+ respond_with_turbo_streams
+ else
+ respond_with_flash_error(message: call.message)
+ end
+ end
+
private
+ def init_next_meeting_occurrence
+ return @next_occurrence if @next_occurrence.present?
+
+ call = ::RecurringMeetings::InitOccurrenceService
+ .new(user: User.system, recurring_meeting: @series)
+ .call(start_time: @next_meeting_time)
+
+ if call.success?
+ call.result
+ else
+ respond_with_flash_error(message: call.message)
+ nil
+ end
+ end
+
def set_meeting
@meeting = Meeting.find(params[:meeting_id])
@project = @meeting.project # required for authorization via before_action
@@ -227,4 +262,27 @@ class MeetingAgendaItemsController < ApplicationController
# show additional base error message
render_base_error_in_flash_message_via_turbo_stream(call.errors)
end
+
+ def check_recurring_meeting_param
+ unless @meeting.recurring? && @meeting.open?
+ return render_400
+ end
+
+ @next_meeting_time = DateTime.iso8601(params[:datetime]).utc
+ @series = @meeting.recurring_meeting
+
+ render_400 unless @next_meeting_time && @series.occurs_at?(@next_meeting_time)
+ find_existing_occurrence
+ end
+
+ def find_existing_occurrence
+ next_occurrence = @series.scheduled_meetings.find_by(start_time: @next_meeting_time)
+ return if next_occurrence.nil?
+
+ if next_occurrence.cancelled?
+ respond_with_flash_error(message: I18n.t(:text_agenda_item_move_next_meeting_cancelled))
+ else
+ @next_occurrence = next_occurrence.meeting
+ end
+ end
end
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index add00b6aefc..9f53985b45f 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -212,6 +212,8 @@ class RecurringMeeting < ApplicationRecord
schedule.previous_occurrence(from_time)&.to_time
end
+ delegate :occurs_at?, to: :schedule
+
def remaining_occurrences
case end_after
when "specific_date"
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 49fbc163af6..f81a43071e9 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -415,6 +415,7 @@ en:
label_agenda_item_undisclosed_wp: "Work package #%{id} not visible"
label_agenda_item_deleted_wp: "Deleted work package reference"
label_agenda_item_actions: "Agenda items actions"
+ label_agenda_item_move_to_next: "Move to next meeting"
label_agenda_item_move_to_top: "Move to top"
label_agenda_item_move_to_bottom: "Move to bottom"
label_agenda_item_move_up: "Move up"
@@ -472,6 +473,8 @@ en:
text_add_work_package_to_meeting_description: "A work package can be added to one or multiple meetings for discussion. Any notes concerning it are also visible here."
text_agenda_item_no_notes: "No notes provided"
text_agenda_item_not_editable_anymore: "This agenda item is not editable anymore."
+ text_agenda_item_move_next_meeting: "Are you sure you want to move this to the next meeting on %{date} at %{time}?"
text_work_package_has_no_upcoming_meeting_agenda_items: "This work package is not scheduled in an upcoming meeting agenda yet."
+ text_agenda_item_move_next_meeting_cancelled: "The next meeting in this series has been cancelled."
text_work_package_add_to_meeting_hint: 'Use the "Add to meeting" button to add this work package to an upcoming meeting.'
text_work_package_has_no_past_meeting_agenda_items: "This work package was not mentioned in a past meeting."
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 0f5c36bce1f..5af11e6175b 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -105,6 +106,7 @@ Rails.application.routes.draw do
get :cancel_edit
put :drop
put :move
+ post :move_to_next, action: :move_to_next_meeting
end
end
resources :sections, controller: "meeting_sections" do
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index 72165bce1d7..f6f02fa8a8e 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -89,7 +89,8 @@ module OpenProject::Meeting
require: :member
permission :manage_agendas,
{
- meeting_agenda_items: %i[new cancel_new create edit cancel_edit update destroy drop move],
+ meeting_agenda_items: %i[new cancel_new create edit cancel_edit update destroy drop move
+ move_to_next_meeting],
meeting_sections: %i[new cancel_new create edit cancel_edit update destroy drop move]
},
permissible_on: :project, # TODO: Change this to :meeting when MeetingRoles are available
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
new file mode 100644
index 00000000000..3a3d1763b68
--- /dev/null
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_move_to_next_spec.rb
@@ -0,0 +1,151 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+require_relative "../../support/pages/meetings/new"
+require_relative "../../support/pages/structured_meeting/show"
+require_relative "../../support/pages/recurring_meeting/show"
+require_relative "../../support/pages/meetings/index"
+
+RSpec.describe "Recurring meetings move to next meeting", :js do
+ include Components::Autocompleter::NgSelectAutocompleteHelpers
+
+ shared_let(:project) { create(:project, enabled_module_names: %w[meetings]) }
+ shared_let(:user_with_manage_permissions) do
+ create :user,
+ lastname: "Manager",
+ preferences: { time_zone: "Etc/UTC" },
+ member_with_permissions: { project => %i[view_meetings manage_agendas] }
+ end
+ shared_let(:user_with_view_permissions) do
+ create :user,
+ lastname: "Viewer",
+ preferences: { time_zone: "Etc/UTC" },
+ member_with_permissions: { project => %i[view_meetings] }
+ end
+ shared_let(:series) do
+ create :recurring_meeting,
+ project:,
+ start_time: DateTime.parse("2025-01-28T10:30:00Z"),
+ duration: 1,
+ frequency: "weekly",
+ end_after: "never",
+ author: user_with_manage_permissions
+ end
+ shared_let(:structured_meeting) do
+ create :structured_meeting,
+ project:,
+ start_time: DateTime.parse("2025-01-28T10:30:00Z"),
+ duration: 1,
+ author: user_with_manage_permissions
+ end
+
+ let!(:recurring_meeting) do
+ # Assuming the first init job has run
+ RecurringMeetings::InitNextOccurrenceJob.perform_now(series, series.first_occurrence.to_time)
+
+ series.meetings.not_templated.first
+ end
+
+ let!(:agenda_item) { create(:meeting_agenda_item, meeting: structured_meeting, title: "Test notes") }
+ let!(:series_agenda_item) { create(:meeting_agenda_item, meeting: recurring_meeting, title: "Test notes") }
+
+ let(:meeting_page) { Pages::StructuredMeeting::Show.new(meeting) }
+
+ before do
+ login_as current_user
+
+ meeting_page.visit!
+ end
+
+ context "when viewing a recurring meeting" do
+ let(:meeting) { recurring_meeting }
+
+ context "with manage_agendas permission" do
+ let(:current_user) { user_with_manage_permissions }
+
+ it "shows the move to next meeting option" do
+ meeting_page.expect_agenda_item(title: "Test notes")
+ meeting_page.expect_agenda_action_menu(series_agenda_item)
+
+ accept_confirm do
+ meeting_page.select_action(series_agenda_item, "Move to next meeting")
+ end
+
+ meeting_page.expect_no_agenda_item(title: "Test notes")
+ end
+ end
+
+ context "with manage_agendas permission, but next occurrence is cancelled" do
+ let(:current_user) { user_with_manage_permissions }
+ let!(:cancelled_occurrence) do
+ create(:scheduled_meeting,
+ :cancelled,
+ recurring_meeting: series,
+ start_time: series.next_occurrence(from_time: recurring_meeting.start_time))
+ end
+
+ it "shows the move to next meeting option" do
+ meeting_page.expect_agenda_item(title: "Test notes")
+ meeting_page.expect_agenda_action_menu(series_agenda_item)
+
+ accept_confirm do
+ meeting_page.select_action(series_agenda_item, "Move to next meeting")
+ end
+
+ expect(page).to have_text "The next meeting in this series has been cancelled."
+ meeting_page.expect_agenda_item(title: "Test notes")
+ end
+ end
+
+ context "with view permission only" do
+ let(:current_user) { user_with_view_permissions }
+
+ it "does not show the move to next meeting option" do
+ meeting_page.expect_agenda_item(title: "Test notes")
+ meeting_page.expect_no_agenda_action_menu(agenda_item)
+ end
+ end
+ end
+
+ context "when viewing a structured meeting" do
+ let(:meeting) { structured_meeting }
+ let(:current_user) { user_with_manage_permissions }
+
+ it "does not show the move to next meeting option" do
+ meeting_page.expect_agenda_item(title: "Test notes")
+ meeting_page.open_menu(agenda_item) do
+ expect(page).to have_text("Edit")
+ expect(page).to have_no_text("Move to next meeting")
+ end
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
index 0e81be864a9..b413eed2fa4 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -146,7 +147,23 @@ module Pages::StructuredMeeting
expect(page).not_to have_test_selector("op-meeting-agenda-title", text: title)
end
+ def expect_agenda_action_menu(item)
+ expect(page)
+ .to have_css("#meeting-agenda-items-item-component-#{item.id} #{test_selector('op-meeting-agenda-actions')}")
+ end
+
+ def expect_no_agenda_action_menu(item)
+ expect(page)
+ .to have_no_css("#meeting-agenda-items-item-component-#{item.id} #{test_selector('op-meeting-agenda-actions')}")
+ end
+
def select_action(item, action)
+ open_menu(item) do
+ click_on action
+ end
+ end
+
+ def open_menu(item, &)
retry_block do
page.within("#meeting-agenda-items-item-component-#{item.id}") do
page.find_test_selector("op-meeting-agenda-actions").click
@@ -154,9 +171,7 @@ module Pages::StructuredMeeting
page.find(".Overlay")
end
- page.within(".Overlay") do
- click_on action
- end
+ page.within(".Overlay", &)
end
def select_outcome_action(action)