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 recurring meetings

Alexander Brandon Colesb995ab5720e0
diff --git a/modules/meeting/app/components/recurring_meetings/delete_dialog_component.html.erb b/modules/meeting/app/components/recurring_meetings/delete_dialog_component.html.erb
new file mode 100644
index 00000000000..3533491c400
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/delete_dialog_component.html.erb
@@ -0,0 +1,46 @@
+<%#-- 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:,
+ form_arguments: {
+ action: polymorphic_path([@project, @recurring_meeting]),
+ method: :delete,
+ data: { turbo: true }
+ }
+ )) do |dialog|
+ dialog.with_confirmation_message do |message|
+ message.with_heading(tag: :h2) { I18n.t("recurring_meeting.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_dialog_component.rb b/modules/meeting/app/components/recurring_meetings/delete_dialog_component.rb
new file mode 100644
index 00000000000..72368d123c1
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/delete_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 DeleteDialogComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+
+ def initialize(recurring_meeting:, project:)
+ super
+
+ @recurring_meeting = recurring_meeting
+ @project = project
+ end
+
+ private
+
+ def id = "delete-recurring-meeting-dialog"
+
+ def title = I18n.t("recurring_meeting.delete_dialog.title")
+
+ def confirmation_message
+ t("recurring_meeting.delete_dialog.confirmation_message_html",
+ title: @recurring_meeting.title,
+ count: @recurring_meeting.remaining_occurrences.count)
+ end
+ end
+end
diff --git a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
index 12f5f0a0dd6..232fd2110bd 100644
--- a/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
+++ b/modules/meeting/app/components/recurring_meetings/show_page_header_component.html.erb
@@ -61,10 +61,11 @@
menu.with_item(
label: I18n.t(:label_recurring_meeting_series_delete),
- href: polymorphic_path([@project, @meeting]),
+ href: polymorphic_path([:delete_dialog, @project, @meeting]),
scheme: :danger,
- form_arguments: {
- method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }
+ 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 771b307967b..0bc946aca6a 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -9,10 +9,10 @@ class RecurringMeetingsController < ApplicationController
include OpTurbo::DialogStreamHelper
before_action :find_meeting,
- only: %i[show update details_dialog destroy edit init
+ only: %i[show update details_dialog delete_dialog destroy edit init
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 destroy edit delete_scheduled notify]
+ only: %i[index show new create update details_dialog delete_dialog destroy edit 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]
@@ -156,6 +156,13 @@ class RecurringMeetingsController < ApplicationController
redirect_to action: :show
end
+ def delete_dialog
+ respond_with_dialog RecurringMeetings::DeleteDialogComponent.new(
+ recurring_meeting: @recurring_meeting,
+ project: @project
+ )
+ end
+
def destroy
if @recurring_meeting.destroy
flash[:notice] = I18n.t(:notice_successful_delete)
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 6b25735ced8..663f46e8cb6 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -287,6 +287,13 @@ en:
The following meetings are planned in the recurring meeting schedule but are not open yet.
Every time a planned meeting starts, the next one will automatically be opened for you.
You can also open planned meetings manually to import the template and start editing the agenda.
+ delete_dialog:
+ title: "Delete meeting series"
+ heading: "Permanently delete this meeting series?"
+ confirmation_message_html: >
+ Deleting <strong>%{title}</strong> will delete all %{count} meetings in this series.
+
+ This action is not reversible. Please proceed with caution.
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 e8092b7c802..f24df91659d 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -36,7 +36,11 @@ Rails.application.routes.draw do
get :delete_dialog
end
end
- resources :recurring_meetings, only: %i[index new create show destroy]
+ resources :recurring_meetings, only: %i[index new create show destroy] do
+ member do
+ get :delete_dialog
+ end
+ end
end
resources :work_packages, only: %i[] do
@@ -63,6 +67,7 @@ Rails.application.routes.draw do
member do
get :details_dialog
get :download_ics
+ get :delete_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 6324fe0a6eb..f3082bb31f5 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[destroy delete_scheduled]
+ recurring_meetings: %i[delete_dialog destroy delete_scheduled]
},
permissible_on: :project,
require: :member
diff --git a/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb b/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb
new file mode 100644
index 00000000000..4996ce890b7
--- /dev/null
+++ b/modules/meeting/spec/components/recurring_meetings/delete_dialog_component_spec.rb
@@ -0,0 +1,75 @@
+# 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::DeleteDialogComponent, 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(:meeting) { build_stubbed(:structured_meeting_template, recurring_meeting:) }
+ let(:user) { build_stubbed(:user) }
+
+ subject do
+ render_inline(described_class.new(recurring_meeting:, 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: recurring_meeting_path(recurring_meeting)
+ 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: project_recurring_meeting_path(project, recurring_meeting)
+ end
+ end
+ end
+
+ it "shows a heading" do
+ expect(subject).to have_text "Permanently delete this meeting series?"
+ end
+
+ it "shows a confirmation message detailing the remaining occurrences in the series" do
+ expect(subject).to have_text "will delete all 6 meetings in this series"
+ 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 e880874c604..7f14c2128e2 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
@@ -88,13 +88,17 @@ RSpec.describe "Recurring meetings CRUD",
it "can delete a recurring meeting from the show page and return to the index page" do
show_page.visit!
- click_on "recurring-meeting-action-menu"
+ show_page.delete_meeting_series
+ show_page.in_delete_recurring_dialog do
+ page.check "I understand that this deletion cannot be reversed"
- accept_confirm(I18n.t("text_are_you_sure")) do
- click_on "Delete meeting series"
+ click_on "Delete permanently"
end
expect(page).to have_current_path meetings_path # check path
+
+ expect_flash(type: :success, message: "Successful deletion.")
+ show_page.expect_no_meeting date: "12/31/2024 01:30 PM"
end
it "can use the 'Create from template' button" do
diff --git a/modules/meeting/spec/support/pages/recurring_meeting/show.rb b/modules/meeting/spec/support/pages/recurring_meeting/show.rb
index dd5d1085f31..c3753aa2d2d 100644
--- a/modules/meeting/spec/support/pages/recurring_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/recurring_meeting/show.rb
@@ -113,6 +113,13 @@ module Pages::RecurringMeeting
expect(page).to have_css("#new-meeting-dialog")
end
+ def delete_meeting_series
+ page.find_test_selector("recurring-meeting-action-menu").click
+ click_on "Delete meeting series"
+
+ expect(page).to have_css("#delete-recurring-meeting-dialog")
+ end
+
def in_edit_dialog(&)
page.within("#new-meeting-dialog", &)
end
@@ -121,6 +128,10 @@ module Pages::RecurringMeeting
page.within("#delete-meeting-dialog", &)
end
+ def in_delete_recurring_dialog(&)
+ page.within("#delete-recurring-meeting-dialog", &)
+ end
+
def expect_no_meeting(date:)
expect(page).to have_no_css("li", text: date)
end