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

[37297] automatic meeting agendas and minutes linked to work packages

Jonas Jabari16588d0cc107
diff --git a/app/models/work_package.rb b/app/models/work_package.rb
index 80fe077fb7a..38977b22a01 100644
--- a/app/models/work_package.rb
+++ b/app/models/work_package.rb
@@ -70,6 +70,8 @@ class WorkPackage < ApplicationRecord
has_many :members, as: :entity, dependent: :destroy
has_many :member_principals, through: :members, class_name: 'Principal', source: :principal
+ has_many :meeting_agenda_items, dependent: :destroy # Question: What about finalized minutes within an agenda item?
+
scope :recently_updated, -> {
order(updated_at: :desc)
}
diff --git a/frontend/angular.json b/frontend/angular.json
index 81022024c3a..5cba3a9eb06 100644
--- a/frontend/angular.json
+++ b/frontend/angular.json
@@ -57,8 +57,7 @@
"node_modules/jquery-ui/themes/base/core.css",
"node_modules/jquery-ui/themes/base/datepicker.css",
"node_modules/jquery-ui/themes/base/dialog.css",
- "node_modules/flatpickr/dist/flatpickr.min.css",
- "node_modules/@primer/css/core/index.scss"
+ "node_modules/flatpickr/dist/flatpickr.min.css"
],
"stylePreprocessorOptions": {
"includePaths": [
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index eef1dff0c47..51373fe7cca 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -6,13 +6,9 @@ import { initializeLocale } from 'core-app/core/setup/init-locale';
import { environment } from './environments/environment';
import { configureErrorReporter } from 'core-app/core/errors/configure-reporter';
import { initializeGlobalListeners } from 'core-app/core/setup/globals/global-listeners';
-import * as Turbo from '@hotwired/turbo';
(window as any).global = window;
-// Disable default turbo-drive for now while we
-Turbo.session.drive = false;
-
// Ensure we set the correct dynamic frontend path
// based on the RAILS_RELATIVE_URL_ROOT setting
// https://webpack.js.org/guides/public-path/
@@ -34,6 +30,7 @@ window.ErrorReporter = configureErrorReporter();
require('core-app/core/setup/init-vendors');
require('core-app/core/setup/init-globals');
require('stimulus/setup');
+require('turbo/setup');
if (environment.production) {
enableProdMode();
diff --git a/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.ts b/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.ts
new file mode 100644
index 00000000000..3b65b41f753
--- /dev/null
+++ b/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-drag-and-drop.controller.ts
@@ -0,0 +1,90 @@
+/*
+ * -- copyright
+ * OpenProject is an open source project management software.
+ * Copyright (C) 2023 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 * as Turbo from '@hotwired/turbo';
+import { Controller } from '@hotwired/stimulus';
+import { Drake } from 'dragula';
+import { debugLog } from 'core-app/shared/helpers/debug_output';
+
+export default class extends Controller {
+ drake:Drake|undefined;
+
+ connect() {
+ this.drake = dragula(
+ [this.containerTarget],
+ { moves: (_el, _source, handle, _sibling) => !!handle?.classList.contains('handle') },
+ )
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ .on('drop', this.drop.bind(this));
+ }
+
+ get containerTarget():HTMLElement {
+ const targetTag = this.data.get('target-tag');
+ return this.element.querySelector(targetTag || 'ul') as HTMLElement;
+ }
+
+ async drop(el:Element, _target:Element|null, _source:Element|null, _sibling:Element|null) {
+ const id = el.getAttribute('data-id');
+ const url = el.getAttribute('data-drop-url');
+ const data = new FormData();
+ const newIndex = Array.from(this.containerTarget.children).indexOf(el);
+
+ if (id && url) {
+ data.append('position', (newIndex + 1).toString());
+
+ const response = await fetch(url, {
+ method: 'PUT',
+ body: data,
+ headers: {
+ 'X-CSRF-Token': (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content,
+ Accept: 'text/vnd.turbo-stream.html',
+ },
+ credentials: 'same-origin',
+ });
+
+ if (!response.ok) {
+ debugLog('Failed to sort item');
+ } else {
+ const text = await response.text();
+ Turbo.renderStreamMessage(text);
+ }
+ }
+
+ if (this.drake) {
+ this.drake.cancel(true); // necessary to prevent "copying" behaviour
+ }
+ }
+
+ disconnect() {
+ if (this.drake) {
+ this.drake.destroy();
+ }
+ }
+}
diff --git a/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-form.controller.ts b/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-form.controller.ts
new file mode 100644
index 00000000000..2774d30a142
--- /dev/null
+++ b/frontend/src/stimulus/controllers/dynamic/meeting-agenda-item-form.controller.ts
@@ -0,0 +1,86 @@
+/*
+ * -- copyright
+ * OpenProject is an open source project management software.
+ * Copyright (C) 2023 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 * as Turbo from '@hotwired/turbo';
+import { Controller } from '@hotwired/stimulus';
+
+export default class extends Controller {
+ static values = {
+ cancelUrl: String,
+ };
+
+ declare cancelUrlValue:string;
+
+ static targets = ['titleInput', 'notesInput', 'notesAddButton'];
+ declare readonly titleInputTarget:HTMLInputElement;
+ declare readonly notesInputTarget:HTMLInputElement;
+ declare readonly notesAddButtonTarget:HTMLInputElement;
+
+ connect():void {
+ this.focusInput();
+ }
+
+ focusInput():void {
+ const titleInput = this.element.querySelector('input[name="meeting_agenda_item[title]"]');
+
+ setTimeout(() => {
+ this.element.scrollIntoView();
+ if (titleInput) {
+ (titleInput as HTMLInputElement).focus();
+ }
+ }, 100);
+ }
+
+ async cancel() {
+ const response = await fetch(this.cancelUrlValue, {
+ method: 'GET',
+ headers: {
+ 'X-CSRF-Token': (document.querySelector('meta[name="csrf-token"]') as HTMLMetaElement).content,
+ Accept: 'text/vnd.turbo-stream.html',
+ },
+ });
+
+ if (response.ok) {
+ const text = await response.text();
+ Turbo.renderStreamMessage(text);
+ }
+ }
+
+ addNotes() {
+ this.notesInputTarget.classList.remove('d-none');
+ this.notesAddButtonTarget.classList.add('d-none');
+ const textarea = this.element.querySelector('textarea[name="meeting_agenda_item[notes]"]');
+ setTimeout(() => {
+ if (textarea) {
+ (textarea as HTMLInputElement).focus();
+ }
+ }, 100);
+ }
+}
diff --git a/frontend/src/tsconfig.app.json b/frontend/src/tsconfig.app.json
index aeda6f9c8a5..c388fe443ed 100644
--- a/frontend/src/tsconfig.app.json
+++ b/frontend/src/tsconfig.app.json
@@ -10,7 +10,8 @@
"polyfills.ts",
"app/core/setup/init-globals.ts",
"app/core/setup/init-vendors.ts",
- "stimulus/setup.ts"
+ "stimulus/setup.ts",
+ "turbo/setup.ts"
],
"include": [
"src/**/*.ts",
diff --git a/frontend/src/turbo/setup.ts b/frontend/src/turbo/setup.ts
new file mode 100644
index 00000000000..8e12155c7b3
--- /dev/null
+++ b/frontend/src/turbo/setup.ts
@@ -0,0 +1,5 @@
+import * as Turbo from '@hotwired/turbo';
+// Disable default turbo-drive for now as we don't need it for now AND it breaks angular routing
+Turbo.session.drive = false;
+// Start turbo
+Turbo.start();
diff --git a/modules/meeting/app/components/authors/autocomplete_item_component.rb b/modules/meeting/app/components/authors/autocomplete_item_component.rb
new file mode 100644
index 00000000000..f19e3507ecd
--- /dev/null
+++ b/modules/meeting/app/components/authors/autocomplete_item_component.rb
@@ -0,0 +1,59 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+#
+# Primer's autocomplete displays the ID of a user when selected instead of the name
+# this cannot be changed at the moment as the component uses a simple text field which
+# can't differentiate between a display and submit value
+# thus, we can't use it
+# leaving the code here for future reference
+
+module Authors
+ class AutocompleteItemComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+
+ with_collection_parameter :user
+
+ def initialize(user:)
+ super
+
+ @user = user
+ end
+
+ def call
+ render(
+ Primer::Beta::AutoComplete::Item.new(
+ value: @user.id
+ )
+ ) do |component|
+ component.with_leading_visual_icon(icon: :person)
+ @user.name
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/flash_message_component.rb b/modules/meeting/app/components/flash_message_component.rb
new file mode 100644
index 00000000000..bddfb6cc9fe
--- /dev/null
+++ b/modules/meeting/app/components/flash_message_component.rb
@@ -0,0 +1,62 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class FlashMessageComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(message: nil, full: false, spacious: false, dismissible: false, icon: nil, scheme: :default)
+ super
+
+ @message = message
+ @full = full
+ @spacious = spacious
+ @dismissible = dismissible # TODO: not working yet -> JS dependency not provided?
+ @icon = icon
+ @scheme = scheme
+ end
+
+ def call
+ component_wrapper do
+ # even without provided message, the wrapper should be rendered as this allows
+ # for triggering a flash message via turbo stream
+ if @message.present?
+ flash_partial
+ end
+ end
+ end
+
+ private
+
+ def flash_partial
+ render(Primer::Beta::Flash.new(
+ full: @full, spacious: @spacious, dismissible: @dismissible, icon: @icon, scheme: @scheme
+ )) { @message }
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/form_component.rb b/modules/meeting/app/components/meeting_agenda_items/form_component.rb
new file mode 100644
index 00000000000..d992e0b7fcc
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/form_component.rb
@@ -0,0 +1,164 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class FormComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, meeting_agenda_item:, method:, submit_path:, cancel_path:, type: :simple)
+ super
+
+ @meeting = meeting
+ @meeting_agenda_item = meeting_agenda_item
+ @method = method
+ @submit_path = submit_path
+ @cancel_path = cancel_path
+ @type = type
+ end
+
+ def call
+ component_wrapper(data: wrapper_data_attributes) do
+ primer_form_with(
+ model: @meeting_agenda_item,
+ method: @method,
+ url: @submit_path
+ ) do |f|
+ form_content_partial(f)
+ end
+ end
+ end
+
+ def render?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ private
+
+ def wrapper_data_attributes
+ {
+ controller: 'meeting-agenda-item-form',
+ 'application-target': 'dynamic',
+ 'meeting-agenda-item-form-cancel-url-value': @cancel_path
+ }
+ end
+
+ def form_content_partial(form)
+ flex_layout do |flex|
+ flex.with_row do
+ form_fields_partial(form)
+ end
+ flex.with_row(mt: 2) do
+ form_notes_partial(form)
+ end
+ flex.with_row do
+ form_actions_partial(form)
+ end
+ end
+ end
+
+ def form_fields_partial(form)
+ flex_layout do |flex|
+ flex.with_column(flex: 1) do
+ case @type
+ when :simple
+ render(MeetingAgendaItem::Title.new(form))
+ when :work_package
+ render(MeetingAgendaItem::WorkPackage.new(form))
+ end
+ end
+ flex.with_column(ml: 2) do
+ render(MeetingAgendaItem::Duration.new(form))
+ end
+ end
+ end
+
+ def form_notes_partial(form)
+ render(Primer::Box.new(data: { 'meeting-agenda-item-form-target': "notesInput" },
+ display: display_notes_input_value)) do
+ render(MeetingAgendaItem::Notes.new(form))
+ end
+ end
+
+ def display_notes_input_value
+ @meeting_agenda_item.notes.blank? ? :none : nil
+ end
+
+ def form_actions_partial(form)
+ flex_layout(justify_content: :space_between, mt: 2) do |flex|
+ flex.with_column do
+ additional_elements_partial
+ end
+ flex.with_column do
+ save_or_cancel_partial(form)
+ end
+ end
+ end
+
+ def additional_elements_partial
+ render(Primer::Beta::Button.new(
+ scheme: :secondary,
+ display: display_notes_add_button_value,
+ data: {
+ 'meeting-agenda-item-form-target': "notesAddButton",
+ action: 'click->meeting-agenda-item-form#addNotes keydown.enter->meeting-agenda-item-form#addNotes'
+ }
+ )) do |component|
+ component.with_leading_visual_icon(icon: :plus)
+ MeetingAgendaItem.human_attribute_name(:notes)
+ end
+ end
+
+ def display_notes_add_button_value
+ @meeting_agenda_item.notes.blank? ? nil : :none
+ end
+
+ def save_or_cancel_partial(form)
+ flex_layout(justify_content: :flex_end) do |flex|
+ flex.with_column(mr: 2) do
+ back_link_partial
+ end
+ flex.with_column do
+ render(MeetingAgendaItem::Submit.new(form, type: @type))
+ end
+ end
+ end
+
+ def back_link_partial
+ render(Primer::Beta::Button.new(
+ scheme: :secondary,
+ tag: :a,
+ href: @cancel_path,
+ data: { 'turbo-stream': true }
+ )) do |_c|
+ t("button_cancel")
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component.rb
new file mode 100644
index 00000000000..f62ecdb28ec
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component.rb
@@ -0,0 +1,65 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class ItemComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting_agenda_item:, state: :show)
+ super
+
+ @meeting_agenda_item = meeting_agenda_item
+ @state = state
+ end
+
+ def wrapper_uniq_by
+ @meeting_agenda_item.id
+ end
+
+ def call
+ component_wrapper do
+ case @state
+ when :show
+ render(MeetingAgendaItems::ItemComponent::ShowComponent.new(**child_component_params))
+ when :edit
+ render(MeetingAgendaItems::ItemComponent::EditComponent.new(**child_component_params))
+ end
+ end
+ end
+
+ private
+
+ def child_component_params
+ {
+ meeting_agenda_item: @meeting_agenda_item
+ }
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb
new file mode 100644
index 00000000000..e0cd4ebb163
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/edit_component.rb
@@ -0,0 +1,58 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class ItemComponent::EditComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting_agenda_item:)
+ super
+
+ @meeting_agenda_item = meeting_agenda_item
+ @type = if @meeting_agenda_item.work_package.present?
+ :work_package
+ else
+ :simple
+ end
+ end
+
+ def call
+ render(Primer::Box.new(pl: 3)) do
+ render(MeetingAgendaItems::FormComponent.new(
+ meeting: @meeting_agenda_item.meeting,
+ meeting_agenda_item: @meeting_agenda_item,
+ method: :put,
+ submit_path: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item, format: :turbo_stream),
+ cancel_path: cancel_edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
+ type: @type
+ ))
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
new file mode 100644
index 00000000000..b09a0f2a642
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb
@@ -0,0 +1,262 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class ItemComponent::ShowComponent < ApplicationComponent
+ include ApplicationHelper
+ include AvatarHelper
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting_agenda_item:)
+ super
+
+ @meeting_agenda_item = meeting_agenda_item
+ @meeting = meeting_agenda_item.meeting
+ end
+
+ def call
+ flex_layout do |flex|
+ flex.with_row do
+ first_row_partial
+ end
+ flex.with_row(mt: edit_enabled? ? 1 : 2, pl: 4) do
+ second_row_partial
+ end
+ end
+ end
+
+ private
+
+ def drag_and_drop_enabled?
+ @meeting.open? && User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ def edit_enabled?
+ @meeting.open? && User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ def first_row_partial
+ flex_layout(justify_content: :space_between, align_items: :flex_start) do |flex|
+ flex.with_column(flex: 1) do
+ left_column_partial
+ end
+ flex.with_column do
+ right_column_partial
+ end
+ end
+ end
+
+ def second_row_partial
+ if @meeting_agenda_item.notes.present?
+ description_partial
+ end
+ end
+
+ def left_column_partial
+ flex_layout(align_items: :flex_start) do |flex|
+ flex.with_column(mx: 1, pt: 2) do
+ if drag_and_drop_enabled?
+ drag_handler_partial
+ end
+ end
+ flex.with_column(flex: 1, mt: 2, pl: drag_and_drop_enabled? ? 0 : 3) do
+ if @meeting_agenda_item.visible_work_package?
+ work_package_title_partial
+ elsif @meeting_agenda_item.linked_work_package?
+ work_package_undisclosed_partial
+ else
+ title_partial
+ end
+ end
+ end
+ end
+
+ def right_column_partial
+ flex_layout(align_items: :center, mt: edit_enabled? ? 1 : 2) do |flex|
+ flex.with_column(mr: 2) do
+ title = I18n.t(:label_added_time_by,
+ author: @meeting_agenda_item.author.name,
+ age: helpers.distance_of_time_in_words(Time.zone.now, @meeting_agenda_item.created_at))
+ render(Users::AvatarComponent.new(user: @meeting_agenda_item.author, size: 'mini', title:))
+ end
+ flex.with_column do
+ actions_partial if edit_enabled?
+ end
+ end
+ end
+
+ def drag_handler_partial
+ render(Primer::Beta::Octicon.new(
+ color: :subtle,
+ classes: "handle",
+ style: "cursor: move;",
+ size: :small,
+ icon: :grabber
+ ))
+ end
+
+ def work_package_title_partial
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(mr: 2) do
+ work_package_link_partial
+ end
+ flex.with_column(mr: 2) do
+ work_package_type_and_id_partial
+ end
+ flex.with_column(mr: 2) do
+ work_package_status_partial
+ end
+ flex.with_column do
+ duration_partial
+ end
+ end
+ end
+
+ def work_package_undisclosed_partial
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(mr: 2) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ I18n.t(:label_agenda_item_undisclosed_wp, id: @meeting_agenda_item.work_package_id)
+ end
+ end
+ flex.with_column do
+ duration_partial
+ end
+ end
+ end
+
+ def work_package_link_partial
+ render(Primer::Beta::Link.new(href: work_package_path(@meeting_agenda_item.work_package), underline: false,
+ font_size: :normal, font_weight: :bold, target: "_blank")) do
+ render(Primer::Beta::Truncate.new) do |component|
+ component.with_item(max_width: 300, expandable: true) do
+ @meeting_agenda_item.work_package.subject
+ end
+ end
+ end
+ end
+
+ def work_package_type_and_id_partial
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ "#{@meeting_agenda_item.work_package.type.name} ##{@meeting_agenda_item.work_package.id}"
+ end
+ end
+
+ def work_package_status_partial
+ render(Primer::Beta::Label.new(font_weight: :bold)) do
+ @meeting_agenda_item.work_package.status.name
+ end
+ end
+
+ def duration_partial
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
+ "#{@meeting_agenda_item.duration_in_minutes || 0} min"
+ end
+ end
+
+ def title_partial
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(mr: 2) do
+ render(Primer::Beta::Text.new(font_size: :normal, font_weight: :bold, test_selector: 'op-meeting-agenda-title')) do
+ render(Primer::Beta::Truncate.new) do |component|
+ component.with_item(max_width: 300, expandable: true) { @meeting_agenda_item.title }
+ end
+ end
+ end
+ flex.with_column do
+ duration_partial
+ end
+ end
+ end
+
+ def description_partial
+ render(Primer::Box.new(color: :subtle)) do
+ ::OpenProject::TextFormatting::Renderer.format_text(@meeting_agenda_item.notes)
+ end
+ end
+
+ def time_slot_partial
+ render(Primer::Beta::Text.new(font_size: :normal, color: :subtle)) do
+ [
+ @meeting_agenda_item.start_time.strftime("%H:%M"),
+ "-",
+ @meeting_agenda_item.end_time.strftime("%H:%M"),
+ "(#{@meeting_agenda_item.duration_in_minutes || 0} min)"
+ ].join(" ")
+ end
+ end
+
+ def actions_partial
+ render(Primer::Alpha::ActionMenu.new) do |menu|
+ menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_agenda_item_actions"), scheme: :invisible, test_selector: 'op-meeting-agenda-actions')
+ edit_action_item(menu)
+ move_actions(menu)
+ delete_action_item(menu)
+ end
+ end
+
+ def edit_action_item(menu)
+ menu.with_item(label: t("label_edit"),
+ href: edit_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
+ content_arguments: {
+ data: { 'turbo-stream': true }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :pencil)
+ end
+ end
+
+ def move_actions(menu)
+ move_action_item(menu, :highest, t("label_agenda_item_move_to_top"), "move-to-top") unless @meeting_agenda_item.first?
+ move_action_item(menu, :higher, t("label_agenda_item_move_up"), "chevron-up") unless @meeting_agenda_item.first?
+ move_action_item(menu, :lower, t("label_agenda_item_move_down"), "chevron-down") unless @meeting_agenda_item.last?
+ move_action_item(menu, :lowest, t("label_agenda_item_move_to_bottom"), "move-to-bottom") unless @meeting_agenda_item.last?
+ end
+
+ def delete_action_item(menu)
+ menu.with_item(label: t("text_destroy"),
+ scheme: :danger,
+ href: meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item),
+ form_arguments: {
+ method: :delete, data: { confirm: t("text_are_you_sure"), 'turbo-stream': true }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :trash)
+ end
+ end
+
+ def move_action_item(menu, move_to, label_text, icon)
+ menu.with_item(label: label_text,
+ href: move_meeting_agenda_item_path(@meeting_agenda_item.meeting, @meeting_agenda_item,
+ move_to:),
+ form_arguments: {
+ method: :put, data: { 'turbo-stream': true }
+ }) do |item|
+ item.with_leading_visual_icon(icon:)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/list_component.rb b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
new file mode 100644
index 00000000000..9cd1515146c
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/list_component.rb
@@ -0,0 +1,112 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class ListComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, form_hidden: true, form_type: :simple)
+ super
+
+ @meeting = meeting
+ @form_hidden = form_hidden
+ @form_type = form_type
+ end
+
+ def call
+ component_wrapper(data: wrapper_data_attributes) do
+ render(Primer::Beta::BorderBox.new) do |border_box|
+ if @meeting.agenda_items.empty? && @form_hidden
+ empty_state_partial(border_box)
+ else
+ @meeting.agenda_items.each do |meeting_agenda_item|
+ row_partial(border_box, meeting_agenda_item)
+ end
+ end
+ border_box.with_row(p: 0, border_top: 0) do
+ new_form_partial
+ end
+ end
+ end
+ end
+
+ private
+
+ def wrapper_data_attributes
+ {
+ controller: 'meeting-agenda-item-drag-and-drop',
+ 'application-target': 'dynamic',
+ 'target-tag': 'ul'
+ }
+ end
+
+ def empty_state_partial(border_box)
+ border_box.with_body(
+ scheme: :default
+ ) do
+ blank_slate_partial
+ end
+ end
+
+ def blank_slate_partial
+ render(Primer::Beta::Blankslate.new) do |component|
+ component.with_visual_icon(icon: :book)
+ component.with_heading(tag: :h2).with_content(t("text_meeting_empty_heading"))
+ component.with_description do
+ flex_layout do |flex|
+ flex.with_row(mb: 2) do
+ render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_1") }
+ end
+ flex.with_row do
+ render(Primer::Beta::Text.new(color: :subtle)) { t("text_meeting_empty_description_2") }
+ end
+ end
+ end
+ end
+ end
+
+ def row_partial(border_box, meeting_agenda_item)
+ border_box.with_row(
+ pl: 0,
+ scheme: :default,
+ data: {
+ id: meeting_agenda_item.id,
+ 'drop-url': drop_meeting_agenda_item_path(meeting_agenda_item.meeting, meeting_agenda_item)
+ }
+ ) do
+ render(MeetingAgendaItems::ItemComponent.new(meeting_agenda_item:))
+ end
+ end
+
+ def new_form_partial
+ render(MeetingAgendaItems::NewComponent.new(meeting: @meeting, hidden: @form_hidden, type: @form_type))
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
new file mode 100644
index 00000000000..d40be4f2262
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/new_button_component.rb
@@ -0,0 +1,80 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class NewButtonComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, meeting_agenda_item: nil, disabled: false)
+ super
+
+ @meeting = meeting
+ @meeting_agenda_item = meeting_agenda_item || MeetingAgendaItem.new(meeting:, author: User.current)
+ @disabled = @meeting.closed? || disabled
+ end
+
+ def call
+ component_wrapper(class: "mt-3") do
+ menu_content_partial
+ end
+ end
+
+ def render?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ private
+
+ def menu_content_partial
+ render(Primer::Alpha::ActionMenu.new) do |component|
+ component.with_show_button(scheme: :primary, disabled: @disabled) do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ t("button_add")
+ end
+ component.with_item(
+ label: t("activerecord.models.meeting_agenda_item", count: 1),
+ tag: :a,
+ content_arguments: {
+ href: new_meeting_agenda_item_path(@meeting, type: "simple"),
+ data: { 'turbo-stream': true }
+ }
+ )
+ component.with_item(
+ label: t("activerecord.models.work_package", count: 1),
+ tag: :a,
+ content_arguments: {
+ href: new_meeting_agenda_item_path(@meeting, type: "work_package"),
+ data: { 'turbo-stream': true }
+ }
+ )
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meeting_agenda_items/new_component.rb b/modules/meeting/app/components/meeting_agenda_items/new_component.rb
new file mode 100644
index 00000000000..6800e4ed761
--- /dev/null
+++ b/modules/meeting/app/components/meeting_agenda_items/new_component.rb
@@ -0,0 +1,69 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class NewComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, meeting_agenda_item: nil, hidden: true, type: :simple)
+ super
+
+ @meeting = meeting
+ @meeting_agenda_item = meeting_agenda_item || MeetingAgendaItem.new(meeting:, author: User.current)
+ @hidden = hidden
+ @type = type
+ end
+
+ def call
+ component_wrapper do
+ unless @hidden
+ form_partial
+ end
+ end
+ end
+
+ private
+
+ def form_partial
+ render(Primer::Box.new(border: :top)) do
+ render(Primer::Box.new(p: 3)) do
+ render(MeetingAgendaItems::FormComponent.new(
+ meeting: @meeting,
+ meeting_agenda_item: @meeting_agenda_item,
+ method: :post,
+ submit_path: meeting_agenda_items_path(@meeting, format: :turbo_stream),
+ cancel_path: cancel_new_meeting_agenda_items_path(@meeting),
+ type: @type
+ ))
+ end
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/header_component.rb b/modules/meeting/app/components/meetings/header_component.rb
new file mode 100644
index 00000000000..8804eb93054
--- /dev/null
+++ b/modules/meeting/app/components/meetings/header_component.rb
@@ -0,0 +1,195 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 HeaderComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:, state: :show)
+ super
+
+ @meeting = meeting
+ @state = state
+ end
+
+ def call
+ component_wrapper do
+ case @state
+ when :show
+ show_partial
+ when :edit
+ edit_partial if edit_enabled?
+ end
+ end
+ end
+
+ private
+
+ def edit_enabled?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ def delete_enabled?
+ User.current.allowed_to?(:delete_meetings, @meeting.project)
+ end
+
+ def show_partial
+ flex_layout do |flex|
+ flex.with_row do
+ title_and_actions_partial
+ end
+ flex.with_row do
+ meta_info_partial
+ end
+ end
+ end
+
+ def title_and_actions_partial
+ flex_layout(justify_content: :space_between, align_items: :center) do |flex|
+ flex.with_column(flex: 1) do
+ title_partial
+ end
+ flex.with_column do
+ actions_partial
+ end
+ end
+ end
+
+ def title_partial
+ render(Primer::Beta::Heading.new(tag: :h1)) { @meeting.title }
+ end
+
+ def actions_partial
+ render(Primer::Alpha::ActionMenu.new) do |menu|
+ menu.with_show_button(icon: "kebab-horizontal", 'aria-label': t("label_meeting_actions"), test_selector: 'op-meetings-header-action-trigger')
+ edit_action_item(menu) if edit_enabled?
+ delete_action_item(menu) if delete_enabled?
+ end
+ end
+
+ def edit_action_item(menu)
+ menu.with_item(label: t("label_meeting_edit_title"),
+ href: edit_meeting_path(@meeting),
+ content_arguments: {
+ data: { 'turbo-stream': true }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :pencil)
+ end
+ end
+
+ def delete_action_item(menu)
+ menu.with_item(label: t("label_meeting_delete"),
+ scheme: :danger,
+ href: meeting_path(@meeting),
+ form_arguments: {
+ method: :delete, data: { confirm: t("text_are_you_sure"), turbo: 'false' }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :trash)
+ end
+ end
+
+ def meta_info_partial
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(mr: 1) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_created_by") }
+ end
+ flex.with_column(mr: 1) do
+ author_link_partial
+ end
+ flex.with_column(mr: 1) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("label_meeting_last_updated") }
+ end
+ flex.with_column do
+ render(Primer::Beta::RelativeTime.new(font_size: :small, color: :subtle, datetime: last_updated_at))
+ end
+ end
+ end
+
+ def author_link_partial
+ render(Primer::Beta::Link.new(font_size: :small, href: user_path(@meeting.author), underline: false,
+ target: "_blank")) do
+ "#{@meeting.author.name}."
+ end
+ end
+
+ def last_updated_at
+ latest_agenda_update = @meeting.agenda_items.maximum(:updated_at) || @meeting.updated_at
+ latest_meeting_update = @meeting.updated_at
+
+ [latest_agenda_update, latest_meeting_update].max
+ end
+
+ def edit_partial
+ flex_layout do |flex|
+ flex.with_row(mb: 2) do
+ title_form_partial
+ end
+ flex.with_row do
+ meta_info_partial
+ end
+ end
+ end
+
+ def title_form_partial
+ primer_form_with(
+ model: @meeting,
+ method: :put,
+ url: update_title_meeting_path(@meeting)
+ ) do |f|
+ form_content_partial(f)
+ end
+ end
+
+ def form_content_partial(form)
+ flex_layout do |flex|
+ flex.with_column(flex: 1, mr: 2) do
+ render(Meeting::Title.new(form))
+ end
+ flex.with_column(mr: 2) do
+ render(Meeting::Submit.new(form))
+ end
+ flex.with_column do
+ back_link_partial
+ end
+ end
+ end
+
+ def back_link_partial
+ render(Primer::Beta::Button.new(
+ scheme: :secondary,
+ tag: :a,
+ href: cancel_edit_meeting_path(@meeting),
+ data: { 'turbo-stream': true }
+ )) do |_c|
+ t("button_cancel")
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/row_component.rb b/modules/meeting/app/components/meetings/row_component.rb
index 8d2d060c74e..60d0219718e 100644
--- a/modules/meeting/app/components/meetings/row_component.rb
+++ b/modules/meeting/app/components/meetings/row_component.rb
@@ -38,6 +38,14 @@ module Meetings
link_to model.title, meeting_path(model)
end
+ def type
+ if model.is_a?(StructuredMeeting)
+ I18n.t('meeting.types.structured')
+ else
+ I18n.t('meeting.types.classic')
+ end
+ end
+
def start_time
safe_join([helpers.format_date(model.start_time), helpers.format_time(model.start_time, false)], " ")
end
diff --git a/modules/meeting/app/components/meetings/show_component.rb b/modules/meeting/app/components/meetings/show_component.rb
new file mode 100644
index 00000000000..9d2cd397975
--- /dev/null
+++ b/modules/meeting/app/components/meetings/show_component.rb
@@ -0,0 +1,85 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 ShowComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ flex_layout(data: { turbo: true }) do |flex|
+ flex.with_row do
+ # prototyical usage of Primer's flash message component wrapped in a component which can be updated via turbo stream
+ # empty initially
+ # should become part of the application layout once finalized
+ render(FlashMessageComponent.new)
+ end
+ flex.with_row(mt: 2, mb: 3, pb: 2, border: :bottom) do
+ heading_partial
+ end
+ flex.with_row do
+ main_content_partial
+ end
+ end
+ end
+
+ private
+
+ def heading_partial
+ render(Meetings::HeaderComponent.new(meeting: @meeting))
+ end
+
+ def main_content_partial
+ render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |component|
+ component.with_main { agenda_partial }
+ component.with_sidebar(row_placement: :end, col_placement: :end, width: :wide) { sidebar_partial }
+ end
+ end
+
+ def agenda_partial
+ flex_layout do |flex|
+ flex.with_row do
+ render(MeetingAgendaItems::ListComponent.new(meeting: @meeting))
+ end
+ flex.with_row do
+ render(MeetingAgendaItems::NewButtonComponent.new(meeting: @meeting))
+ end
+ end
+ end
+
+ def sidebar_partial
+ render(Meetings::SidebarComponent.new(meeting: @meeting))
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/sidebar/details_component.rb b/modules/meeting/app/components/meetings/sidebar/details_component.rb
new file mode 100644
index 00000000000..540ff73b5d8
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar/details_component.rb
@@ -0,0 +1,176 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Sidebar::DetailsComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ component_wrapper do
+ flex_layout do |flex|
+ flex.with_row do
+ heading_partial
+ end
+ flex.with_row(mt: 2) do
+ details_partial
+ end
+ end
+ end
+ end
+
+ private
+
+ def edit_enabled?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ def heading_partial
+ flex_layout(align_items: :center, justify_content: :space_between) do |flex|
+ flex.with_column(flex: 1) do
+ render(Primer::Beta::Heading.new(tag: :h4)) { t("label_meeting_details") }
+ end
+ if edit_enabled?
+ flex.with_column do
+ dialog_wrapper_partial
+ end
+ end
+ end
+ end
+
+ def dialog_wrapper_partial
+ render(Primer::Alpha::Dialog.new(
+ id: "edit-meeting-details-dialog", title: t("label_meeting_details"),
+ size: :medium_portrait
+ )) do |dialog|
+ dialog.with_show_button(icon: :pencil, 'aria-label': t("label_meeting_details_edit"), scheme: :invisible)
+ render(Meetings::Sidebar::DetailsFormComponent.new(meeting: @meeting))
+ end
+ end
+
+ def details_partial
+ flex_layout do |flex|
+ flex.with_row do
+ date_partial
+ end
+ flex.with_row(mt: 2) do
+ time_partial
+ end
+ flex.with_row(mt: 2) do
+ duration_partial
+ end
+ if @meeting.location.present?
+ flex.with_row(mt: 2) do
+ location_partial
+ end
+ end
+ end
+ end
+
+ def date_partial
+ meeting_attribute_row(:calendar) do
+ render(Primer::Beta::Text.new) do
+ format_date(@meeting.start_time)
+ end
+ end
+ end
+
+ def time_partial
+ meeting_attribute_row(:clock) do
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column do
+ render(Primer::Beta::Text.new) do
+ "#{format_time(@meeting.start_time, false)} - #{format_time(@meeting.end_time, false)}"
+ end
+ end
+ flex.with_column(ml: 2) do
+ render(Primer::Beta::Text.new(color: :subtle, font_size: :small)) do
+ Time.zone.to_s[/\((.*?)\)/m, 1]
+ end
+ end
+ end
+ end
+ end
+
+ def duration_partial
+ duration = Duration.new(seconds: @meeting.duration * 3600)
+
+ meeting_attribute_row(:stopwatch) do
+ if duration.hours > 0
+ render(Primer::Beta::Text.new) do
+ "#{duration.hours} h #{duration.minutes} min"
+ end
+ else
+ render(Primer::Beta::Text.new) do
+ "#{duration.minutes} min"
+ end
+ end
+ end
+ end
+
+ def location_partial
+ if @meeting.location.include?("http")
+ meeting_attribute_row(:link) do
+ render(Primer::Beta::Link.new(href: @meeting.location, target: "_blank")) do
+ truncated_location
+ end
+ end
+ else
+ meeting_attribute_row(:location) do
+ render(Primer::Beta::Text.new) do
+ truncated_location
+ end
+ end
+ end
+ end
+
+ def truncated_location
+ render(Primer::Beta::Truncate.new) do |component|
+ component.with_item(max_width: 250) do
+ @meeting.location
+ end
+ end
+ end
+
+ def meeting_attribute_row(icon, &)
+ flex_layout(align_items: :center, justify_content: :space_between) do |flex|
+ flex.with_column do
+ render(Primer::Beta::Octicon.new(icon:))
+ end
+ flex.with_column(flex: 1, ml: 1, &)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/sidebar/details_form_component.rb b/modules/meeting/app/components/meetings/sidebar/details_form_component.rb
new file mode 100644
index 00000000000..50771b99943
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar/details_form_component.rb
@@ -0,0 +1,102 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Sidebar::DetailsFormComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ component_wrapper do
+ primer_form_with(
+ model: @meeting,
+ method: :put,
+ url: update_details_meeting_path(@meeting)
+ ) do |f|
+ component_collection do |collection|
+ collection.with_component(Primer::Alpha::Dialog::Body.new) do
+ form_content_partial(f)
+ end
+ collection.with_component(Primer::Alpha::Dialog::Footer.new) do
+ form_actions_partial
+ end
+ end
+ end
+ end
+ end
+
+ def render?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ private
+
+ def form_content_partial(form)
+ flex_layout(my: 3) do |flex|
+ flex.with_row do
+ render(Meeting::StartDate.new(form, initial_value: start_date_initial_value))
+ end
+ flex.with_row(mt: 3) do
+ render(Meeting::StartTime.new(form, initial_value: start_time_initial_value))
+ end
+ flex.with_row(mt: 3) do
+ render(Meeting::Duration.new(form))
+ end
+ flex.with_row(mt: 3) do
+ render(Meeting::Location.new(form))
+ end
+ end
+ end
+
+ def start_date_initial_value
+ @meeting.start_time&.strftime("%Y-%m-%d")
+ end
+
+ def start_time_initial_value
+ @meeting.start_time&.strftime("%H:%M")
+ end
+
+ def form_actions_partial
+ component_collection do |collection|
+ collection.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-meeting-details-dialog" })) do
+ t("button_cancel")
+ end
+ collection.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do
+ t("button_save")
+ end
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_component.rb
new file mode 100644
index 00000000000..10e6f279731
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar/participants_component.rb
@@ -0,0 +1,197 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Sidebar::ParticipantsComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ component_wrapper do
+ flex_layout do |flex|
+ flex.with_row do
+ heading_partial
+ end
+ flex.with_row(mt: 2) do
+ participant_list_partial(5)
+ end
+ if edit_enabled?
+ flex.with_row(mt: 3) do
+ manage_button_partial
+ end
+ end
+ end
+ end
+ end
+
+ private
+
+ def edit_enabled?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ def heading_partial
+ flex_layout(align_items: :center, justify_content: :space_between) do |flex|
+ flex.with_column(flex: 1) do
+ title_partial
+ end
+ if edit_enabled?
+ flex.with_column do
+ dialog_wrapper_partial
+ end
+ end
+ end
+ end
+
+ def title_partial
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(mr: 2) do
+ render(Primer::Beta::Heading.new(tag: :h4)) { Meeting.human_attribute_name(:participants) }
+ end
+ flex.with_column do
+ render(Primer::Beta::Counter.new(count: @meeting.invited_or_attended_participants.count, scheme: :primary))
+ end
+ end
+ end
+
+ def dialog_wrapper_partial
+ render(Primer::Alpha::Dialog.new(
+ id: "edit-participants-dialog", title: Meeting.human_attribute_name(:participants),
+ size: :medium_portrait
+ )) do |dialog|
+ dialog.with_show_button(icon: :gear, 'aria-label': t("label_meeting_manage_participants"), scheme: :invisible)
+ render(Meetings::Sidebar::ParticipantsFormComponent.new(meeting: @meeting))
+ end
+ end
+
+ def participant_list_partial(max_initially_shown_participants)
+ count = @meeting.invited_or_attended_participants.count
+
+ if count == 0
+ render(Primer::Beta::Text.new(color: :subtle)) { t("label_meeting_no_participants") }
+ elsif count <= max_initially_shown_participants
+ unsplit_participant_list
+ elsif count > max_initially_shown_participants
+ split_participant_list(max_initially_shown_participants)
+ end
+ end
+
+ def unsplit_participant_list
+ flex_layout do |flex|
+ @meeting.invited_or_attended_participants.sort.each do |participant|
+ flex.with_row(mt: 1) do
+ participant_partial(participant)
+ end
+ end
+ end
+ end
+
+ def split_participant_list(max_initially_shown_participants)
+ flex_layout do |flex|
+ @meeting.invited_or_attended_participants.sort.take(max_initially_shown_participants).each do |participant|
+ flex.with_row(mt: 1) do
+ participant_partial(participant)
+ end
+ end
+ flex.with_row(mt: 2) do
+ more_participants_partial(max_initially_shown_participants)
+ end
+ end
+ end
+
+ def more_participants_partial(max_initially_shown_participants)
+ render Primer::Beta::Details.new do |component|
+ flex_layout do |flex|
+ flex.with_row do
+ component.with_summary(size: :small, scheme: :link) do
+ t('label_meeting_show_hide_participants',
+ count: @meeting.invited_or_attended_participants.count - max_initially_shown_participants).to_s
+ end
+ end
+ flex.with_row do
+ component.with_body do
+ hidden_participants_partial(max_initially_shown_participants)
+ end
+ end
+ end
+ end
+ end
+
+ def hidden_participants_partial(max_initially_shown_participants)
+ flex_layout do |flex|
+ @meeting.invited_or_attended_participants.sort[max_initially_shown_participants..].each do |participant|
+ flex.with_row(mt: 1) do
+ participant_partial(participant)
+ end
+ end
+ end
+ end
+
+ def participant_partial(participant)
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column do
+ render(Users::AvatarComponent.new(user: participant.user,
+ size: :medium))
+ end
+ participant_state_partial(participant, flex)
+ end
+ end
+
+ def participant_state_partial(participant, flex)
+ if participant.attended?
+ flex.with_column(ml: 1) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("description_attended").capitalize }
+ end
+ elsif participant.invited?
+ flex.with_column(ml: 1) do
+ render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) { t("description_invite").capitalize }
+ end
+ end
+ end
+
+ def manage_button_partial
+ render(Primer::Beta::Button.new(
+ scheme: :link,
+ color: :default,
+ underline: false,
+ font_weight: :bold,
+ data: { 'show-dialog-id': "edit-participants-dialog" }
+ )) do |button|
+ button.with_leading_visual_icon(icon: "person-add")
+ t("label_meeting_add_participants")
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb b/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb
new file mode 100644
index 00000000000..5fb307c6adc
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar/participants_form_component.rb
@@ -0,0 +1,230 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Sidebar::ParticipantsFormComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpenProject::FormTagHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ component_wrapper do
+ form_partial
+ end
+ end
+
+ def render?
+ User.current.allowed_to?(:edit_meetings, @meeting.project)
+ end
+
+ private
+
+ def form_partial
+ primer_form_with(
+ model: @meeting,
+ method: :put,
+ url: update_participants_meeting_path(@meeting)
+ ) do |f|
+ component_collection do |collection|
+ collection.with_component(Primer::Alpha::Dialog::Body.new(style: "max-height: 460px;", my: 3)) do
+ flex_layout(mt: 3) do |flex|
+ flex.with_row do
+ header_partial
+ end
+ flex.with_row do
+ form_content_partial(f)
+ end
+ end
+ end
+ collection.with_component(Primer::Alpha::Dialog::Footer.new(show_divider: true)) do
+ form_actions_partial
+ end
+ end
+ end
+ end
+
+ def header_partial
+ flex_layout(justify_content: :flex_end) do |flex|
+ flex.with_column(style: "width: 90px;", text_align: :center) do
+ render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_invite").capitalize }
+ end
+ flex.with_column(style: "width: 90px;", text_align: :center) do
+ render(Primer::Beta::Text.new(font_weight: :emphasized)) { t("description_attended").capitalize }
+ end
+ end
+ end
+
+ def form_content_partial(_form)
+ flex_layout(my: 3) do |flex|
+ @meeting.all_changeable_participants.sort.each do |user|
+ flex.with_row do
+ hidden_field_tag "meeting[participants_attributes][][user_id]", user.id
+ end
+ participant_form_partial(user, flex)
+ end
+ end
+ end
+
+ def participant_form_partial(user, flex)
+ flex.with_row(mb: 2, pb: 1, border: :bottom) do
+ if @meeting.participants.present? && participant = @meeting.participants.detect { |p| p.user_id == user.id }
+ exisiting_participant_form_partial(participant)
+ else
+ new_participant_form_partial(user)
+ end
+ end
+ end
+
+ def exisiting_participant_form_partial(participant)
+ flex_layout do |flex|
+ flex.with_row do
+ hidden_field_tag "meeting[participants_attributes][][id]", participant.id
+ end
+ flex.with_row do
+ exisiting_participant_form_checkboxes_partial(participant)
+ end
+ end
+ end
+
+ def exisiting_participant_form_checkboxes_partial(participant)
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(flex: 1) do
+ render(Users::AvatarComponent.new(
+ user: participant.user,
+ ))
+ end
+ flex.with_column(style: "width: 90px;", text_align: :center) do
+ invited_participant_checkbox_partial(participant)
+ end
+ flex.with_column(style: "width: 90px;", text_align: :center) do
+ attended_participant_checkbox_partial(participant)
+ end
+ end
+ end
+
+ def invited_participant_checkbox_partial(participant)
+ styled_check_box_tag "meeting[participants_attributes][][invited]", 1, participant.invited?,
+ id: "checkbox_invited_#{participant.user.id}"
+ # Primer checkboxes currently not working in this context as they render an additional hidden input tag
+ # messing up the nested attributes mapping when posting the data to the server
+ #
+ # render(Primer::Alpha::CheckBox.new(
+ # name: "meeting[participants_attributes][][invited]",
+ # checked: participant.invited?,
+ # id: "checkbox_invited_#{participant.user.id}",
+ # visually_hide_label: true,
+ # label: "Invited",
+ # scheme: :boolean,
+ # unchecked_value: ""
+ # ))
+ end
+
+ def attended_participant_checkbox_partial(participant)
+ styled_check_box_tag "meeting[participants_attributes][][attended]", 1, participant.attended?,
+ id: "checkbox_attended_#{participant.user.id}"
+ # Primer checkboxes currently not working in this context as they render an additional hidden input tag
+ # messing up the nested attributes mapping when posting the data to the server
+ #
+ # render(Primer::Alpha::CheckBox.new(
+ # name: "meeting[participants_attributes][][attended]",
+ # checked: participant.attended?,
+ # id: "checkbox_attended_#{participant.user.id}",
+ # visually_hide_label: true,
+ # label: "Attended",
+ # scheme: :boolean,
+ # unchecked_value: ""
+ # ))
+ end
+
+ def new_participant_form_partial(user)
+ flex_layout(align_items: :center) do |flex|
+ flex.with_column(flex: 1) do
+ render(Users::AvatarComponent.new(
+ user:,
+ ))
+ end
+ flex.with_column(style: "width: 90px;", text_align: :center) do
+ invited_user_checkbox_partial(user)
+ end
+ flex.with_column(style: "width: 90px;", text_align: :center) do
+ attended_user_checkbox_partial(user)
+ end
+ end
+ end
+
+ def invited_user_checkbox_partial(user)
+ styled_check_box_tag "meeting[participants_attributes][][invited]", value = "1", checked = false,
+ id: "checkbox_invited_#{user.id}"
+ # Primer checkboxes currently not working in this context as they render an additional hidden input tag
+ # messing up the nested attributes mapping when posting the data to the server
+ #
+ # render(Primer::Alpha::CheckBox.new(
+ # name: "meeting[participants_attributes][][invited]",
+ # id: "checkbox_invited_#{user.id}",
+ # visually_hide_label: true,
+ # label: "Invited",
+ # scheme: :boolean,
+ # unchecked_value: ""
+ # ))
+ end
+
+ def attended_user_checkbox_partial(user)
+ styled_check_box_tag "meeting[participants_attributes][][attended]", value = "1", checked = false,
+ id: "checkbox_attended_#{user.id}"
+ # Primer checkboxes currently not working in this context as they render an additional hidden input tag
+ # messing up the nested attributes mapping when posting the data to the server
+ #
+ # render(Primer::Alpha::CheckBox.new(
+ # name: "meeting[participants_attributes][][attended]",
+ # id: "checkbox_attended_#{user.id}",
+ # visually_hide_label: true,
+ # label: "Attended",
+ # scheme: :boolean,
+ # unchecked_value: ""
+ # ))
+ end
+
+ def form_actions_partial
+ component_collection do |collection|
+ collection.with_component(Primer::ButtonComponent.new(data: { 'close-dialog-id': "edit-participants-dialog" })) do
+ t("button_cancel")
+ end
+ collection.with_component(Primer::ButtonComponent.new(scheme: :primary, type: :submit)) do
+ t("button_save")
+ end
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/sidebar/state_component.rb b/modules/meeting/app/components/meetings/sidebar/state_component.rb
new file mode 100644
index 00000000000..13f83ed3090
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar/state_component.rb
@@ -0,0 +1,174 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 Sidebar::StateComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ component_wrapper do
+ case @meeting.state
+ when "open"
+ open_state_partial
+ when "closed"
+ closed_state_partial
+ end
+ end
+ end
+
+ private
+
+ def edit_enabled?
+ User.current.allowed_to?(:close_meeting_agendas, @meeting.project)
+ end
+
+ def open_state_partial
+ flex_layout do |flex|
+ flex.with_row do
+ open_state_label_partial
+ end
+ flex.with_row(mt: 3) do
+ open_description_partial
+ end
+ if edit_enabled?
+ flex.with_row(mt: 3) do
+ open_actions_partial
+ end
+ end
+ end
+ end
+
+ def open_state_label_partial
+ render(Primer::Beta::State.new(title: "state", scheme: :open)) do
+ flex_layout do |flex|
+ flex.with_column(mr: 1) do
+ render(Primer::Beta::Octicon.new(icon: "issue-opened"))
+ end
+ flex.with_column do
+ render(Primer::Beta::Text.new) { t("label_meeting_state_open") }
+ end
+ end
+ end
+ end
+
+ def open_description_partial
+ render(Primer::Beta::Text.new(color: :subtle)) do
+ t("text_meeting_open_description")
+ end
+ end
+
+ def open_actions_partial
+ form_for(@meeting, method: "put", url: change_state_meeting_path(@meeting),
+ data: { 'turbo-stream': true }) do |f|
+ flex_layout do |flex|
+ flex.with_row do
+ f.hidden_field :state, value: "closed"
+ end
+ flex.with_row do
+ render(Primer::Beta::Button.new(
+ scheme: :link,
+ color: :default,
+ underline: false,
+ font_weight: :bold,
+ type: :submit
+ )) do |button|
+ button.with_leading_visual_icon(icon: :lock)
+ t("label_meeting_close_action")
+ end
+ end
+ end
+ end
+ end
+
+ def closed_state_partial
+ flex_layout do |flex|
+ flex.with_row do
+ closed_state_label_partial
+ end
+ flex.with_row(mt: 3) do
+ closed_description_partial
+ end
+ if edit_enabled?
+ flex.with_row(mt: 3) do
+ closed_actions_partial
+ end
+ end
+ end
+ end
+
+ def closed_state_label_partial
+ render(Primer::Beta::State.new(title: "state", scheme: :default)) do
+ flex_layout do |flex|
+ flex.with_column(mr: 1) do
+ render(Primer::Beta::Octicon.new(icon: "issue-closed"))
+ end
+ flex.with_column do
+ render(Primer::Beta::Text.new) { t("label_meeting_state_closed") }
+ end
+ end
+ end
+ end
+
+ def closed_description_partial
+ render(Primer::Beta::Text.new(color: :subtle)) do
+ t("text_meeting_closed_description")
+ end
+ end
+
+ def closed_actions_partial
+ form_for(@meeting, method: "put", url: change_state_meeting_path(@meeting),
+ data: { 'turbo-stream': true }) do |f|
+ flex_layout do |flex|
+ flex.with_row do
+ f.hidden_field :state, value: "open"
+ end
+ flex.with_row do
+ render(Primer::Beta::Button.new(
+ scheme: :link,
+ color: :default,
+ underline: false,
+ font_weight: :bold,
+ type: :submit
+ )) do |button|
+ button.with_leading_visual_icon(icon: :unlock)
+ t("label_meeting_reopen_action")
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/sidebar_component.rb b/modules/meeting/app/components/meetings/sidebar_component.rb
new file mode 100644
index 00000000000..b4d1318ff7e
--- /dev/null
+++ b/modules/meeting/app/components/meetings/sidebar_component.rb
@@ -0,0 +1,71 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 SidebarComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+
+ def call
+ component_wrapper do
+ flex_layout(pl: 1) do |flex|
+ flex.with_row(border: :bottom, pb: 2) do
+ details_partial
+ end
+ flex.with_row(mt: 3, border: :bottom, pb: 2) do
+ state_partial
+ end
+ flex.with_row(mt: 3) do
+ participants_partial
+ end
+ end
+ end
+ end
+
+ private
+
+ def details_partial
+ render(Meetings::Sidebar::DetailsComponent.new(meeting: @meeting))
+ end
+
+ def state_partial
+ render(Meetings::Sidebar::StateComponent.new(meeting: @meeting))
+ end
+
+ def participants_partial
+ render(Meetings::Sidebar::ParticipantsComponent.new(meeting: @meeting))
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/table_component.rb b/modules/meeting/app/components/meetings/table_component.rb
index 3f13143ac51..a4cbc4f4974 100644
--- a/modules/meeting/app/components/meetings/table_component.rb
+++ b/modules/meeting/app/components/meetings/table_component.rb
@@ -32,7 +32,7 @@ module Meetings
class TableComponent < ::TableComponent
options :current_project # used to determine if displaying the projects column
- sortable_columns :title, :project_name, :start_time, :duration, :location
+ sortable_columns :title, :project_name, :type, :start_time, :duration, :location
def initial_sort
%i[start_time asc]
@@ -56,6 +56,7 @@ module Meetings
@headers ||= [
[:title, { caption: Meeting.human_attribute_name(:title) }],
current_project.blank? ? [:project_name, { caption: Meeting.human_attribute_name(:project) }] : nil,
+ [:type, { caption: Meeting.human_attribute_name(:type) }],
[:start_time, { caption: Meeting.human_attribute_name(:start_time) }],
[:duration, { caption: Meeting.human_attribute_name(:duration) }],
[:location, { caption: Meeting.human_attribute_name(:location) }]
diff --git a/modules/meeting/app/contracts/meeting_agenda_items/base_contract.rb b/modules/meeting/app/contracts/meeting_agenda_items/base_contract.rb
new file mode 100644
index 00000000000..4c021e6e176
--- /dev/null
+++ b/modules/meeting/app/contracts/meeting_agenda_items/base_contract.rb
@@ -0,0 +1,45 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class BaseContract < ::ModelContract
+ include EditableItem
+
+ def self.model
+ MeetingAgendaItem
+ end
+
+ attribute :meeting
+ attribute :work_package
+
+ attribute :position
+ attribute :title
+ attribute :duration_in_minutes
+ attribute :notes
+ end
+end
diff --git a/modules/meeting/app/contracts/meeting_agenda_items/create_contract.rb b/modules/meeting/app/contracts/meeting_agenda_items/create_contract.rb
new file mode 100644
index 00000000000..b083853fbc5
--- /dev/null
+++ b/modules/meeting/app/contracts/meeting_agenda_items/create_contract.rb
@@ -0,0 +1,32 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class CreateContract < BaseContract
+ end
+end
diff --git a/modules/meeting/app/contracts/meeting_agenda_items/delete_contract.rb b/modules/meeting/app/contracts/meeting_agenda_items/delete_contract.rb
new file mode 100644
index 00000000000..e0694742acb
--- /dev/null
+++ b/modules/meeting/app/contracts/meeting_agenda_items/delete_contract.rb
@@ -0,0 +1,35 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class DeleteContract < ::DeleteContract
+ include EditableItem
+
+ delete_permission :edit_meetings
+ end
+end
diff --git a/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rb b/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rb
new file mode 100644
index 00000000000..1ee14797445
--- /dev/null
+++ b/modules/meeting/app/contracts/meeting_agenda_items/editable_item.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ module EditableItem
+ extend ActiveSupport::Concern
+
+ included do
+ validate :validate_editable
+ end
+
+ protected
+
+
+ def validate_editable
+ unless model.editable?
+ errors.add :base, I18n.t(:text_meeting_not_editable_anymore)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/contracts/meeting_agenda_items/update_contract.rb b/modules/meeting/app/contracts/meeting_agenda_items/update_contract.rb
new file mode 100644
index 00000000000..39edd467484
--- /dev/null
+++ b/modules/meeting/app/contracts/meeting_agenda_items/update_contract.rb
@@ -0,0 +1,32 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class UpdateContract < BaseContract
+ end
+end
diff --git a/modules/meeting/app/controllers/concerns/application_component_streams.rb b/modules/meeting/app/controllers/concerns/application_component_streams.rb
new file mode 100644
index 00000000000..49b68c2e205
--- /dev/null
+++ b/modules/meeting/app/controllers/concerns/application_component_streams.rb
@@ -0,0 +1,43 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 ApplicationComponentStreams
+ extend ActiveSupport::Concern
+
+ included do
+ def render_error_flash_message_via_turbo_stream(**kwargs)
+ update_flash_message_via_turbo_stream(**kwargs.merge(scheme: :danger, icon: :stop))
+ end
+
+ def update_flash_message_via_turbo_stream(**)
+ replace_via_turbo_stream(
+ component: FlashMessageComponent.new(**)
+ )
+ end
+ end
+end
diff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
new file mode 100644
index 00000000000..003888ffd47
--- /dev/null
+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb
@@ -0,0 +1,150 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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
+ module AgendaComponentStreams
+ extend ActiveSupport::Concern
+
+ included do
+ def update_header_component_via_turbo_stream(meeting: @meeting, state: :show)
+ update_via_turbo_stream(
+ component: Meetings::HeaderComponent.new(
+ meeting:,
+ state:
+ )
+ )
+ end
+
+ def update_sidebar_component_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: Meetings::SidebarComponent.new(
+ meeting:
+ )
+ )
+ end
+
+ def update_sidebar_details_component_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: Meetings::Sidebar::DetailsComponent.new(
+ meeting:
+ )
+ )
+ end
+
+ def update_sidebar_state_component_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: Meetings::Sidebar::StateComponent.new(
+ meeting:
+ )
+ )
+ end
+
+ def update_sidebar_details_form_component_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: Meetings::Sidebar::DetailsFormComponent.new(
+ meeting:
+ )
+ )
+ end
+
+ def update_sidebar_participants_component_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: Meetings::Sidebar::ParticipantsComponent.new(
+ meeting:
+ )
+ )
+ end
+
+ def update_sidebar_participants_form_component_via_turbo_stream(meeting: @meeting)
+ update_via_turbo_stream(
+ component: Meetings::Sidebar::ParticipantsFormComponent.new(
+ meeting:
+ )
+ )
+ end
+
+ def update_new_component_via_turbo_stream(hidden: false, meeting_agenda_item: nil, meeting: @meeting, type: :simple)
+ update_via_turbo_stream(
+ component: MeetingAgendaItems::NewComponent.new(
+ hidden:,
+ meeting:,
+ meeting_agenda_item:,
+ type:
+ )
+ )
+ end
+
+ def update_new_button_via_turbo_stream(disabled: false, meeting_agenda_item: nil, meeting: @meeting)
+ update_via_turbo_stream(
+ component: MeetingAgendaItems::NewButtonComponent.new(
+ disabled:,
+ meeting:,
+ meeting_agenda_item:
+ )
+ )
+ end
+
+ def update_list_via_turbo_stream(meeting: @meeting, form_hidden: true, form_type: :simple)
+ # replace needs to be called in order to mount the drag and drop handlers again
+ # update would not do that and drag and drop would stop working after the first update
+ replace_via_turbo_stream(
+ component: MeetingAgendaItems::ListComponent.new(
+ meeting:,
+ form_hidden:,
+ form_type:
+ )
+ )
+ # as the list is updated without displaying the form, the new button needs to be enabled again
+ # the new button might be in a disabled state
+ update_new_button_via_turbo_stream(disabled: false) if form_hidden == true
+ end
+
+ def update_item_via_turbo_stream(state: :show, meeting_agenda_item: @meeting_agenda_item)
+ if @meeting_agenda_item.duration_in_minutes_previously_changed?
+ # if duration was changed, all following items are affectected with their time-slot
+ # thus update the whole list to reflect the changes on the UI immediately
+ update_list_via_turbo_stream
+ else
+ update_via_turbo_stream(
+ component: MeetingAgendaItems::ItemComponent.new(
+ state:,
+ meeting_agenda_item:
+ )
+ )
+ end
+ end
+
+ def update_all_via_turbo_stream
+ update_header_component_via_turbo_stream
+ update_sidebar_component_via_turbo_stream
+ update_new_button_via_turbo_stream
+ update_list_via_turbo_stream
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
new file mode 100644
index 00000000000..ee3200d1489
--- /dev/null
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -0,0 +1,207 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class MeetingAgendaItemsController < ApplicationController
+ include AttachableServiceCall
+ include OpTurbo::ComponentStream
+ include Meetings::AgendaComponentStreams
+ include ApplicationComponentStreams
+
+ before_action :set_meeting
+ before_action :set_agenda_item_type, only: %i[new create]
+ before_action :set_meeting_agenda_item,
+ except: %i[index new cancel_new create author_autocomplete_index]
+ before_action :authorize
+
+ def new
+ if @meeting.open?
+ update_new_component_via_turbo_stream(hidden: false, type: @agenda_item_type)
+ update_new_button_via_turbo_stream(disabled: true)
+ else
+ update_all_via_turbo_stream
+ render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def cancel_new
+ update_new_component_via_turbo_stream(hidden: true)
+ update_new_button_via_turbo_stream(disabled: false)
+
+ respond_with_turbo_streams
+ end
+
+ def create
+ call = ::MeetingAgendaItems::CreateService
+ .new(user: current_user)
+ .call(meeting_agenda_item_params.merge(meeting_id: @meeting.id))
+
+ @meeting_agenda_item = call.result
+
+ if call.success?
+ # enabel continue editing
+ update_list_via_turbo_stream(form_hidden: false, form_type: @agenda_item_type)
+ update_header_component_via_turbo_stream
+ elsif call.errors[:base].present?
+ render_base_error_in_flash_message_via_turbo_stream(call)
+ else
+ # show errors
+ update_new_component_via_turbo_stream(
+ hidden: false, meeting_agenda_item: @meeting_agenda_item, type: @agenda_item_type
+ )
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def edit
+ if @meeting_agenda_item.editable?
+ update_item_via_turbo_stream(state: :edit)
+ else
+ update_all_via_turbo_stream
+ render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def cancel_edit
+ update_item_via_turbo_stream(state: :show)
+
+ respond_with_turbo_streams
+ end
+
+ def update
+ call = ::MeetingAgendaItems::UpdateService
+ .new(user: current_user, model: @meeting_agenda_item)
+ .call(meeting_agenda_item_params)
+
+ if call.success?
+ update_item_via_turbo_stream
+ update_header_component_via_turbo_stream
+ elsif call.errors[:base].present?
+ render_base_error_in_flash_message_via_turbo_stream(call)
+ else
+ # show errors
+ update_item_via_turbo_stream(state: :edit)
+ render_base_error_in_flash_message_via_turbo_stream(call)
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def destroy
+ call = ::MeetingAgendaItems::DeleteService
+ .new(user: current_user, model: @meeting_agenda_item)
+ .call
+
+ if call.success?
+ update_list_via_turbo_stream
+ update_header_component_via_turbo_stream
+ else
+ generic_call_failure_response(call)
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def drop
+ call = ::MeetingAgendaItems::UpdateService
+ .new(user: current_user, model: @meeting_agenda_item)
+ .call(position: params[:position].to_i)
+
+ if call.success?
+ update_list_via_turbo_stream
+ update_header_component_via_turbo_stream
+ else
+ generic_call_failure_response(call)
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def move
+ call = ::MeetingAgendaItems::UpdateService
+ .new(user: current_user, model: @meeting_agenda_item)
+ .call(move_to: params[:move_to]&.to_sym)
+
+ if call.success?
+ update_list_via_turbo_stream
+ update_header_component_via_turbo_stream
+ else
+ generic_call_failure_response(call)
+ end
+
+ respond_with_turbo_streams
+ end
+
+ # Primer's autocomplete displays the ID of a user when selected instead of the name
+ # this cannot be changed at the moment as the component uses a simple text field which
+ # can't differentiate between a display and submit value
+ # thus, we can't use it
+ # leaving the code here for future reference
+ # def author_autocomplete_index
+ # @users = User.active.like(params[:q]).limit(10)
+
+ # render(Authors::AutocompleteItemComponent.with_collection(@users), layout: false)
+ # end
+
+ private
+
+ def set_meeting
+ @meeting = Meeting.find(params[:meeting_id])
+ @project = @meeting.project # required for authorization via before_action
+ end
+
+ def set_agenda_item_type
+ @agenda_item_type = params[:type]&.to_sym
+ end
+
+ def set_meeting_agenda_item
+ @meeting_agenda_item = MeetingAgendaItem.find(params[:id])
+ end
+
+ def meeting_agenda_item_params
+ params.require(:meeting_agenda_item).permit(:title, :duration_in_minutes, :notes, :work_package_id)
+ end
+
+ def generic_call_failure_response(call)
+ # A failure might imply that the meeting was already closed and the action was triggered from a stale browser window
+ # updating all components resolves the stale state of that window
+ update_all_via_turbo_stream
+ # show additional base error message
+ render_base_error_in_flash_message_via_turbo_stream(call)
+ end
+
+ def render_base_error_in_flash_message_via_turbo_stream(call)
+ if call.errors[:base].present?
+ render_error_flash_message_via_turbo_stream(message: call.errors[:base].to_sentence)
+ end
+ end
+end
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 754dc5ce55e..f863b651eda 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -31,9 +31,9 @@ class MeetingsController < ApplicationController
before_action :find_optional_project, only: %i[index new create]
before_action :build_meeting, only: %i[new create]
before_action :find_meeting, except: %i[index new create]
- before_action :convert_params, only: %i[create update]
- before_action :authorize, except: %i[index new create]
- before_action :authorize_global, only: %i[index new create]
+ before_action :convert_params, only: %i[create update update_participants]
+ before_action :authorize, except: %i[index new create update_title update_details update_participants change_state]
+ before_action :authorize_global, only: %i[index new create update_title update_details update_participants change_state]
helper :watchers
helper :meeting_contents
@@ -43,6 +43,10 @@ class MeetingsController < ApplicationController
include PaginationHelper
include SortHelper
+ include OpTurbo::ComponentStream
+ include ApplicationComponentStreams
+ include Meetings::AgendaComponentStreams
+
menu_item :new_meeting, only: %i[new create]
def index
@@ -56,7 +60,11 @@ class MeetingsController < ApplicationController
end
def show
- params[:tab] ||= 'minutes' if @meeting.agenda.present? && @meeting.agenda.locked?
+ if @meeting.is_a?(StructuredMeeting)
+ render(Meetings::ShowComponent.new(meeting: @meeting))
+ elsif @meeting.agenda.present? && @meeting.agenda.locked?
+ params[:tab] ||= 'minutes'
+ end
end
def create
@@ -103,7 +111,24 @@ class MeetingsController < ApplicationController
redirect_to action: 'index', project_id: @project
end
- def edit; end
+ def edit
+ respond_to do |format|
+ format.turbo_stream do
+ update_header_component_via_turbo_stream(state: :edit)
+
+ render turbo_stream: @turbo_streams
+ end
+ format.html do
+ render :edit
+ end
+ end
+ end
+
+ def cancel_edit
+ update_header_component_via_turbo_stream(state: :show)
+
+ respond_with_turbo_streams
+ end
def update
@meeting.participants_attributes = @converted_params.delete(:participants_attributes)
@@ -116,6 +141,65 @@ class MeetingsController < ApplicationController
end
end
+ def update_participants
+ @meeting.participants_attributes = @converted_params.delete(:participants_attributes)
+ @meeting.save
+
+ if @meeting.errors.any?
+ update_sidebar_participants_form_component_via_turbo_stream
+ else
+ update_sidebar_participants_component_via_turbo_stream
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def update_title
+ @meeting.update(title: structured_meeting_params[:title])
+
+ if @meeting.errors.any?
+ update_header_component_via_turbo_stream(state: :edit)
+ else
+ update_header_component_via_turbo_stream(state: :show)
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def update_details
+ @meeting.update(structured_meeting_params)
+
+ if @meeting.errors.any?
+ update_sidebar_details_form_component_via_turbo_stream
+ else
+ update_header_component_via_turbo_stream
+ update_sidebar_details_component_via_turbo_stream
+
+ # the list needs to be updated if the start time has changed
+ # in order to update the agenda item time slots
+ update_list_via_turbo_stream if @meeting.previous_changes[:start_time].present?
+ end
+
+ respond_with_turbo_streams
+ end
+
+ def change_state
+ case structured_meeting_params[:state]
+ when "open"
+ @meeting.open!
+ when "closed"
+ @meeting.closed!
+ end
+
+ if @meeting.errors.any?
+ update_sidebar_state_component_via_turbo_stream
+ else
+ update_all_via_turbo_stream
+ end
+
+ respond_with_turbo_streams
+ end
+
private
def load_query
@@ -182,7 +266,8 @@ class MeetingsController < ApplicationController
# instance variable.
@converted_params = meeting_params.to_h
- @converted_params[:duration] = @converted_params[:duration].to_hours
+ @converted_params[:type] = meeting_type(@converted_params[:type])
+ @converted_params[:duration] = @converted_params[:duration].to_hours if @converted_params[:duration].present?
# Force defaults on participants
@converted_params[:participants_attributes] ||= {}
@converted_params[:participants_attributes].each { |p| p.reverse_merge! attended: false, invited: false }
@@ -190,9 +275,24 @@ class MeetingsController < ApplicationController
def meeting_params
if params[:meeting].present?
- params.require(:meeting).permit(:title, :location, :start_time,
+ params.require(:meeting).permit(:title, :location, :start_time, :type,
:duration, :start_date, :start_time_hour,
participants_attributes: %i[email name invited attended user user_id meeting id])
end
end
+
+ def structured_meeting_params
+ if params[:structured_meeting].present?
+ params.require(:structured_meeting).permit(:title, :location, :start_time_hour, :duration, :start_date, :state)
+ end
+ end
+
+ def meeting_type(given_type)
+ case given_type
+ when 'structured'
+ 'StructuredMeeting'
+ else
+ 'Meeting'
+ end
+ end
end
diff --git a/modules/meeting/app/forms/meeting/duration.rb b/modules/meeting/app/forms/meeting/duration.rb
new file mode 100644
index 00000000000..dbc56397604
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/duration.rb
@@ -0,0 +1,45 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class Meeting::Duration < ApplicationForm
+ form do |meeting_form|
+ meeting_form.text_field(
+ name: :duration,
+ type: :number,
+ min: 0,
+ max: 24,
+ step: 0.05,
+ placeholder: Meeting.human_attribute_name(:duration),
+ label: Meeting.human_attribute_name(:duration),
+ visually_hide_label: false,
+ required: true,
+ leading_visual: { icon: :stopwatch },
+ caption: I18n.t("text_in_hours")
+ )
+ end
+end
diff --git a/modules/meeting/app/forms/meeting/location.rb b/modules/meeting/app/forms/meeting/location.rb
new file mode 100644
index 00000000000..e9879cd7673
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/location.rb
@@ -0,0 +1,39 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class Meeting::Location < ApplicationForm
+ form do |meeting_form|
+ meeting_form.text_field(
+ name: :location,
+ placeholder: Meeting.human_attribute_name(:location),
+ label: Meeting.human_attribute_name(:location),
+ visually_hide_label: false,
+ leading_visual: { icon: :link }
+ )
+ end
+end
diff --git a/modules/meeting/app/forms/meeting/start_date.rb b/modules/meeting/app/forms/meeting/start_date.rb
new file mode 100644
index 00000000000..ba82d4b8a27
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/start_date.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class Meeting::StartDate < ApplicationForm
+ form do |meeting_form|
+ meeting_form.text_field(
+ name: :start_date,
+ type: "date",
+ value: @initial_value,
+ placeholder: Meeting.human_attribute_name(:start_date),
+ label: Meeting.human_attribute_name(:start_date),
+ leading_visual: { icon: :calendar },
+ required: true,
+ autofocus: true
+ )
+ end
+
+ def initialize(initial_value: DateTime.now.strftime("%Y-%m-%d"))
+ @initial_value = initial_value
+ end
+end
diff --git a/modules/meeting/app/forms/meeting/start_time.rb b/modules/meeting/app/forms/meeting/start_time.rb
new file mode 100644
index 00000000000..e2dde05f164
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/start_time.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class Meeting::StartTime < ApplicationForm
+ form do |meeting_form|
+ meeting_form.text_field(
+ name: :start_time_hour,
+ type: "time",
+ value: @initial_value,
+ placeholder: Meeting.human_attribute_name(:start_time),
+ label: Meeting.human_attribute_name(:start_time),
+ leading_visual: { icon: :clock },
+ required: true,
+ caption: Time.zone.to_s[/\((.*?)\)/m, 1]
+ )
+ end
+
+ def initialize(initial_value: DateTime.now.strftime("%H:%M"))
+ @initial_value = initial_value
+ end
+end
diff --git a/modules/meeting/app/forms/meeting/submit.rb b/modules/meeting/app/forms/meeting/submit.rb
new file mode 100644
index 00000000000..384edde7e31
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/submit.rb
@@ -0,0 +1,33 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class Meeting::Submit < ApplicationForm
+ form do |meeting_form|
+ meeting_form.submit(name: :submit, label: I18n.t("button_save"), scheme: :primary)
+ end
+end
diff --git a/modules/meeting/app/forms/meeting/title.rb b/modules/meeting/app/forms/meeting/title.rb
new file mode 100644
index 00000000000..8e8a53cf8b5
--- /dev/null
+++ b/modules/meeting/app/forms/meeting/title.rb
@@ -0,0 +1,40 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class Meeting::Title < ApplicationForm
+ form do |meeting_form|
+ meeting_form.text_field(
+ name: :title,
+ placeholder: Meeting.human_attribute_name(:title),
+ label: Meeting.human_attribute_name(:title),
+ visually_hide_label: true,
+ required: true,
+ autofocus: true
+ )
+ end
+end
diff --git a/modules/meeting/app/forms/meeting_agenda_item/duration.rb b/modules/meeting/app/forms/meeting_agenda_item/duration.rb
new file mode 100644
index 00000000000..ee7751e4a62
--- /dev/null
+++ b/modules/meeting/app/forms/meeting_agenda_item/duration.rb
@@ -0,0 +1,46 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class MeetingAgendaItem::Duration < ApplicationForm
+ form do |agenda_item_form|
+ agenda_item_form.text_field(
+ name: :duration_in_minutes,
+ placeholder: MeetingAgendaItem.human_attribute_name(:duration_in_minutes),
+ label: MeetingAgendaItem.human_attribute_name(:duration_in_minutes),
+ leading_visual: { icon: :stopwatch },
+ visually_hide_label: true,
+ max: 1440,
+ type: :number,
+ disabled: @disabled
+ )
+ end
+
+ def initialize(disabled: false)
+ @disabled = disabled
+ end
+end
diff --git a/modules/meeting/app/forms/meeting_agenda_item/notes.rb b/modules/meeting/app/forms/meeting_agenda_item/notes.rb
new file mode 100644
index 00000000000..076514f8bb5
--- /dev/null
+++ b/modules/meeting/app/forms/meeting_agenda_item/notes.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class MeetingAgendaItem::Notes < ApplicationForm
+ form do |agenda_item_form|
+ agenda_item_form.rich_text_area(
+ name: :notes,
+ label: MeetingAgendaItem.human_attribute_name(:notes),
+ disabled: @disabled
+ )
+ end
+
+ def initialize(disabled: false)
+ @disabled = disabled
+ end
+end
diff --git a/modules/meeting/app/forms/meeting_agenda_item/submit.rb b/modules/meeting/app/forms/meeting_agenda_item/submit.rb
new file mode 100644
index 00000000000..ead95703510
--- /dev/null
+++ b/modules/meeting/app/forms/meeting_agenda_item/submit.rb
@@ -0,0 +1,40 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class MeetingAgendaItem::Submit < ApplicationForm
+ form do |agenda_item_form|
+ agenda_item_form.group(layout: :horizontal) do |button_group|
+ button_group.hidden(name: :type, value: @type, scope_name_to_model: false)
+ button_group.submit(name: :submit_button, label: I18n.t("button_save"), scheme: :primary)
+ end
+ end
+
+ def initialize(type: :simple)
+ @type = type
+ end
+end
diff --git a/modules/meeting/app/forms/meeting_agenda_item/title.rb b/modules/meeting/app/forms/meeting_agenda_item/title.rb
new file mode 100644
index 00000000000..70df5d4d91f
--- /dev/null
+++ b/modules/meeting/app/forms/meeting_agenda_item/title.rb
@@ -0,0 +1,48 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class MeetingAgendaItem::Title < ApplicationForm
+ form do |agenda_item_form|
+ agenda_item_form.text_field(
+ name: :title,
+ placeholder: MeetingAgendaItem.human_attribute_name(:title),
+ label: MeetingAgendaItem.human_attribute_name(:title),
+ visually_hide_label: true,
+ required: true,
+ autofocus: true,
+ disabled: @disabled,
+ data: {
+ action: 'keydown.esc->meeting-agenda-item-form#cancel'
+ }
+ )
+ end
+
+ def initialize(disabled: false)
+ @disabled = disabled
+ end
+end
diff --git a/modules/meeting/app/forms/meeting_agenda_item/work_package.rb b/modules/meeting/app/forms/meeting_agenda_item/work_package.rb
new file mode 100644
index 00000000000..21c3e863867
--- /dev/null
+++ b/modules/meeting/app/forms/meeting_agenda_item/work_package.rb
@@ -0,0 +1,52 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class MeetingAgendaItem::WorkPackage < ApplicationForm
+ form do |agenda_item_form|
+ agenda_item_form.autocompleter(
+ name: :work_package_id,
+ label: WorkPackage.model_name.human,
+ visually_hide_label: true,
+ autocomplete_options: {
+ id: "op-agenda-items-wp-autocomplete",
+ data: {
+ 'test-selector': 'op-agenda-items-wp-autocomplete'
+ },
+ resource: 'work_packages',
+ searchKey: 'subjectOrId',
+ focusDirectly: true,
+ disabled: @disabled
+ }
+ )
+ end
+
+ def initialize(disabled: false)
+ super()
+ @disabled = disabled
+ end
+end
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 4531825c944..4909ad3e07f 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -37,6 +37,7 @@ class Meeting < ApplicationRecord
has_one :minutes, dependent: :destroy, class_name: 'MeetingMinutes'
has_many :contents, -> { readonly }, class_name: 'MeetingContent'
has_many :participants, dependent: :destroy, class_name: 'MeetingParticipant'
+ has_many :agenda_items, dependent: :destroy, class_name: 'MeetingAgendaItem'
default_scope do
order("#{Meeting.table_name}.start_time DESC")
@@ -95,6 +96,11 @@ class Meeting < ApplicationRecord
after_initialize :set_initial_values
+ enum state: {
+ open: 0, # 0 -> default, leave values for future states between open and closed
+ closed: 5
+ }
+
##
# Return the computed start_time when changed
def start_time
@@ -140,6 +146,10 @@ class Meeting < ApplicationRecord
(user || User.current).allowed_to?(:view_meetings, project)
end
+ def invited_or_attended_participants
+ participants.where(invited: true).or(participants.where(attended: true))
+ end
+
def all_changeable_participants
changeable_participants = participants.select(&:invited).collect(&:user)
changeable_participants = changeable_participants + participants.select(&:attended).collect(&:user)
@@ -216,6 +226,16 @@ class Meeting < ApplicationRecord
self.original_participants_attributes = attrs
end
+ def calculate_agenda_item_time_slots
+ current_time = start_time
+ agenda_items.order(:position).each do |top|
+ start_time = current_time
+ current_time += top.duration_in_minutes&.minutes || 0.minutes
+ end_time = current_time
+ top.update_columns(start_time:, end_time:) # avoid callbacks, infinite loop otherwise
+ end
+ end
+
protected
# Participants of older meetings
diff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rb
new file mode 100644
index 00000000000..9ab7be5bff8
--- /dev/null
+++ b/modules/meeting/app/models/meeting_agenda_item.rb
@@ -0,0 +1,69 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+#
+
+class MeetingAgendaItem < ApplicationRecord
+ belongs_to :meeting, foreign_key: 'meeting_id', class_name: 'StructuredMeeting'
+ belongs_to :work_package, class_name: '::WorkPackage'
+ has_one :project, through: :meeting
+ belongs_to :author, class_name: 'User', optional: false
+
+ acts_as_list scope: :meeting
+ default_scope { order(:position) }
+
+ validates :author_id, presence: true
+ validates :meeting_id, presence: true
+ validates :title, presence: true, if: Proc.new { |item| item.work_package_id.blank? }
+ validates :work_package_id, presence: true, if: Proc.new { |item| item.title.blank? }
+
+ validates :duration_in_minutes,
+ numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1440 },
+ allow_nil: true
+
+ after_create :trigger_meeting_agenda_item_time_slots_calculation
+ after_save :trigger_meeting_agenda_item_time_slots_calculation, if: Proc.new { |item|
+ item.duration_in_minutes_previously_changed? || item.position_previously_changed?
+ }
+ after_destroy :trigger_meeting_agenda_item_time_slots_calculation
+
+ def trigger_meeting_agenda_item_time_slots_calculation
+ meeting.calculate_agenda_item_time_slots
+ end
+
+ def linked_work_package?
+ work_package.present?
+ end
+
+ def visible_work_package?
+ linked_work_package? && work_package.visible?(User.current)
+ end
+
+ def editable?
+ !meeting&.closed?
+ end
+end
diff --git a/modules/meeting/app/models/structured_meeting.rb b/modules/meeting/app/models/structured_meeting.rb
new file mode 100644
index 00000000000..ffa8145702e
--- /dev/null
+++ b/modules/meeting/app/models/structured_meeting.rb
@@ -0,0 +1,31 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+class StructuredMeeting < Meeting
+ has_many :agenda_items, dependent: :destroy, foreign_key: 'meeting_id', class_name: 'MeetingAgendaItem'
+end
diff --git a/modules/meeting/app/services/meeting_agenda_items/create_service.rb b/modules/meeting/app/services/meeting_agenda_items/create_service.rb
new file mode 100644
index 00000000000..93940cc3fb4
--- /dev/null
+++ b/modules/meeting/app/services/meeting_agenda_items/create_service.rb
@@ -0,0 +1,32 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class CreateService < ::BaseServices::Create
+ end
+end
diff --git a/modules/meeting/app/services/meeting_agenda_items/delete_service.rb b/modules/meeting/app/services/meeting_agenda_items/delete_service.rb
new file mode 100644
index 00000000000..079198106fd
--- /dev/null
+++ b/modules/meeting/app/services/meeting_agenda_items/delete_service.rb
@@ -0,0 +1,32 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class DeleteService < ::BaseServices::Delete
+ end
+end
diff --git a/modules/meeting/app/services/meeting_agenda_items/set_attributes_service.rb b/modules/meeting/app/services/meeting_agenda_items/set_attributes_service.rb
new file mode 100644
index 00000000000..1acea4caac8
--- /dev/null
+++ b/modules/meeting/app/services/meeting_agenda_items/set_attributes_service.rb
@@ -0,0 +1,37 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class SetAttributesService < ::BaseServices::SetAttributes
+ def set_default_attributes(_params)
+ model.change_by_system do
+ model.author = user
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/services/meeting_agenda_items/update_service.rb b/modules/meeting/app/services/meeting_agenda_items/update_service.rb
new file mode 100644
index 00000000000..07c10a49171
--- /dev/null
+++ b/modules/meeting/app/services/meeting_agenda_items/update_service.rb
@@ -0,0 +1,32 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 MeetingAgendaItems
+ class UpdateService < ::BaseServices::Update
+ end
+end
diff --git a/modules/meeting/app/views/meetings/_form.html.erb b/modules/meeting/app/views/meetings/_form.html.erb
index f90502bed34..6e36f2c1349 100644
--- a/modules/meeting/app/views/meetings/_form.html.erb
+++ b/modules/meeting/app/views/meetings/_form.html.erb
@@ -35,6 +35,52 @@ See COPYRIGHT and LICENSE files for more details.
<%= f.text_field :title, :required => true, :size => 60, container_class: '-wide' %>
</div>
+ <div class="form--field -required -align-start">
+ <label class="form--label" for="meeting_type"><%= Meeting.human_attribute_name(:type) %></label>
+ <div class="form--field-container">
+ <div class="op-tile-block">
+ <label class="op-tile-block--tile form--radio-button-container -wide"
+ for="meeting_type_classic"
+ data-test-selector="op-tile-block">
+ <div class="op-tile-block--content">
+ <%= styled_radio_button_tag 'meeting[type]',
+ 'classic',
+ true,
+ no_label: true,
+ class: 'radio-button' %>
+ <div>
+ <span data-test-selector="op-tile-block-title" class="op-tile-block--title">
+ <%= t('meeting.types.classic') %>
+ </span>
+ <p class="op-tile-block--description">
+ <%= t('meeting.types.classic_text') %>
+ </p>
+ </div>
+ </div>
+ </label>
+ <label class="op-tile-block--tile form--radio-button-container -wide"
+ for="meeting_type_structured"
+ data-test-selector="op-tile-block">
+ <div class="op-tile-block--content">
+ <%= styled_radio_button_tag 'meeting[type]',
+ 'structured',
+ false,
+ no_label: true,
+ class: 'radio-button' %>
+ <div>
+ <span data-test-selector="op-tile-block-title" class="op-tile-block--title">
+ <%= t('meeting.types.structured') %>
+ </span>
+ <p class="op-tile-block--description">
+ <%= t('meeting.types.structured_text') %>
+ </p>
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+ </div>
+
<% if global_meeting_create_context? %>
<div class="form--field -required">
<label class="form--label" for="project_id"><%= Meeting.human_attribute_name(:project) %>:</label>
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index d0ba3c5434d..fa20c69c0bf 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -39,18 +39,27 @@ en:
activerecord:
attributes:
meeting:
+ type: "Meeting type"
location: "Location"
duration: "Duration"
+ notes: "Notes"
participants: "Participants"
participants_attended: "Attendees"
participants_invited: "Invitees"
project: "Project"
+ start_date: "Date"
start_time: "Time"
start_time_hour: "Starting time"
+ meeting_agenda_items:
+ title: "Title"
+ author: "Responsible"
+ duration_in_minutes: "Duration in minutes"
+ description: "Notes"
errors:
messages:
invalid_time_format: "is not a valid time. Required format: HH:MM"
models:
+ meeting_agenda_item: "Agenda item"
meeting_agenda: "Agenda"
meeting_minutes: "Minutes"
@@ -97,6 +106,11 @@ en:
meeting:
+ types:
+ classic: 'Free-text meeting'
+ classic_text: 'Organize your meeting in a formattable text agenda and protocol.'
+ structured: 'Structured meeting'
+ structured_text: 'Organize your meeting as a list of agenda items, optionally linking them to a work package.'
copied: "Copied from Meeting #%{id}"
notice_successful_notification: "Notification sent successfully"
@@ -125,3 +139,41 @@ en:
text_review_meeting_agenda: "%{author} has put the %{link} up for review."
text_review_meeting_minutes: "%{author} has put the %{link} up for review."
text_notificiation_invited: "This mail contains an ics entry for the meeting below:"
+
+ text_meeting_empty_heading: "Your meeting is empty"
+ text_meeting_empty_description_1: "Start by adding agenda items below. Each item can be as simple as just a title, but you can also add additional details like duration, notes and a person responsible."
+ text_meeting_empty_description_2: "You can also add references to existing work packages. When you do, related notes will automatically be visible in the work package's \"Meetings\" tab."
+ label_meeting_empty_action: "Add agenda item"
+
+ label_meeting_actions: "Meeting actions"
+ label_meeting_edit_title: "Edit meeting title"
+ label_meeting_delete: "Delete meeting"
+ label_meeting_created_by: "Created by"
+ label_meeting_last_updated: "Last updated"
+
+ label_agenda_item_undisclosed_wp: "Undisclosed work package reference #%{id}"
+ label_agenda_item_actions: "Agenda items actions"
+ label_agenda_item_move_to_top: "Move to top"
+ label_agenda_item_move_to_bottom: "Move to bottom"
+ label_agenda_item_move_up: "Move up"
+ label_agenda_item_move_down: "Move down"
+
+ label_meeting_details: "Meeting details"
+ label_meeting_details_edit: "Edit meeting details"
+
+ label_meeting_state_open: "Open"
+ label_meeting_state_closed: "Closed"
+ label_meeting_reopen_action: "Reopen meeting"
+ label_meeting_close_action: "Close meeting"
+ text_meeting_open_description: "This meeting is open. You can add/remove agenda items and edit them as you please. After the meeting is over, close it to lock it."
+ text_meeting_closed_description: "This meeting is closed. You cannot add/remove agenda items anymore."
+
+ label_meeting_manage_participants: "Manage participants"
+ label_meeting_no_participants: "No participants"
+ label_meeting_show_hide_participants: "Show/hide %{count} more"
+ label_meeting_add_participants: "Add participants"
+
+ text_meeting_not_editable_anymore: "This meeting is not editable anymore."
+
+ label_add_work_package_to_meeting_dialog_title: "Add work package to meeting"
+ label_add_work_package_to_meeting_dialog_button: "Add to meeting"
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 0c743ee9e84..11bb685ea99 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -31,7 +31,40 @@ OpenProject::Application.routes.draw do
resources :meetings, only: %i[index new create]
end
+ resources :work_packages, only: %i[] do
+ resources :meetings, only: %i[] do
+ collection do
+ resources :tab, only: %i[index], controller: 'work_package_meetings_tab', as: 'meetings_tab'
+ end
+ end
+ resources :meeting_agenda_items, only: %i[] do
+ collection do
+ post :create, controller: 'work_package_meetings_tab', action: :add_work_package_to_meeting
+ end
+ end
+ end
+
resources :meetings do
+ member do
+ get :cancel_edit
+ put :update_title
+ put :update_details
+ put :update_participants
+ put :change_state
+ end
+ resources :agenda_items, controller: 'meeting_agenda_items' do
+ collection do
+ get :new, action: :new, as: :new
+ get :cancel_new
+ # get :author_autocomplete_index
+ end
+ member do
+ get :cancel_edit
+ put :drop
+ put :move
+ end
+ end
+
resource :agenda, controller: 'meeting_agendas', only: [:update] do
member do
get :history
diff --git a/modules/meeting/db/migrate/20230816141222_create_meeting_agenda_items.rb b/modules/meeting/db/migrate/20230816141222_create_meeting_agenda_items.rb
new file mode 100644
index 00000000000..b63d8d399aa
--- /dev/null
+++ b/modules/meeting/db/migrate/20230816141222_create_meeting_agenda_items.rb
@@ -0,0 +1,16 @@
+class CreateMeetingAgendaItems < ActiveRecord::Migration[5.1]
+ def change
+ create_table :meeting_agenda_items do |t|
+ t.references :meeting, foreign_key: true
+ t.references :author, foreign_key: { to_table: :users }
+ t.string :title
+ t.text :description
+ t.integer :position
+ t.integer :duration_in_minutes
+ t.datetime :start_time
+ t.datetime :end_time
+
+ t.timestamps
+ end
+ end
+end
diff --git a/modules/meeting/db/migrate/20230823113310_add_work_package_to_meeting_agenda_items.rb b/modules/meeting/db/migrate/20230823113310_add_work_package_to_meeting_agenda_items.rb
new file mode 100644
index 00000000000..815b2446589
--- /dev/null
+++ b/modules/meeting/db/migrate/20230823113310_add_work_package_to_meeting_agenda_items.rb
@@ -0,0 +1,5 @@
+class AddWorkPackageToMeetingAgendaItems < ActiveRecord::Migration[5.1]
+ def change
+ add_reference :meeting_agenda_items, :work_package, index: true
+ end
+end
diff --git a/modules/meeting/db/migrate/20230829122717_add_state_to_meetings.rb b/modules/meeting/db/migrate/20230829122717_add_state_to_meetings.rb
new file mode 100644
index 00000000000..f5de2d6b142
--- /dev/null
+++ b/modules/meeting/db/migrate/20230829122717_add_state_to_meetings.rb
@@ -0,0 +1,5 @@
+class AddStateToMeetings < ActiveRecord::Migration[5.1]
+ def change
+ add_column :meetings, :state, :integer, default: 0, null: false
+ end
+end
diff --git a/modules/meeting/db/migrate/20230911102918_add_type_to_meeting.rb b/modules/meeting/db/migrate/20230911102918_add_type_to_meeting.rb
new file mode 100644
index 00000000000..b09b4a1d776
--- /dev/null
+++ b/modules/meeting/db/migrate/20230911102918_add_type_to_meeting.rb
@@ -0,0 +1,5 @@
+class AddTypeToMeeting < ActiveRecord::Migration[7.0]
+ def change
+ add_column :meetings, :type, :string, default: 'Meeting', null: false
+ end
+end
diff --git a/modules/meeting/db/migrate/20230918135247_change_meeting_agenda_item_description_to_notes.rb b/modules/meeting/db/migrate/20230918135247_change_meeting_agenda_item_description_to_notes.rb
new file mode 100644
index 00000000000..c9274ad7f30
--- /dev/null
+++ b/modules/meeting/db/migrate/20230918135247_change_meeting_agenda_item_description_to_notes.rb
@@ -0,0 +1,5 @@
+class ChangeMeetingAgendaItemDescriptionToNotes < ActiveRecord::Migration[7.0]
+ def change
+ rename_column :meeting_agenda_items, :description, :notes
+ end
+end
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index db66476c2fc..1e7d4bab3d3 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -49,7 +49,10 @@ module OpenProject::Meeting
require: :member,
contract_actions: { meetings: %i[create] }
permission :edit_meetings,
- { meetings: %i[edit update] },
+ {
+ meetings: %i[edit cancel_edit update update_title update_details update_participants],
+ meeting_agenda_items: %i[new cancel_new create edit cancel_edit update destroy drop move]
+ },
permissible_on: :project,
require: :member
permission :delete_meetings,
@@ -61,11 +64,16 @@ module OpenProject::Meeting
permissible_on: :project,
require: :member
permission :create_meeting_agendas,
- { meeting_agendas: %i[update preview] },
+ {
+ meeting_agendas: %i[update preview],
+ },
permissible_on: :project,
require: :member
permission :close_meeting_agendas,
- { meeting_agendas: %i[close open] },
+ {
+ meetings: %i[change_state],
+ meeting_agendas: %i[close open]
+ },
permissible_on: :project,
require: :member
permission :send_meeting_agendas_notification,
@@ -104,7 +112,7 @@ module OpenProject::Meeting
should_render_global_menu_item = Proc.new do
(User.current.logged? || !Setting.login_required?) &&
- User.current.allowed_to_globally?(:view_meetings)
+ User.current.allowed_to_globally?(:view_meetings)
end
menu :top_menu,
diff --git a/modules/meeting/spec/contracts/meeting_agenda_items/create_contract_spec.rb b/modules/meeting/spec/contracts/meeting_agenda_items/create_contract_spec.rb
new file mode 100644
index 00000000000..a60a7b03974
--- /dev/null
+++ b/modules/meeting/spec/contracts/meeting_agenda_items/create_contract_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 'spec_helper'
+require 'contracts/shared/model_contract_shared_context'
+require_relative './shared_contract_examples'
+
+RSpec.describe MeetingAgendaItems::CreateContract do
+ include_context 'ModelContract shared context'
+ include_examples 'meeting is not readable'
+end
diff --git a/modules/meeting/spec/contracts/meeting_agenda_items/delete_contract_spec.rb b/modules/meeting/spec/contracts/meeting_agenda_items/delete_contract_spec.rb
new file mode 100644
index 00000000000..6f38f9cb6bb
--- /dev/null
+++ b/modules/meeting/spec/contracts/meeting_agenda_items/delete_contract_spec.rb
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 'spec_helper'
+require 'contracts/shared/model_contract_shared_context'
+require_relative 'shared_contract_examples'
+
+RSpec.describe MeetingAgendaItems::DeleteContract do
+ include_context 'ModelContract shared context'
+
+ let(:project) { create(:project) }
+ let(:meeting) { create(:structured_meeting, project:) }
+ let(:item) { create(:meeting_agenda_item, meeting:) }
+ let(:contract) { described_class.new(item, user) }
+
+ context 'with permission' do
+ let(:user) do
+ create(:user, member_in_project: project, member_with_permissions: [:edit_meetings])
+ end
+
+ it_behaves_like 'contract is valid'
+ include_examples 'meeting is not readable'
+ end
+
+ context 'without permission' do
+ let(:user) { build_stubbed(:user) }
+
+ it_behaves_like 'contract is invalid', base: :error_unauthorized
+ end
+end
diff --git a/modules/meeting/spec/contracts/meeting_agenda_items/shared_contract_examples.rb b/modules/meeting/spec/contracts/meeting_agenda_items/shared_contract_examples.rb
new file mode 100644
index 00000000000..e1289c49e62
--- /dev/null
+++ b/modules/meeting/spec/contracts/meeting_agenda_items/shared_contract_examples.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 'spec_helper'
+require 'contracts/shared/model_contract_shared_context'
+
+RSpec.shared_examples_for 'meeting is not readable' do
+ let(:user) { build_stubbed(:user) }
+ let(:meeting) { build_stubbed(:structured_meeting) }
+ let(:item) { build_stubbed(:meeting_agenda_item, meeting:) }
+ let(:contract) { described_class.new(item, user) }
+
+ context 'when :meeting is not editable' do
+ let(:meeting) { build_stubbed(:structured_meeting, state: :closed) }
+
+ it_behaves_like 'contract is invalid', base: I18n.t(:text_meeting_not_editable_anymore)
+ end
+end
diff --git a/modules/meeting/spec/contracts/meeting_agenda_items/update_contract_spec.rb b/modules/meeting/spec/contracts/meeting_agenda_items/update_contract_spec.rb
new file mode 100644
index 00000000000..6bbf4850eb5
--- /dev/null
+++ b/modules/meeting/spec/contracts/meeting_agenda_items/update_contract_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 'spec_helper'
+require 'contracts/shared/model_contract_shared_context'
+require_relative './shared_contract_examples'
+
+RSpec.describe MeetingAgendaItems::UpdateContract do
+ include_context 'ModelContract shared context'
+ include_examples 'meeting is not readable'
+end
diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb
index 93f9c15e731..aaec71aa276 100644
--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb
+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb
@@ -178,7 +178,7 @@ RSpec.describe MeetingsController do
expect(response).to render_template :new
expect(response.body)
.to have_selector '#errorExplanation li',
- text: "Start date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}"
+ text: "Date #{I18n.t('activerecord.errors.messages.not_an_iso_date')}"
end
end
diff --git a/modules/meeting/spec/factories/meeting_agenda_item_factory.rb b/modules/meeting/spec/factories/meeting_agenda_item_factory.rb
new file mode 100644
index 00000000000..34686b173ad
--- /dev/null
+++ b/modules/meeting/spec/factories/meeting_agenda_item_factory.rb
@@ -0,0 +1,37 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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.
+#++
+
+FactoryBot.define do
+ factory :meeting_agenda_item do |m|
+ meeting
+ work_package { nil }
+ author factory: :user
+ duration_in_minutes { 10 }
+ m.sequence(:title) { |n| "Agenda item #{n}" }
+ end
+end
diff --git a/modules/meeting/spec/factories/meeting_factory.rb b/modules/meeting/spec/factories/meeting_factory.rb
index c15c35b11a7..999a4840e30 100644
--- a/modules/meeting/spec/factories/meeting_factory.rb
+++ b/modules/meeting/spec/factories/meeting_factory.rb
@@ -27,7 +27,7 @@
#++
FactoryBot.define do
- factory :meeting do |m|
+ factory :meeting, class: 'Meeting' do |m|
author factory: :user
project
start_time { Date.tomorrow + 10.hours }
@@ -38,5 +38,9 @@ FactoryBot.define do
after(:create) do |meeting, evaluator|
meeting.project = evaluator.project if evaluator.project
end
+
+ factory :structured_meeting, class: 'StructuredMeeting' do |m|
+ m.sequence(:title) { |n| "Structured meeting #{n}" }
+ 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
new file mode 100644
index 00000000000..5c11d88f80f
--- /dev/null
+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
@@ -0,0 +1,198 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 'spec_helper'
+
+require_relative '../../support/pages/meetings/new'
+require_relative '../../support/pages/structured_meeting/show'
+
+# Cuprite has a bug where it sends keydown events without #key property
+# This breaks stimulus handling of the escape action
+# https://github.com/rubycdp/cuprite/issues/240
+RSpec.describe 'Structured meetings CRUD',
+ :js,
+ with_cuprite: false do
+ include Components::Autocompleter::NgSelectAutocompleteHelpers
+
+ shared_let(:project) { create(:project, enabled_module_names: %w[meetings work_package_tracking]) }
+ shared_let(:user) do
+ create(:user,
+ lastname: 'First',
+ member_in_project: project,
+ member_with_permissions: %i[view_meetings create_meetings edit_meetings delete_meetings view_work_packages]).tap do |u|
+ u.pref[:time_zone] = 'utc'
+
+ u.save!
+ end
+ end
+ shared_let(:other_user) do
+ create(:user,
+ lastname: 'Second',
+ member_in_project: project,
+ member_with_permissions: %i[view_meetings view_work_packages])
+ end
+ shared_let(:no_member_user) do
+ create(:user,
+ lastname: 'Third')
+ end
+ shared_let(:work_package) do
+ create(:work_package, project:, subject: 'Important task')
+ end
+
+ let(:current_user) { user }
+ let(:new_page) { Pages::Meetings::New.new(project) }
+ let(:show_page) { Pages::StructuredMeeting::Show.new(StructuredMeeting.order(id: :asc).last) }
+
+ before do
+ login_as current_user
+ new_page.visit!
+ expect(page).to have_current_path(new_page.path)
+ new_page.set_title 'Some title'
+ new_page.set_type 'Structured'
+
+ new_page.set_start_date '2013-03-28'
+ new_page.set_start_time '13:30'
+ new_page.set_duration '1.5'
+ new_page.invite(other_user)
+
+ new_page.click_create
+ end
+
+ it 'can create a structured meeting and add agenda items' do
+ show_page.expect_toast(message: 'Successful creation')
+
+ # Can add and edit a single item
+ show_page.add_agenda_item do
+ fill_in 'Title', with: 'My agenda item'
+ fill_in 'Duration in minutes', with: '25'
+ end
+
+ show_page.expect_agenda_item title: 'My agenda item'
+ show_page.cancel_add_form
+
+ item = MeetingAgendaItem.find_by(title: 'My agenda item')
+ show_page.edit_agenda_item(item) do
+ fill_in 'Title', with: 'Updated title'
+ click_button 'Save'
+ end
+
+ show_page.expect_no_agenda_item title: 'My agenda item'
+
+ # Can add multiple items
+ show_page.add_agenda_item do
+ fill_in 'Title', with: 'First'
+ end
+
+ show_page.expect_agenda_item title: 'Updated title'
+ show_page.expect_agenda_item title: 'First'
+
+ show_page.in_agenda_form do
+ fill_in 'Title', with: 'Second'
+ click_button 'Save'
+ end
+
+ show_page.expect_agenda_item title: 'Updated title'
+ show_page.expect_agenda_item title: 'First'
+ show_page.expect_agenda_item title: 'Second'
+
+ # Can reorder
+ show_page.assert_agenda_order! 'Updated title', 'First', 'Second'
+
+ second = MeetingAgendaItem.find_by!(title: 'Second')
+ show_page.select_action(second, I18n.t(:label_sort_higher))
+ show_page.assert_agenda_order! 'Updated title', 'Second', 'First'
+
+ first = MeetingAgendaItem.find_by!(title: 'First')
+ show_page.select_action(first, I18n.t(:label_sort_highest))
+ show_page.assert_agenda_order! 'First', 'Updated title', 'Second'
+
+ # Can edit and cancel with escape
+ show_page.edit_agenda_item(first) do
+ find_field('Title').send_keys :escape
+ end
+ show_page.expect_item_edit_form(first, visible: false)
+
+ # Can remove
+ show_page.remove_agenda_item first
+ show_page.assert_agenda_order! 'Updated title', 'Second'
+
+ # Can link work packages
+ show_page.add_agenda_item(type: WorkPackage) do
+ select_autocomplete(find_test_selector('op-agenda-items-wp-autocomplete'),
+ query: 'task',
+ results_selector: 'body')
+ end
+
+ show_page.expect_agenda_link work_package
+ wp_item = MeetingAgendaItem.find_by!(work_package_id: work_package.id)
+ expect(wp_item).to be_present
+
+ # user can see actions
+ expect(page).to have_selector('#meeting-agenda-items-new-button-component')
+ expect(page).to have_test_selector('op-meeting-agenda-actions', count: 3)
+
+ # other_use can view, but not edit
+ login_as other_user
+ show_page.visit!
+
+ expect(page).not_to have_selector('#meeting-agenda-items-new-button-component')
+ expect(page).not_to have_test_selector('op-meeting-agenda-actions')
+ end
+
+ it 'can delete a meeting and get back to the index page' do
+ click_button('op-meetings-header-action-trigger')
+
+ accept_confirm(I18n.t('text_are_you_sure')) do
+ click_button 'Delete meeting'
+ end
+
+ expect(page).to have_current_path project_meetings_path(project)
+ end
+
+ context 'with a work package reference to another' do
+ let!(:meeting) { create(:structured_meeting, project:, author: current_user) }
+ let!(:other_project) { create(:project) }
+ let!(:other_wp) { create(:work_package, project: other_project, author: current_user, subject: 'Private task') }
+ let!(:role) { create(:role, permissions: %w[view_work_packages]) }
+ let!(:membership) { create(:member, principal: user, project: other_project, roles: [role]) }
+ let!(:agenda_item) { create(:meeting_agenda_item, meeting:, author: current_user, work_package: other_wp) }
+ let(:show_page) { Pages::StructuredMeeting::Show.new(meeting) }
+
+ it 'shows correctly for author, but returns an unresolved reference for the second user' do
+ show_page.visit!
+ show_page.expect_agenda_link agenda_item
+ expect(page).to have_text 'Private task'
+
+ login_as other_user
+
+ show_page.visit!
+ show_page.expect_undisclosed_agenda_link agenda_item
+ expect(page).not_to have_text 'Private task'
+ end
+ end
+end
diff --git a/modules/meeting/spec/models/meeting_agenda_item_spec.rb b/modules/meeting/spec/models/meeting_agenda_item_spec.rb
new file mode 100644
index 00000000000..9141564078a
--- /dev/null
+++ b/modules/meeting/spec/models/meeting_agenda_item_spec.rb
@@ -0,0 +1,103 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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_relative "../spec_helper"
+
+RSpec.describe MeetingAgendaItem do
+ let(:meeting) { build_stubbed(:structured_meeting) }
+
+ subject { described_class.new(meeting:, **attributes) }
+
+ describe '#author' do
+ let(:attributes) { { title: 'foo', author: } }
+
+ context 'when author is missing' do
+ let(:author) { nil }
+
+ it 'validates' do
+ expect(subject).not_to be_valid
+ expect(subject.errors[:author]).to include "must exist"
+ end
+ end
+
+ context 'when author is present' do
+ let(:author) { build_stubbed(:user) }
+
+ it 'validates' do
+ expect(subject).to be_valid
+ end
+ end
+ end
+
+ describe '#duration' do
+ let(:attributes) { { title: 'foo', author: build_stubbed(:user), duration_in_minutes: } }
+
+ context 'with a valid duration' do
+ let(:duration_in_minutes) { 60 }
+
+ it 'is valid' do
+ expect(subject).to be_valid
+ end
+ end
+
+ context 'with a negative duration' do
+ let(:duration_in_minutes) { -1 }
+
+ it 'is invalid' do
+ expect(subject).not_to be_valid
+ expect(subject.errors[:duration_in_minutes]).to include "must be greater than or equal to 0."
+ end
+ end
+
+ context 'with a duration that is too large' do
+ let(:duration_in_minutes) { 10000000000 }
+
+ it 'is valid' do
+ expect(subject).not_to be_valid
+ expect(subject.errors[:duration_in_minutes]).to include "must be less than or equal to 1440."
+ end
+ end
+
+ context 'with max duration' do
+ let(:duration_in_minutes) { 1440 }
+
+ it 'is valid' do
+ expect(subject).to be_valid
+ end
+ end
+
+ context 'with overmax duration' do
+ let(:duration_in_minutes) { 1441 }
+
+ it 'is valid' do
+ expect(subject).not_to be_valid
+ expect(subject.errors[:duration_in_minutes]).to include "must be less than or equal to 1440."
+ end
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/new.rb b/modules/meeting/spec/support/pages/meetings/new.rb
index aaf8e4f3c1a..c7f245049e5 100644
--- a/modules/meeting/spec/support/pages/meetings/new.rb
+++ b/modules/meeting/spec/support/pages/meetings/new.rb
@@ -49,6 +49,10 @@ module Pages::Meetings
end
end
+ def set_type(type)
+ choose type, match: :first
+ end
+
def set_title(text)
fill_in 'Title', with: text
end
@@ -70,7 +74,8 @@ module Pages::Meetings
end
def set_start_time(time)
- fill_in 'Time', with: time
+ input = page.find('#meeting-form-start-time')
+ page.execute_script("arguments[0].value = arguments[1]", input.native, time)
end
def set_duration(duration)
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
new file mode 100644
index 00000000000..03cc78bf595
--- /dev/null
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -0,0 +1,117 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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_relative '../meetings/show'
+
+module Pages::StructuredMeeting
+ class Show < ::Pages::Meetings::Show
+ def expect_empty
+ expect(page).to have_no_selector('[id^="meeting-agenda-items-item-component"]')
+ end
+
+ def add_agenda_item(type: MeetingAgendaItem, cancel_followup_item: true, &block)
+ page.within('#content') do
+ click_button I18n.t(:button_add)
+ end
+
+ click_link type.model_name.human
+
+ in_agenda_form(&block)
+
+ click_button 'Save'
+ end
+
+ def cancel_add_form
+ page.find('#meeting-agenda-items-new-component a', text: I18n.t(:button_cancel)).click
+ end
+
+ def in_agenda_form(&block)
+ page.within('#meeting-agenda-items-form-component', &block)
+ end
+
+ def assert_agenda_order!(*titles)
+ retry_block do
+ found = page.all(:test_id, 'op-meeting-agenda-title').map(&:text)
+ raise "Expected order of agenda items #{titles.inspect}, but found #{found.inspect}" if titles != found
+ end
+ end
+
+ def remove_agenda_item(item)
+ accept_confirm(I18n.t('text_are_you_sure')) do
+ select_action item, I18n.t(:button_delete)
+ end
+
+ expect_no_agenda_item(title: item.title)
+ end
+
+ def expect_agenda_item(title:)
+ expect(page).to have_test_selector('op-meeting-agenda-title', text: title)
+ end
+
+ def expect_agenda_link(item)
+ if item.is_a?(WorkPackage)
+ expect(page).to have_selector("[id^='meeting-agenda-items-item-component-']", text: item.subject)
+ else
+ expect(page).to have_selector("#meeting-agenda-items-item-component-#{item.id}", text: item.work_package.subject)
+ end
+ end
+
+ def expect_agenda_author(name)
+ expect(page).to have_test_selector('op-principal', text: name)
+ end
+
+ def expect_undisclosed_agenda_link(item)
+ expect(page).to have_selector("#meeting-agenda-items-item-component-#{item.id}",
+ text: I18n.t(:label_agenda_item_undisclosed_wp, id: item.work_package_id))
+ end
+
+ def expect_no_agenda_item(title:)
+ expect(page).not_to have_test_selector('op-meeting-agenda-title', text: title)
+ end
+
+ def select_action(item, action)
+ page.within("#meeting-agenda-items-item-component-#{item.id}") do
+ page.find_test_selector('op-meeting-agenda-actions').click
+ end
+
+ page.within('.Overlay') do
+ click_on action
+ end
+ end
+
+ def edit_agenda_item(item, &block)
+ select_action item, 'Edit'
+ page.within("#meeting-agenda-items-item-component-#{item.id} #meeting-agenda-items-form-component", &block)
+ end
+
+ def expect_item_edit_form(item, visible: true)
+ expect(page)
+ .to have_conditional_selector(visible, "#meeting-agenda-items-item-component-#{item.id} #meeting-agenda-items-form-component")
+ end
+ end
+end
diff --git a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb
index 20ac2190ff9..14ebfb7460d 100644
--- a/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb
+++ b/spec/support/components/autocompleter/ng_select_autocomplete_helpers.rb
@@ -40,6 +40,18 @@ module Components::Autocompleter
end
end
+ def expect_ng_option(element, option)
+ within(ng_find_dropdown(element)) do
+ expect(page).to have_selector('.ng-option', text: option)
+ end
+ end
+
+ def expect_no_ng_option(element, option)
+ within(ng_find_dropdown(element)) do
+ expect(page).not_to have_selector('.ng-option', text: option)
+ end
+ end
+
##
# Insert the query, typing
def ng_enter_query(element, query, wait_for_fetched_options: true)
@@ -71,7 +83,7 @@ module Components::Autocompleter
##
# Get the ng_select input element
- def ng_select_input(from_element)
+ def ng_select_input(from_element = page)
from_element.find('.ng-input input')
end