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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add banners to forms
Mir Bhatia9ff9a5460c0b
diff --git a/frontend/src/stimulus/controllers/show-when-checked.controller.ts b/frontend/src/stimulus/controllers/show-when-checked.controller.tsindex 3793039d8c8..517a091551e 100644--- a/frontend/src/stimulus/controllers/show-when-checked.controller.ts+++ b/frontend/src/stimulus/controllers/show-when-checked.controller.ts@@ -1,5 +1,37 @@+/*+ * -- 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.+ * +++ */+import { ApplicationController } from 'stimulus-use';+// can show OR hide items by default (with "reversed" set to hide on checking)+// can show AND hide items (toggling between them) by using "show-when" data attributeexport default class OpShowWhenCheckedController extends ApplicationController {static targets = ['cause', 'effect'];@@ -8,12 +40,10 @@ export default class OpShowWhenCheckedController extends ApplicationController {};declare reversedValue:boolean;-declare readonly hasReversedValue:boolean;+ declare readonly effectTargets:HTMLElement[];- declare readonly effectTargets:HTMLInputElement[];-- private boundListener = this.toggleDisabled.bind(this);+ private boundListener = this.toggle.bind(this);causeTargetConnected(target:HTMLElement) {target.addEventListener('change', this.boundListener);@@ -23,22 +53,35 @@ export default class OpShowWhenCheckedController extends ApplicationController {target.removeEventListener('change', this.boundListener);}- private toggleDisabled(evt:InputEvent):void {+ private toggle(evt:InputEvent):void {const input = evt.target as HTMLInputElement;- const targetName = input.dataset.targetName;const checked = input.checked;- const hidden = (this.hasReversedValue && this.reversedValue) ? checked : !checked;+ const targetName = input.dataset.targetName;++ const activeState = (this.hasReversedValue && this.reversedValue) ? !checked : checked;this.effectTargets.filter((el) => targetName === el.dataset.targetName).forEach((el) => {+ const showWhen = el.dataset.showWhen;++ let shouldShow:boolean;++ if (showWhen === 'checked') {+ shouldShow = activeState;+ } else if (showWhen === 'unchecked') {+ shouldShow = !activeState;+ } else {+ shouldShow = activeState;+ }+if (el.dataset.setVisibility === 'true') {- el.style.setProperty('visibility', hidden ? 'hidden' : 'visible');+ el.style.setProperty('visibility', shouldShow ? 'visible' : 'hidden');} else if (el.dataset.visibilityClass) {- el.classList.toggle(el.dataset.visibilityClass, hidden);+ el.classList.toggle(el.dataset.visibilityClass, !shouldShow);} else {- el.hidden = hidden;+ el.hidden = !shouldShow;}});}diff --git a/modules/meeting/app/components/meetings/email_updates_banner_component.rb b/modules/meeting/app/components/meetings/email_updates_banner_component.rbnew file mode 100644index 00000000000..cd73f78ae4b--- /dev/null+++ b/modules/meeting/app/components/meetings/email_updates_banner_component.rb@@ -0,0 +1,59 @@+# 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 EmailUpdatesBannerComponent < ApplicationComponent+ def initialize(meeting, override: nil)+ super+ @meeting = meeting+ @override = override+ end++ def call+ render(Primer::Alpha::Banner.new(description:, scheme:))+ end++ private++ def description+ return I18n.t("text_email_updates_enabled") if @override == :enabled+ return I18n.t("text_email_updates_muted") if @override == :muted++ @meeting.notify? ? I18n.t("text_email_updates_enabled") : I18n.t("text_email_updates_muted")+ end++ def scheme+ return :default if @override == :enabled+ return :warning if @override == :muted++ @meeting.notify? ? :default : :warning+ end+ end+enddiff --git a/modules/meeting/app/components/meetings/index/form_component.html.erb b/modules/meeting/app/components/meetings/index/form_component.html.erbindex c6c3176b4e7..f54aca3dff8 100644--- a/modules/meeting/app/components/meetings/index/form_component.html.erb+++ b/modules/meeting/app/components/meetings/index/form_component.html.erb@@ -8,6 +8,7 @@turbo: true,controller: ["show-when-value-selected",+ "show-when-checked",@meeting.is_a?(RecurringMeeting) ? "recurring-meetings--form" : nil].compact.join(" "),"recurring-meetings--form-persisted-value": @meeting.persisted?@@ -120,6 +121,31 @@render(Meeting::SendEmailUpdates.new(f, meeting: @meeting))end+ modal_body.with_row(+ mt: 3,+ data: {+ "show-when-checked-target-name": "notification-banner",+ "show-when-checked-target": "effect",+ "show-when": "checked",+ visibility_class: "d-none"+ }+ ) do+ render(Meetings::EmailUpdatesBannerComponent.new(@meeting, override: :enabled))+ end++ modal_body.with_row(+ mt: 3,+ classes: "d-none",+ data: {+ "show-when-checked-target-name": "notification-banner",+ "show-when-checked-target": "effect",+ "show-when": "unchecked",+ visibility_class: "d-none"+ }+ ) do+ render(Meetings::EmailUpdatesBannerComponent.new(@meeting, override: :muted))+ end+if @copy_frommodal_body.with_row dorender(Meeting::CopiedFrom.new(f, id: @copy_from.id))diff --git a/modules/meeting/app/components/meetings/side_panel/details_form_component.html.erb b/modules/meeting/app/components/meetings/side_panel/details_form_component.html.erbindex 435f4664c65..9fb0a101449 100644--- a/modules/meeting/app/components/meetings/side_panel/details_form_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/details_form_component.html.erb@@ -15,6 +15,10 @@render(BaseErrorsComponent.new(@meeting, mb: 3))end+ modal_body.with_row(mb: 3) do+ render(Meetings::EmailUpdatesBannerComponent.new(@meeting))+ end+modal_body.with_row(mb: 3) dorender(Meeting::TimeGroup.new(f, meeting: @meeting))enddiff --git a/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erb b/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erbindex 343d37ce3a7..edd84fc7e5b 100644--- a/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/participants_dialog.html.erb@@ -19,6 +19,10 @@class: "Overlay-form") do |_f|flex_layout do |form_container|+ form_container.with_row(mb: 3) do+ render(Meetings::EmailUpdatesBannerComponent.new(@meeting))+ end+form_container.with_row doflex_layout(justify_content: :flex_end) do |header|header.with_column(style: "width: 90px;", text_align: :center) dodiff --git a/modules/meeting/app/forms/meeting/send_email_updates.rb b/modules/meeting/app/forms/meeting/send_email_updates.rbindex 3b06d575efe..bd9a4f57c24 100644--- a/modules/meeting/app/forms/meeting/send_email_updates.rb+++ b/modules/meeting/app/forms/meeting/send_email_updates.rb@@ -33,7 +33,11 @@ class Meeting::SendEmailUpdates < ApplicationFormmeeting_form.check_box(name: "notify",label: I18n.t("label_meeting_send_updates"),- checked: @meeting.notify? != false+ checked: @meeting.notify? != false,+ data: {+ "show-when-checked-target": "cause",+ "show-when-checked-target-name": "notification-banner"+ })enddiff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex fbb0a06a1e7..93d7a45421f 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -529,3 +529,6 @@ en:text_agenda_item_move_next_meeting_cancelled: "Unable to move to the next meeting since it 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."++ 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."