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

[#59885] Impl. DeleteDialog for scheduled meetings

Alexander Brandon Coles0d8b7e696197
diff --git a/modules/meeting/app/components/recurring_meetings/delete_scheduled_dialog_component.html.erb b/modules/meeting/app/components/recurring_meetings/delete_scheduled_dialog_component.html.erb
new file mode 100644
index 00000000000..2e6798f91ee
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/delete_scheduled_dialog_component.html.erb
@@ -0,0 +1,51 @@
+<%#-- 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.
+
+++#%>
+
+<%=
+ render(Primer::OpenProject::DangerConfirmationDialog.new(
+ id:,
+ title:,
+ confirm_button_text:,
+ cancel_button_text:,
+ form_arguments: {
+ action: polymorphic_path(
+ [:delete_scheduled, @project, @scheduled.recurring_meeting],
+ start_time: @scheduled.start_time.iso8601
+ ),
+ method: :post,
+ data: { turbo: true }
+ }
+ )) do |dialog|
+ dialog.with_confirmation_message do |message|
+ message.with_heading(tag: :h2) { I18n.t("recurring_meeting.scheduled_delete_dialog.heading") }
+ message.with_description_content(confirmation_message)
+ end
+ dialog.with_confirmation_check_box_content(I18n.t("text_permanent_delete_confirmation_checkbox_label"))
+ end
+%>
diff --git a/modules/meeting/app/components/recurring_meetings/delete_scheduled_dialog_component.rb b/modules/meeting/app/components/recurring_meetings/delete_scheduled_dialog_component.rb
new file mode 100644
index 00000000000..853209e1195
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/delete_scheduled_dialog_component.rb
@@ -0,0 +1,55 @@
+# 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.
+#++
+
+module RecurringMeetings
+ class DeleteScheduledDialogComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+
+ def initialize(scheduled:, project:)
+ super
+
+ @scheduled = scheduled
+ @project = project
+ end
+
+ private
+
+ def id = "delete-scheduled-recurring-meeting-dialog"
+
+ def title = I18n.t("recurring_meeting.scheduled_delete_dialog.title")
+
+ def confirmation_message = t("recurring_meeting.scheduled_delete_dialog.confirmation_message_html")
+
+ def confirm_button_text = I18n.t("recurring_meeting.scheduled_delete_dialog.confirm_button")
+
+ def cancel_button_text = I18n.t(:button_close)
+ end
+end
diff --git a/modules/meeting/app/components/recurring_meetings/row_component.rb b/modules/meeting/app/components/recurring_meetings/row_component.rb
index a5ed2374d37..d93e5742448 100644
--- a/modules/meeting/app/components/recurring_meetings/row_component.rb
+++ b/modules/meeting/app/components/recurring_meetings/row_component.rb
@@ -193,9 +193,11 @@ module RecurringMeetings
menu.with_item(
label: I18n.t(:label_recurring_meeting_cancel),
scheme: :danger,
- href: delete_scheduled_recurring_meeting_path(model.recurring_meeting.id, start_time: model.start_time.iso8601),
- form_arguments: {
- method: :post, data: { confirm: I18n.t("text_are_you_sure"), turbo: false }
+ href: polymorphic_path([:delete_scheduled_dialog, current_project, model.recurring_meeting],
+ start_time: model.start_time.iso8601),
+ tag: :a,
+ content_arguments: {
+ data: { controller: "async-dialog" }
}
) do |item|
item.with_leading_visual_icon(icon: :trash)
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index 0bc946aca6a..35788cf0ec8 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -10,12 +10,14 @@ class RecurringMeetingsController < ApplicationController
before_action :find_meeting,
only: %i[show update details_dialog delete_dialog destroy edit init
- delete_scheduled template_completed download_ics notify end_series end_series_dialog]
+ delete_scheduled_dialog delete_scheduled template_completed download_ics notify end_series
+ end_series_dialog]
before_action :find_optional_project,
- only: %i[index show new create update details_dialog delete_dialog destroy edit delete_scheduled notify]
+ only: %i[index show new create update details_dialog delete_dialog destroy edit delete_scheduled_dialog
+ delete_scheduled notify]
before_action :authorize_global, only: %i[index new create]
before_action :authorize, except: %i[index new create]
- before_action :get_scheduled_meeting, only: %i[delete_scheduled]
+ before_action :get_scheduled_meeting, only: %i[delete_scheduled_dialog delete_scheduled]
before_action :convert_params, only: %i[create update]
before_action :check_template_completable, only: %i[template_completed]
@@ -194,6 +196,13 @@ class RecurringMeetingsController < ApplicationController
redirect_to action: :show, id: @recurring_meeting, status: :see_other
end
+ def delete_scheduled_dialog
+ respond_with_dialog RecurringMeetings::DeleteScheduledDialogComponent.new(
+ scheduled: @scheduled,
+ project: @project
+ )
+ end
+
def delete_scheduled
if @scheduled.update(cancelled: true)
flash[:notice] = I18n.t(:notice_successful_cancel)
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 663f46e8cb6..209b5f8f705 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -294,6 +294,14 @@ en:
Deleting <strong>%{title}</strong> will delete all %{count} meetings in this series.
This action is not reversible. Please proceed with caution.
+ scheduled_delete_dialog:
+ title: "Cancel meeting occurrence"
+ heading: "Cancel this meeting occurrence?"
+ confirmation_message_html: >
+ Any meeting information not in the template will be lost.
+
+ Do you want to continue?
+ confirm_button: "Cancel occurrence"
notice_successful_notification: "Notification sent successfully"
notice_timezone_missing: No time zone is set and %{zone} is assumed. To choose your time zone, please click here.
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index f24df91659d..97fa4b2f7ef 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -39,6 +39,8 @@ Rails.application.routes.draw do
resources :recurring_meetings, only: %i[index new create show destroy] do
member do
get :delete_dialog
+ get :delete_scheduled_dialog
+ post :delete_scheduled
end
end
end
@@ -68,6 +70,7 @@ Rails.application.routes.draw do
get :details_dialog
get :download_ics
get :delete_dialog
+ get :delete_scheduled_dialog
post :init
post :delete_scheduled
post :template_completed
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index f3082bb31f5..36929ea6006 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -71,7 +71,7 @@ module OpenProject::Meeting
permission :delete_meetings,
{
meetings: %i[delete_dialog destroy],
- recurring_meetings: %i[delete_dialog destroy delete_scheduled]
+ recurring_meetings: %i[delete_dialog destroy delete_scheduled_dialog delete_scheduled]
},
permissible_on: :project,
require: :member
diff --git a/modules/meeting/spec/components/recurring_meetings/delete_scheduled_dialog_component_spec.rb b/modules/meeting/spec/components/recurring_meetings/delete_scheduled_dialog_component_spec.rb
new file mode 100644
index 00000000000..d3cf5b53ecd
--- /dev/null
+++ b/modules/meeting/spec/components/recurring_meetings/delete_scheduled_dialog_component_spec.rb
@@ -0,0 +1,77 @@
+# 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 "rails_helper"
+
+RSpec.describe RecurringMeetings::DeleteScheduledDialogComponent, type: :component do
+ include Rails.application.routes.url_helpers
+
+ let(:project) { build_stubbed(:project) }
+ let(:recurring_meeting) { build_stubbed(:recurring_meeting, project:, end_after: :iterations, iterations: 6) }
+ let(:start_time) { 1.day.from_now }
+ let(:scheduled) { recurring_meeting.scheduled_meetings.find_or_initialize_by(start_time: start_time) }
+ let(:meeting) { build_stubbed(:structured_meeting_template, recurring_meeting:) }
+ let(:user) { build_stubbed(:user) }
+
+ subject do
+ render_inline(described_class.new(scheduled:, project:))
+ page
+ end
+
+ before do
+ login_as(user)
+ end
+
+ describe "dialog form" do
+ context "without a current project" do
+ let(:project) { nil }
+
+ it "renders the correct form action" do
+ expect(subject).to have_element "form", action: delete_scheduled_recurring_meeting_path(
+ recurring_meeting, start_time: start_time.iso8601
+ )
+ end
+ end
+
+ context "with a current project" do
+ let(:project) { build_stubbed(:project) }
+
+ it "renders the correct form action" do
+ expect(subject).to have_element "form", action: delete_scheduled_project_recurring_meeting_path(
+ project, recurring_meeting, start_time: start_time.iso8601
+ )
+ end
+ end
+ end
+
+ it "shows a heading" do
+ expect(subject).to have_text "Cancel this meeting occurrence?"
+ end
+end
diff --git a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb
index ac2ecbf8abd..0ec3a738f39 100644
--- a/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/recurring_meetings/recurring_meeting_crud_spec.rb
@@ -149,6 +149,23 @@ RSpec.describe "Recurring meetings CRUD",
show_page.expect_cancelled_meeting date: "12/31/2024 01:30 PM"
end
+ it "can cancel a scheduled occurrence from the global show page" do
+ show_page.visit!
+
+ show_page.cancel_occurrence date: "01/07/2025 01:30 PM"
+ show_page.in_delete_scheduled_dialog do
+ check "I understand that this deletion cannot be reversed"
+
+ click_on "Cancel occurrence"
+ end
+
+ expect_flash(type: :success, message: "Successful cancellation.")
+
+ expect(page).to have_current_path(show_page.path)
+
+ show_page.expect_cancelled_meeting date: "01/07/2025 01:30 PM"
+ end
+
it "can cancel an occurrence from the project show page" do
show_page.visit_project!
@@ -167,6 +184,23 @@ RSpec.describe "Recurring meetings CRUD",
show_page.expect_cancelled_meeting date: "12/31/2024 01:30 PM"
end
+ it "can cancel a scheduled occurrence from the project show page" do
+ show_page.visit_project!
+
+ show_page.cancel_occurrence date: "01/07/2025 01:30 PM"
+ show_page.in_delete_scheduled_dialog do
+ check "I understand that this deletion cannot be reversed"
+
+ click_on "Cancel occurrence"
+ end
+
+ expect_flash(type: :success, message: "Successful cancellation.")
+
+ expect(page).to have_current_path(show_page.project_path)
+
+ show_page.expect_cancelled_meeting date: "01/07/2025 01:30 PM"
+ end
+
it "can edit the details of a recurring meeting" do
show_page.visit!
diff --git a/modules/meeting/spec/support/pages/recurring_meeting/show.rb b/modules/meeting/spec/support/pages/recurring_meeting/show.rb
index 677971057b8..2bb19f2e69c 100644
--- a/modules/meeting/spec/support/pages/recurring_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/recurring_meeting/show.rb
@@ -138,6 +138,10 @@ module Pages::RecurringMeeting
page.within("#delete-recurring-meeting-dialog", &)
end
+ def in_delete_scheduled_dialog(&)
+ page.within("#delete-scheduled-recurring-meeting-dialog", &)
+ end
+
def expect_no_meeting(date:)
expect(page).to have_no_css("li", text: date)
end