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

Alexander Brandon Coles6d84e0b13517
diff --git a/modules/meeting/app/components/meetings/delete_dialog_component.html.erb b/modules/meeting/app/components/meetings/delete_dialog_component.html.erb
new file mode 100644
index 00000000000..17de1f160a1
--- /dev/null
+++ b/modules/meeting/app/components/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, @meeting.becomes(Meeting)]),
+ method: :delete,
+ data: { turbo: true }
+ }
+ )) do |dialog|
+ dialog.with_confirmation_message do |message|
+ message.with_heading(tag: :h2) { 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/meetings/delete_dialog_component.rb b/modules/meeting/app/components/meetings/delete_dialog_component.rb
new file mode 100644
index 00000000000..d78eb65da65
--- /dev/null
+++ b/modules/meeting/app/components/meetings/delete_dialog_component.rb
@@ -0,0 +1,73 @@
+# 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 Meetings
+ class DeleteDialogComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+
+ def initialize(meeting:, project:)
+ super
+
+ @meeting = meeting
+ @project = project
+ end
+
+ delegate :recurring_meeting, to: :@meeting
+
+ private
+
+ def id = "delete-meeting-dialog"
+
+ def title
+ if recurring_meeting.present?
+ I18n.t("meeting.delete_dialog.occurrence.title")
+ else
+ I18n.t("meeting.delete_dialog.one_time.title")
+ end
+ end
+
+ def heading
+ if recurring_meeting.present?
+ I18n.t("meeting.delete_dialog.occurrence.heading")
+ else
+ I18n.t("meeting.delete_dialog.one_time.heading")
+ end
+ end
+
+ def confirmation_message
+ if recurring_meeting.present?
+ t("meeting.delete_dialog.occurrence.confirmation_message_html", name: recurring_meeting.title)
+ else
+ t("meeting.delete_dialog.one_time.confirmation_message_html")
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb
index 4f9e57a7c39..f4ae73d211b 100644
--- a/modules/meeting/app/components/meetings/header_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_component.html.erb
@@ -95,9 +95,10 @@
menu.with_item(label: delete_label,
scheme: :danger,
- href: meeting_path(@meeting),
- form_arguments: {
- method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }
+ href: polymorphic_path([:delete_dialog, @project, @meeting.becomes(Meeting)]),
+ tag: :a,
+ content_arguments: {
+ data: { controller: "async-dialog" }
}) do |item|
item.with_leading_visual_icon(icon: :trash)
end if delete_enabled?
diff --git a/modules/meeting/app/components/meetings/row_component.rb b/modules/meeting/app/components/meetings/row_component.rb
index 60abe47f6ad..ea4ac880968 100644
--- a/modules/meeting/app/components/meetings/row_component.rb
+++ b/modules/meeting/app/components/meetings/row_component.rb
@@ -140,22 +140,15 @@ module Meetings
menu.with_item(label: recurring_meeting.present? ? I18n.t(:label_recurring_meeting_delete) : I18n.t(:label_meeting_delete),
scheme: :danger,
- href: meeting_path(model),
- form_arguments: {
- method: :delete, data: { confirm: delete_confirm_message, turbo: false }
+ href: delete_dialog_meeting_path(model),
+ tag: :a,
+ content_arguments: {
+ data: { controller: "async-dialog" }
}) do |item|
item.with_leading_visual_icon(icon: :trash)
end
end
- def delete_confirm_message
- if recurring_meeting.present?
- I18n.t(:label_recurring_meeting_delete_confirmation, name: recurring_meeting.title)
- else
- I18n.t("text_are_you_sure")
- end
- end
-
def recurring_label
render(Primer::BaseComponent.new(tag: :span, color: :muted)) do
concat render(Primer::Beta::Octicon.new(icon: :iterations, mr: 1, ml: 1))
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index af3e93508f0..c635696abd8 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -27,7 +27,7 @@
#++
class MeetingsController < ApplicationController
- before_action :load_and_authorize_in_optional_project, only: %i[index new new_dialog show create history]
+ before_action :load_and_authorize_in_optional_project, only: %i[index new new_dialog show create delete_dialog destroy history]
before_action :verify_activities_module_activated, only: %i[history]
before_action :determine_date_range, only: %i[history]
before_action :determine_author, only: %i[history]
@@ -178,6 +178,13 @@ class MeetingsController < ApplicationController
end
end
+ def delete_dialog
+ respond_with_dialog Meetings::DeleteDialogComponent.new(
+ meeting: @meeting,
+ project: @project
+ )
+ end
+
def destroy # rubocop:disable Metrics/AbcSize
recurring = @meeting.recurring_meeting
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 7a73e3e7348..f0bcc6d9f40 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -136,10 +136,6 @@ en:
label_recurring_meeting_copy: "Copy as one-off"
label_recurring_meeting_cancel: "Cancel this occurrence"
label_recurring_meeting_delete: "Delete occurrence"
- label_recurring_meeting_delete_confirmation: >
- This meeting is part of a series called %{name}.
- This will only delete this particular occurrence and not the entire series.
- Do you want to continue?
label_recurring_occurrence_delete_confirmation: >
Any meeting information not in the template will be lost.
Do you want to continue?
@@ -222,6 +218,19 @@ en:
structured_text: "Organize your meeting as a dynamic list of agenda items, optionally linking them to a work package."
structured_text_copy: "Copying a meeting will currently not copy the associated meeting agenda items, just the details"
copied: "Copied from Meeting #%{id}"
+ delete_dialog:
+ one_time:
+ title: "Delete meeting"
+ heading: "Delete this meeting?"
+ confirmation_message_html: >
+ Do you want to continue?
+ occurrence:
+ title: "Delete occurrence"
+ heading: "Delete this meeting occurrence?"
+ confirmation_message_html: >
+ This meeting is part of a series called <strong>%{name}</strong>.
+ This will only delete this particular occurrence and not the entire series.
+ Do you want to continue?
meeting_section:
untitled_title: "Untitled section"
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 5bb5ebfeb3b..e8092b7c802 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -28,10 +28,13 @@
Rails.application.routes.draw do
resources :projects, only: %i[] do
- resources :meetings, only: %i[index new create show] do
+ resources :meetings, only: %i[index new create show destroy] do
collection do
get "menu" => "meetings/menus#show"
end
+ member do
+ get :delete_dialog
+ end
end
resources :recurring_meetings, only: %i[index new create show destroy]
end
@@ -86,6 +89,7 @@ Rails.application.routes.draw do
put :change_state
post :notify
get :history
+ get :delete_dialog
end
resources :agenda_items, controller: "meeting_agenda_items" do
collection do
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index fccbea65629..6324fe0a6eb 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -70,7 +70,7 @@ module OpenProject::Meeting
require: :member
permission :delete_meetings,
{
- meetings: [:destroy],
+ meetings: %i[delete_dialog destroy],
recurring_meetings: %i[destroy delete_scheduled]
},
permissible_on: :project,
diff --git a/modules/meeting/spec/components/meetings/delete_dialog_component_spec.rb b/modules/meeting/spec/components/meetings/delete_dialog_component_spec.rb
new file mode 100644
index 00000000000..0f37640dd70
--- /dev/null
+++ b/modules/meeting/spec/components/meetings/delete_dialog_component_spec.rb
@@ -0,0 +1,92 @@
+# 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 Meetings::DeleteDialogComponent, type: :component do
+ include Rails.application.routes.url_helpers
+
+ let(:project) { build_stubbed(:project) }
+ let(:user) { build_stubbed(:user) }
+
+ subject do
+ render_inline(described_class.new(meeting:, project:))
+ page
+ end
+
+ before do
+ login_as(user)
+ end
+
+ describe "dialog form" do
+ let(:meeting) { build_stubbed(:meeting, project:) }
+
+ context "without a current project" do
+ let(:project) { nil }
+
+ it "renders the correct form action" do
+ expect(subject).to have_element "form", action: meeting_path(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_meeting_path(project, meeting)
+ end
+ end
+ end
+
+ describe "with a one-off meeting" do
+ let(:meeting) { build_stubbed(:meeting, project:) }
+
+ it "shows a heading" do
+ expect(subject).to have_text "Delete this meeting?"
+ end
+
+ it "shows a simple confirmation message" do
+ expect(subject).to have_text "Do you want to continue?"
+ end
+ end
+
+ context "with an associated recurring/templated meeting" do
+ let(:series) { build_stubbed(:recurring_meeting) }
+ let(:meeting) { build_stubbed(:structured_meeting_template, recurring_meeting: series) }
+
+ it "shows a heading" do
+ expect(subject).to have_text "Delete this meeting occurrence?"
+ end
+
+ it "shows a message that the meeting is part of a series" do
+ expect(subject).to have_text "meeting is part of a series"
+ end
+ end
+end
diff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
index 8c6d89c72fc..6ea8d36a52d 100644
--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
@@ -212,11 +212,17 @@ RSpec.describe "Structured meetings CRUD",
it "can delete a meeting and get back to the index page" do
click_on("op-meetings-header-action-trigger")
- accept_confirm(I18n.t("text_are_you_sure")) do
- click_on "Delete meeting"
+ click_on "Delete meeting"
+
+ within "#delete-meeting-dialog" do
+ check "I understand that this deletion cannot be reversed"
+
+ click_on "Delete permanently"
end
expect(page).to have_current_path project_meetings_path(project)
+
+ expect_flash(type: :success, message: "Successful deletion.")
end
context "when exporting as ICS" do
diff --git a/modules/meeting/spec/support/pages/meetings/index.rb b/modules/meeting/spec/support/pages/meetings/index.rb
index 0333069d815..c82efef56ef 100644
--- a/modules/meeting/spec/support/pages/meetings/index.rb
+++ b/modules/meeting/spec/support/pages/meetings/index.rb
@@ -130,7 +130,7 @@ module Pages::Meetings
def expect_delete_action(meeting)
within more_menu(meeting) do
- expect(page).to have_button("Delete meeting")
+ expect(page).to have_link("Delete meeting")
end
end