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

Add toggle button to meeting show page

Mir Bhatiaeb324b777246
diff --git a/modules/meeting/app/components/meetings/side_panel/details_component.rb b/modules/meeting/app/components/meetings/side_panel/details_component.rb
index 4286868d756..d417c7a301c 100644
--- a/modules/meeting/app/components/meetings/side_panel/details_component.rb
+++ b/modules/meeting/app/components/meetings/side_panel/details_component.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
diff --git a/modules/meeting/app/components/meetings/side_panel/notifications_button_component.html.erb b/modules/meeting/app/components/meetings/side_panel/notifications_button_component.html.erb
new file mode 100644
index 00000000000..dc2e5933814
--- /dev/null
+++ b/modules/meeting/app/components/meetings/side_panel/notifications_button_component.html.erb
@@ -0,0 +1,73 @@
+<%#-- 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.
+
+++#%>
+
+<%=
+ component_wrapper do
+ render(Primer::OpenProject::FlexLayout.new) do |flex|
+ flex.with_row do
+ render(Primer::OpenProject::FlexLayout.new(align_items: :center)) do |row|
+ row.with_column do
+ render(Primer::Beta::Heading.new(tag: :h5)) { I18n.t("label_send_email_updates") }
+ end
+
+ row.with_column(ml: 2) do
+ if @meeting.notify?
+ concat(
+ render(Primer::Beta::Text.new(color: :success, font_size: :small)) do
+ I18n.t("label_status_enabled")
+ end
+ )
+ else
+ concat(
+ render(Primer::Beta::Text.new(color: :danger, font_size: :small)) do
+ I18n.t("label_status_muted")
+ end
+ )
+ end
+ end
+ end
+ end
+
+ if show_button?
+ flex.with_row(mt: 2) do
+ render(
+ Primer::Beta::Button.new(
+ scheme: :default,
+ block: true,
+ tag: :a,
+ href: toggle_notifications_dialog_project_meeting_path(@project, @meeting),
+ title: I18n.t("label_send_email_updates"),
+ data: { "turbo-stream": true }
+ )
+ ) { title }
+ end
+ end
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meetings/side_panel/notifications_button_component.rb b/modules/meeting/app/components/meetings/side_panel/notifications_button_component.rb
new file mode 100644
index 00000000000..e72aed72993
--- /dev/null
+++ b/modules/meeting/app/components/meetings/side_panel/notifications_button_component.rb
@@ -0,0 +1,56 @@
+# 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 SidePanel::NotificationsButtonComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ @project = meeting.project
+ end
+
+ private
+
+ def title
+ @meeting.notify? ? I18n.t("label_mute") : I18n.t("label_enable")
+ end
+
+ def show_button?
+ return false unless @meeting.editable?
+
+ [email protected]? || @meeting.templated?
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/side_panel/toggle_notifications_dialog_component.html.erb b/modules/meeting/app/components/meetings/side_panel/toggle_notifications_dialog_component.html.erb
new file mode 100644
index 00000000000..08aaf591c3c
--- /dev/null
+++ b/modules/meeting/app/components/meetings/side_panel/toggle_notifications_dialog_component.html.erb
@@ -0,0 +1,47 @@
+<%#-- 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::DangerDialog.new(
+ id:,
+ title:,
+ confirm_button_text:,
+ cancel_button_text:,
+ form_arguments: {
+ action: toggle_notifications_project_meeting_path(@project, @meeting)
+ }
+ )
+ ) do |dialog|
+ dialog.with_confirmation_message do |message|
+ message.with_heading(tag: :h2) { heading }
+ message.with_description_content(confirmation_message)
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meetings/side_panel/toggle_notifications_dialog_component.rb b/modules/meeting/app/components/meetings/side_panel/toggle_notifications_dialog_component.rb
new file mode 100644
index 00000000000..e0a0f0b8fd0
--- /dev/null
+++ b/modules/meeting/app/components/meetings/side_panel/toggle_notifications_dialog_component.rb
@@ -0,0 +1,83 @@
+# 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 SidePanel::ToggleNotificationsDialogComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+
+ def initialize(meeting)
+ super
+
+ @meeting = meeting
+ @project = meeting.project
+ end
+
+ private
+
+ def id = "toggle-notifications-dialog"
+
+ def title
+ if @meeting.notify?
+ I18n.t("meeting.notifications_dialog.title.mute")
+ else
+ I18n.t("meeting.notifications_dialog.title.enable")
+ end
+ end
+
+ def heading
+ if @meeting.notify?
+ I18n.t("meeting.notifications_dialog.title.mute")
+ else
+ I18n.t("meeting.notifications_dialog.title.enable")
+ end
+ end
+
+ def confirmation_message
+ if @meeting.notify?
+ I18n.t("meeting.notifications_dialog.message.mute")
+ else
+ I18n.t("meeting.notifications_dialog.message.enable")
+ end
+ end
+
+ def confirm_button_text
+ if @meeting.notify?
+ I18n.t("meeting.notifications_dialog.confirm_label.mute")
+ else
+ I18n.t("meeting.notifications_dialog.confirm_label.enable")
+ end
+ end
+
+ def cancel_button_text
+ I18n.t("button_cancel")
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/side_panel_component.html.erb b/modules/meeting/app/components/meetings/side_panel_component.html.erb
index 5f582e547ab..c5a223abe69 100644
--- a/modules/meeting/app/components/meetings/side_panel_component.html.erb
+++ b/modules/meeting/app/components/meetings/side_panel_component.html.erb
@@ -2,6 +2,9 @@
component_wrapper do
render(Primer::OpenProject::SidePanel.new) do |panel|
panel.with_section(Meetings::SidePanel::DetailsComponent.new(meeting: @meeting))
+
+ panel.with_section(Meetings::SidePanel::NotificationsButtonComponent.new(meeting: @meeting))
+
unless @meeting.template?
panel.with_section(Meetings::SidePanel::StateComponent.new(meeting: @meeting))
end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index b19aa11bd7e..a0d9bf1c3c8 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -348,6 +348,19 @@ class MeetingsController < ApplicationController
)
end
+ def toggle_notifications_dialog
+ respond_with_dialog Meetings::SidePanel::ToggleNotificationsDialogComponent.new(@meeting)
+ end
+
+ def toggle_notifications
+ @meeting.update!(notify: [email protected])
+
+ update_sidebar_component_via_turbo_stream
+ update_header_component_via_turbo_stream
+
+ respond_with_turbo_streams
+ end
+
private
def load_query
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index a81d88f141d..33095272196 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -186,7 +186,11 @@ class Meeting < ApplicationRecord
end
def notify?
- notify
+ if recurring?
+ recurring_meeting.template.notify
+ else
+ notify
+ end
end
def invited_or_attended_participants
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 93d7a45421f..2b2f431d076 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -281,6 +281,20 @@ en:
label: Footer text
caption: This text will appear on every page at the center of the footer.
submit_button: Download
+ notifications_dialog:
+ title:
+ enable: "Enable email calendar updates?"
+ mute: "Mute email calendar updates?"
+ message:
+ enable: >
+ All participants will receive updated calendar invites via email informing them of changes to the meeting.
+ One will be sent immediately now.
+ mute: >
+ Participants will no longer receive updated calendar invites via email with changes to the meeting.
+ If they already had an invite for this meeting, it might no longer be accurate.
+ confirm_label:
+ enable: "Enable email updates"
+ mute: "Mute email updates"
meeting_section:
untitled_title: "Untitled section"
@@ -532,3 +546,11 @@ en:
text_email_updates_muted: "Email calendar updates are muted. Participants will not receive updated invites via email when you make changes."
text_email_updates_enabled: "Email calendar updates are enabled. All participants will receive updated invites via email when you make changes."
+
+ label_send_email_updates: "Send email calendar updates"
+ label_mute: "Mute"
+ label_enable: "Enable"
+ label_status_muted: "muted"
+ label_status_enabled: "enabled"
+
+
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 12da77fe6c6..a0068f222cf 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -51,6 +51,8 @@ Rails.application.routes.draw do
get :history
get :delete_dialog
get :generate_pdf_dialog
+ get :toggle_notifications_dialog
+ post :toggle_notifications
end
end
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index d48d5dbf7df..837f146af79 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -62,8 +62,8 @@ module OpenProject::Meeting
contract_actions: { meetings: %i[create] }
permission :edit_meetings,
{
- meetings: %i[edit cancel_edit update update_title change_state
- details_dialog update_details update_participants],
+ meetings: %i[edit cancel_edit update update_title change_state toggle_notifications_dialog
+ details_dialog update_details update_participants toggle_notifications],
recurring_meetings: %i[edit cancel_edit update update_title details_dialog update_details
notify end_series end_series_dialog],
work_package_meetings_tab: %i[add_work_package_to_meeting_dialog add_work_package_to_meeting]