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

[#50820] Show meeting history / changes (#14112)

Mir Bhatia5dccda332f29
diff --git a/app/components/activities/item_component.html.erb b/app/components/activities/item_component.html.erb
index d5f5f7727dd..c0d5c6f5dce 100644
--- a/app/components/activities/item_component.html.erb
+++ b/app/components/activities/item_component.html.erb
@@ -29,14 +29,21 @@ See COPYRIGHT and LICENSE files for more details.
<li class="op-activity-list--item">
<div class="op-activity-list--item-title">
- <%= link_to @event.event_title.squish, @event.event_path %>
+ <% if @event.event_path %>
+ <%= link_to @event.event_title.squish, @event.event_path %>
+ <% else %>
+ <%= @event.event_title %>
+ <% end %>
<%= project_suffix %>
</div>
<%=
- render(Activities::ItemSubtitleComponent.new(user: display_user? && @event.event_author,
- datetime: @event.event_datetime,
- is_creation: @event.journal.initial?,
- journable_type: @event.journal.journable_type))
+ render(Activities::ItemSubtitleComponent.new(
+ user: display_user? && @event.event_author,
+ datetime: @event.event_datetime,
+ is_creation: initial?,
+ is_deletion: deletion?,
+ journable_type: @event.journal.journable_type)
+ )
%>
<% if comment.present? -%>
<ul class="op-activity-list--item-details">
diff --git a/app/components/activities/item_component.rb b/app/components/activities/item_component.rb
index a9ec9cc0173..e5824bf301f 100644
--- a/app/components/activities/item_component.rb
+++ b/app/components/activities/item_component.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class Activities::ItemComponent < ViewComponent::Base
+class Activities::ItemComponent < ViewComponent::Base # rubocop:disable OpenProject/AddPreviewForViewComponent
with_collection_parameter :event
strip_trailing_whitespace
@@ -54,13 +54,19 @@ class Activities::ItemComponent < ViewComponent::Base
end
def display_details?
- return false if @event.journal.initial? && @event.journal.journable_type != 'TimeEntry'
+ journal = @event.journal
+ return false if (initial? && journal.journable_type != "TimeEntry") || deletion?
rendered_details.present?
end
def rendered_details
- filter_details.filter_map { |detail| @event.journal.render_detail(detail, activity_page: @activity_page) }
+ if data[:details]
+ render_event_details
+ else
+ # this doesn't do anything for details of type "agenda_items_10_title"
+ filter_journal_details.filter_map { |detail| @event.journal.render_detail(detail, activity_page: @activity_page) }
+ end
end
def comment
@@ -81,6 +87,18 @@ class Activities::ItemComponent < ViewComponent::Base
@event.event_url
end
+ def initial?
+ @event.journal.initial? || data[:initial]
+ end
+
+ def deletion?
+ data[:deleted]
+ end
+
+ def data
+ @event.data || {}
+ end
+
private
def activity?(type)
@@ -95,7 +113,7 @@ class Activities::ItemComponent < ViewComponent::Base
@current_project && (@event.project != @current_project)
end
- def filter_details
+ def filter_journal_details
details = @event.journal.details
details.delete(:user_id) if details[:logged_by_id] == details[:user_id]
@@ -110,4 +128,10 @@ class Activities::ItemComponent < ViewComponent::Base
def delete_detail(details, field)
details.delete(field) if details[field] && details[field].first.nil?
end
+
+ def render_event_details
+ data[:details].filter_map do |detail|
+ @event.journal.render_detail(detail, activity_page: @activity_page)
+ end
+ end
end
diff --git a/app/components/activities/item_subtitle_component.rb b/app/components/activities/item_subtitle_component.rb
index 6585a39d7ca..211d07d797e 100644
--- a/app/components/activities/item_subtitle_component.rb
+++ b/app/components/activities/item_subtitle_component.rb
@@ -29,11 +29,12 @@
#++
class Activities::ItemSubtitleComponent < ViewComponent::Base
- def initialize(user:, datetime:, is_creation:, journable_type:)
+ def initialize(user:, datetime:, is_creation:, is_deletion:, journable_type:)
super()
@user = user
@datetime = datetime
@is_creation = is_creation
+ @is_deletion = is_deletion
@journable_type = journable_type
end
@@ -56,7 +57,11 @@ class Activities::ItemSubtitleComponent < ViewComponent::Base
def i18n_key
i18n_key = 'activity.item.'.dup
- i18n_key << (@is_creation ? 'created_' : 'updated_')
+ i18n_key << (if @is_deletion
+ 'deleted_'
+ else
+ (@is_creation ? 'created_' : 'updated_')
+ end)
i18n_key << 'by_' if @user
i18n_key << 'on'
i18n_key << '_time_entry' if time_entry?
diff --git a/app/components/op_turbo/frame_component.html.erb b/app/components/op_turbo/frame_component.html.erb
index ef2ba54cf46..2d564a06837 100644
--- a/app/components/op_turbo/frame_component.html.erb
+++ b/app/components/op_turbo/frame_component.html.erb
@@ -26,6 +26,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>
-<turbo-frame id="<%=turbo_frame_id%>">
- <%= content %>
-</turbo-frame>
+<% if options[:lazy] == true %>
+ <turbo-frame id="<%=turbo_frame_id%>" src="<%= options[:lazy_source] %>" loading="lazy">
+ <%= content %>
+ </turbo-frame>
+<% else %>
+ <turbo-frame id="<%=turbo_frame_id%>">
+ <%= content %>
+ </turbo-frame>
+<% end %>
diff --git a/app/components/open_project/common/duration_component.rb b/app/components/open_project/common/duration_component.rb
index 70639b9dd3a..45bd009080f 100644
--- a/app/components/open_project/common/duration_component.rb
+++ b/app/components/open_project/common/duration_component.rb
@@ -42,9 +42,11 @@ module OpenProject
end
def call
- render(Primer::Beta::Text.new) do
- localized_parts.join(separator)
- end
+ render(Primer::Beta::Text.new) { text }
+ end
+
+ def text
+ localized_parts.join(separator)
end
private
diff --git a/app/models/activities/event.rb b/app/models/activities/event.rb
index 97b0346457c..c36540cd454 100644
--- a/app/models/activities/event.rb
+++ b/app/models/activities/event.rb
@@ -1,3 +1,31 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Activities
Event = Struct.new(:provider,
:event_id,
@@ -11,6 +39,7 @@ module Activities
:event_type,
:event_path,
:event_url,
+ :data,
# attributes below are eager loaded by Activities::Fetcher
:event_author,
:journal,
diff --git a/app/models/activities/event_mapper.rb b/app/models/activities/event_mapper.rb
new file mode 100644
index 00000000000..d8b4e78d047
--- /dev/null
+++ b/app/models/activities/event_mapper.rb
@@ -0,0 +1,85 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Activities
+ class EventMapper
+ include Redmine::I18n
+
+ attr_reader :journable
+
+ def initialize(journable)
+ @journable = journable
+ end
+
+ def map_to_events
+ journable
+ .journals
+ .includes(*journals_includes)
+ .all
+ .flat_map { |journal| map_to_event(journal) }
+ end
+
+ protected
+
+ def journals_includes
+ %i[data]
+ end
+
+ def map_to_event(journal)
+ params = mapped_params(journal)
+ create_event(params)
+ end
+
+ def create_event(params)
+ Activities::Event.new(**params)
+ end
+
+ def mapped_params(journal)
+ data = event_data(journal)
+
+ {
+ event_description: journal.notes,
+ event_datetime: journal.updated_at,
+ event_author: journal.user,
+ project: journal.project,
+ project_id: journal.project&.id,
+ journal:,
+ data:,
+ event_title: event_title(journal, data)
+ }
+ end
+
+ def event_data(journal)
+ raise NotImplementedError
+ end
+
+ def event_title(journal, data)
+ raise NotImplementedError
+ end
+ end
+end
diff --git a/app/models/activities/fetcher.rb b/app/models/activities/fetcher.rb
index 0da981cbdb2..2422359bb52 100644
--- a/app/models/activities/fetcher.rb
+++ b/app/models/activities/fetcher.rb
@@ -36,9 +36,10 @@ module Activities
end
def initialize(user, options = {})
- options.assert_valid_keys(:project, :with_subprojects, :author, :scope)
+ options.assert_valid_keys(:project, :with_subprojects, :author, :scope, :meeting)
@user = user
@project = options[:project]
+ @meeting = options[:meeting]
@options = options
self.scope = options[:scope] || :all
@@ -129,10 +130,10 @@ module Activities
journal_ids = events.map(&:event_id)
Journal
- .includes(:data, :customizable_journals, :attachable_journals, :bcf_comment)
- .find(journal_ids)
- .then { |journals| ::API::V3::Activities::ActivityEagerLoadingWrapper.wrap(journals) }
- .index_by(&:id)
+ .includes(:data, :customizable_journals, :attachable_journals, :bcf_comment)
+ .find(journal_ids)
+ .then { |journals| ::API::V3::Activities::ActivityEagerLoadingWrapper.wrap(journals) }
+ .index_by(&:id)
end
def sort_by_most_recent_first(events)
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 5760be8a305..6baa73508eb 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -52,6 +52,9 @@ class Journal < ApplicationRecord
register_journal_formatter :time_entry_named_association, OpenProject::JournalFormatter::TimeEntryNamedAssociation
register_journal_formatter :cause, OpenProject::JournalFormatter::Cause
register_journal_formatter :file_link, OpenProject::JournalFormatter::FileLink
+ register_journal_formatter :meeting_start_time, OpenProject::JournalFormatter::MeetingStartTime
+ register_journal_formatter :agenda_item_position, OpenProject::JournalFormatter::AgendaItemPosition
+ register_journal_formatter :agenda_item_duration, OpenProject::JournalFormatter::AgendaItemDuration
# Attributes related to the cause are stored in a JSONB column so we can easily add new relations and related
# attributes without a heavy database migration. Fields will be prefixed with `cause_` but are stored in the JSONB
diff --git a/app/views/common/feed.atom.builder b/app/views/common/feed.atom.builder
index 8faa7a4afe6..d2420224474 100644
--- a/app/views/common/feed.atom.builder
+++ b/app/views/common/feed.atom.builder
@@ -32,22 +32,23 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
first_item_event = !first_item.nil? && first_item.respond_to?(:data) ? first_item.data : first_item
updated_time = first_item_event.nil? ? Time.now : first_item_event.event_datetime
- xml.title truncate_single_line(@title, length: 100)
- xml.link "rel" => "self", "href" => url_for(only_path: false)
- xml.link "rel" => "alternate", "href" => url_for(only_path: false, format: nil, key: nil)
- xml.id url_for(controller: "/homescreen", action: :index, only_path: false)
+ xml.title truncate_single_line(@title, length: 100)
+ xml.link "rel" => "self", "href" => url_for(only_path: false)
+ xml.link "rel" => "alternate", "href" => url_for(only_path: false, format: nil, key: nil)
+ xml.id url_for(controller: "/homescreen", action: :index, only_path: false)
xml.updated(updated_time.xmlschema)
xml.author { xml.name Setting.app_title }
xml.generator(uri: OpenProject::Info.url) { xml.text! OpenProject::Info.app_name }
@items.each do |item|
- item_event = !first_item.nil? && first_item.respond_to?(:data) ? item.data : item
+ item_event = item.try(:data) || item
xml.entry do
- url = if item_event.is_a? Activities::Event
- item_event.event_url
- else
- url_for(item_event.event_url(only_path: false))
- end
+ url =
+ if item_event.is_a? Activities::Event
+ item_event.event_url
+ else
+ url_for(item_event.event_url(only_path: false))
+ end
if @project
xml.title truncate_single_line(item_event.event_title, length: 100)
else
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 40f0301584e..be7d72512ca 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1130,6 +1130,8 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
updated_by_on_time_entry: "logged time updated by %{user} on %{datetime}"
updated_on: "updated on %{datetime}"
updated_on_time_entry: "logged time updated on %{datetime}"
+ deleted_on: "deleted on %{datetime}"
+ deleted_by_on: "deleted by %{user} on %{datetime}"
parent_without_of: "Subproject"
parent_no_longer: "No longer subproject of"
time_entry:
@@ -1141,6 +1143,13 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
other: "<i>%{count} hours</i>"
updated: "changed from %{old_value} to %{value}"
logged_for: "Logged for"
+ meeting_agenda_item:
+ duration:
+ added: "set to %{value} minutes"
+ removed: "removed"
+ updated: "changed from %{old_value} to %{value}"
+ position:
+ updated: "reordered"
filter:
changeset: "Changesets"
message: "Forums"
diff --git a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb
index 8d798fd0448..e8ad2291e97 100644
--- a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb
@@ -42,6 +42,23 @@ module Acts::Journalized
get_association_changes(original, changed, *)
end
+ def association_changes_multiple_attributes(original, changed, association, association_name, key, values)
+ list = {}
+ values.each do |value|
+ list.store(value, get_association_changes(original, changed, association, association_name, key, value))
+ end
+
+ transformed = {}
+ list.each do |key, value|
+ value.each do |agenda_item, data|
+ transformed["#{agenda_item}_#{key}"] ||= {}
+ transformed["#{agenda_item}_#{key}"] = data
+ end
+ end
+
+ transformed
+ end
+
private
def normalize_newlines(data)
diff --git a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
index 565aadab76a..5371fa17773 100644
--- a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
@@ -70,6 +70,18 @@ module JournalChanges
)
end
+ if journable.respond_to?(:agenda_items)
+ @changes.merge!(
+ ::Acts::Journalized::JournableDiffer.association_changes_multiple_attributes(
+ predecessor,
+ self,
+ 'agenda_item_journals',
+ 'agenda_items',
+ :agenda_item_id,
+ [:title, :duration_in_minutes, :notes, :position, :work_package_id]
+ )
+ )
+ end
@changes
end
end
diff --git a/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb b/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb
index 1eb2e6d81ff..f5b3bd7cce2 100644
--- a/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb
@@ -74,13 +74,15 @@ module JournalFormatter
end
def self.default_formatters
- { datetime: JournalFormatter::Datetime,
+ {
+ datetime: JournalFormatter::Datetime,
day_count: JournalFormatter::DayCount,
decimal: JournalFormatter::Decimal,
fraction: JournalFormatter::Fraction,
id: JournalFormatter::Id,
named_association: JournalFormatter::NamedAssociation,
- plaintext: JournalFormatter::Plaintext }
+ plaintext: JournalFormatter::Plaintext
+ }
end
self.formatters = default_formatters
@@ -103,7 +105,9 @@ module JournalFormatter
return if formatter.nil?
- formatter.render(field, values, options).html_safe # rubocop:disable Rails/OutputSafety
+ formatter
+ .render(field, values, options)
+ &.html_safe # rubocop:disable Rails/OutputSafety
end
def formatter_instance(field)
diff --git a/lookbook/previews/open_project/common/duration_component_preview.rb b/lookbook/previews/open_project/common/duration_component_preview.rb
index b558b48fe02..d15d404d30d 100644
--- a/lookbook/previews/open_project/common/duration_component_preview.rb
+++ b/lookbook/previews/open_project/common/duration_component_preview.rb
@@ -17,6 +17,10 @@ module OpenProject
def iso8601
render OpenProject::Common::DurationComponent.new("P3DT12H5M", :seconds, color: :subtle)
end
+
+ def plain_text
+ render_with_template
+ end
end
end
end
diff --git a/lookbook/previews/open_project/common/duration_component_preview/plain_text.html.erb b/lookbook/previews/open_project/common/duration_component_preview/plain_text.html.erb
new file mode 100644
index 00000000000..4a7bd463a7e
--- /dev/null
+++ b/lookbook/previews/open_project/common/duration_component_preview/plain_text.html.erb
@@ -0,0 +1 @@
+<%= OpenProject::Common::DurationComponent.new("P3DT12H5M", :seconds).text %>
diff --git a/modules/meeting/app/components/meetings/header_component.html.erb b/modules/meeting/app/components/meetings/header_component.html.erb
index 19894fc69f5..c99e3c3e8d9 100644
--- a/modules/meeting/app/components/meetings/header_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_component.html.erb
@@ -43,6 +43,14 @@
end
end
+ menu.with_item(label: t(:label_history),
+ tag: :button,
+ content_arguments: { "data-show-dialog-id": "meetings-history-dialog" },
+ value: ""
+ ) do |item|
+ item.with_leading_visual_icon(icon: :clock) # or :check TBD
+ end
+
menu.with_item(label: t("label_meeting_delete"),
scheme: :danger,
href: meeting_path(@meeting),
@@ -56,6 +64,17 @@
end
end
+ show_header.with_row do
+ render(OpTurbo::OpPrimer::AsyncDialogComponent.new(
+ id: "meetings-history-dialog",
+ src: history_meeting_path(@meeting),
+ size: :xlarge,
+ header_variant: :large,
+ title: I18n.t(:label_history),
+ hide_button: true
+ ))
+ end
+
show_header.with_row do
render(Meetings::HeaderInfolineComponent.new(@meeting))
end
diff --git a/modules/meeting/app/components/meetings/history_component.html.erb b/modules/meeting/app/components/meetings/history_component.html.erb
new file mode 100644
index 00000000000..3e224c62729
--- /dev/null
+++ b/modules/meeting/app/components/meetings/history_component.html.erb
@@ -0,0 +1,6 @@
+<%=
+ component_wrapper do
+ render(OpTurbo::FrameComponent.new(@meeting, context: :meeting_history, lazy: true, lazy_source: history_meeting_path(@meeting.id))) do
+ end
+ end
+%>
diff --git a/modules/meeting/app/components/meetings/history_component.rb b/modules/meeting/app/components/meetings/history_component.rb
new file mode 100644
index 00000000000..e7b1d5e563c
--- /dev/null
+++ b/modules/meeting/app/components/meetings/history_component.rb
@@ -0,0 +1,13 @@
+module Meetings
+ class HistoryComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(meeting:)
+ super
+
+ @meeting = meeting
+ end
+ end
+end
diff --git a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb b/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb
index 430e9194511..59c33590647 100644
--- a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb
+++ b/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.html.erb
@@ -5,14 +5,19 @@
title: @title,
size: @size
)) do |dialog|
- if @button_text
- dialog.with_show_button(**merged_text_button_attributes) do |button|
- button.with_leading_visual_icon(icon: @button_icon) if @button_icon
- @button_text
+ dialog.with_header(variant: @header_variant)
+
+ unless @hide_button
+ if @button_text
+ dialog.with_show_button(**merged_text_button_attributes) do |button|
+ button.with_leading_visual_icon(icon: @button_icon) if @button_icon
+ @button_text
+ end
+ else
+ dialog.with_show_button(**merged_icon_button_attributes)
end
- else
- dialog.with_show_button(**merged_icon_button_attributes)
end
+
content_tag("turbo-frame",
id: "#{@id}-frame",
loading: :lazy,
diff --git a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb b/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb
index 93a51f8815b..eab35782557 100644
--- a/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb
+++ b/modules/meeting/app/components/op_turbo/op_primer/async_dialog_component.rb
@@ -32,14 +32,16 @@ module OpTurbo
include ApplicationHelper
include ::OpPrimer::ComponentHelpers
- def initialize(id:, src:, title:, button_icon: nil, button_icon_label: nil, button_text: nil, button_attributes: {},
- size: :auto)
+ def initialize(id:, src:, title:, size: :auto, header_variant: :medium,
+ hide_button: false, button_icon: nil, button_icon_label: nil, button_text: nil, button_attributes: {})
super
@id = id
@src = src
@title = title
+ @header_variant = header_variant
@size = size
+ @hide_button = hide_button
@button_icon = button_icon
@button_icon_label = button_icon_label
@button_text = button_text
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index f928fd9abf3..78b68179643 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -28,9 +28,13 @@
class MeetingsController < ApplicationController
around_action :set_time_zone
- before_action :find_optional_project, only: %i[index new create]
+ before_action :find_optional_project, only: %i[index new create history]
+ before_action :verify_activities_module_activated, only: %i[history]
+ before_action :determine_date_range, only: %i[history]
+ before_action :determine_author, only: %i[history]
before_action :build_meeting, only: %i[new]
before_action :find_meeting, except: %i[index new create]
+ before_action :set_activity, only: %i[history]
before_action :find_copy_from_meeting, only: %i[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]
@@ -88,7 +92,7 @@ class MeetingsController < ApplicationController
link = I18n.t(:notice_timezone_missing, zone: Time.zone)
text += " #{view_context.link_to(link, { controller: '/my', action: :account }, class: 'link_to_profile')}"
end
- flash[:notice] = text.html_safe
+ flash[:notice] = text.html_safe # rubocop:disable Rails/OutputSafety
redirect_to action: 'show', id: call.result
else
@@ -132,6 +136,15 @@ class MeetingsController < ApplicationController
end
end
+ def history
+ @events = get_events
+
+ render :history
+ rescue ActiveRecord::RecordNotFound => e
+ op_handle_warning "Failed to find all resources in activities: #{e.message}"
+ render_404 I18n.t(:error_can_not_find_all_resources)
+ end
+
def cancel_edit
update_header_component_via_turbo_stream(state: :show)
@@ -328,6 +341,56 @@ class MeetingsController < ApplicationController
end
end
+ def meeting_type(given_type)
+ case given_type
+ when 'dynamic'
+ 'StructuredMeeting'
+ else
+ 'Meeting'
+ end
+ end
+
+ def verify_activities_module_activated
+ render_403 if @project && [email protected]_enabled?('activity')
+ end
+
+ def set_activity
+ @activity = Activities::Fetcher.new(User.current,
+ project: @project,
+ with_subprojects: @with_subprojects,
+ author: @author,
+ scope: activity_scope,
+ meeting: @meeting)
+ end
+
+ def get_events
+ Activities::MeetingEventMapper
+ .new(@meeting)
+ .map_to_events
+ end
+
+ def activity_scope
+ ["meetings", "meeting_agenda_items"]
+ end
+
+ def determine_date_range
+ @days = 31 # Setting.activity_days_default.to_i
+
+ if params[:from]
+ begin
+ ; @date_to = params[:from].to_date + 1.day;
+ rescue StandardError;
+ end
+ end
+
+ @date_to ||= User.current.today + 1.day
+ @date_from = @date_to - @days
+ end
+
+ def determine_author
+ @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
+ end
+
def find_copy_from_meeting
return unless params[:copied_from_meeting_id]
diff --git a/modules/meeting/app/forms/meeting_agenda_item/duration.rb b/modules/meeting/app/forms/meeting_agenda_item/duration.rb
index 5c4f91caa0b..c7fc1301958 100644
--- a/modules/meeting/app/forms/meeting_agenda_item/duration.rb
+++ b/modules/meeting/app/forms/meeting_agenda_item/duration.rb
@@ -30,7 +30,7 @@ class MeetingAgendaItem::Duration < ApplicationForm
form do |agenda_item_form|
agenda_item_form.text_field(
name: :duration_in_minutes,
- placeholder: I18n.t("activerecord.attributes.meeting_agenda_items.duration_in_minutes"),
+ placeholder: I18n.t("activerecord.attributes.meeting_agenda_item.duration_in_minutes"),
label: MeetingAgendaItem.human_attribute_name(:duration_in_minutes),
leading_visual: { icon: :stopwatch },
visually_hide_label: true,
diff --git a/modules/meeting/app/models/activities/meeting_activity_provider.rb b/modules/meeting/app/models/activities/meeting_activity_provider.rb
index cd1c9b492dc..21a2e800fed 100644
--- a/modules/meeting/app/models/activities/meeting_activity_provider.rb
+++ b/modules/meeting/app/models/activities/meeting_activity_provider.rb
@@ -139,6 +139,20 @@ class Activities::MeetingActivityProvider < Activities::BaseActivityProvider
url_helpers.meeting_url(id)
end
+ def event_selection_query(user, from, to, options)
+ query = journals_with_data_query
+ query = extend_event_query(query)
+ query = filter_for_event_datetime(query, from, to)
+ query = restrict_user(query, options)
+ query = restrict_meeting(query, options)
+ restrict_projects(query, user, options)
+ end
+
+ def restrict_meeting(query, options)
+ query = query.where(journals_table[:journable_id].eq(options[:meeting].id)) if options[:meeting]
+ query
+ end
+
private
def meetings_table
diff --git a/modules/meeting/app/models/activities/meeting_event_mapper.rb b/modules/meeting/app/models/activities/meeting_event_mapper.rb
new file mode 100644
index 00000000000..d24a90372d4
--- /dev/null
+++ b/modules/meeting/app/models/activities/meeting_event_mapper.rb
@@ -0,0 +1,205 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Activities::MeetingEventMapper < Activities::EventMapper
+ include ActionView::Helpers::TagHelper
+ include OpenProject::StaticRouting::UrlHelpers
+ include ActionView::Helpers::UrlHelper
+
+ protected
+
+ def map_to_event(journal)
+ count = agenda_changes(journal).count
+ total = journal.details.count
+
+ if count > 0 && count < total
+ # If we have a mix of meeting and agenda item journal, split it up
+ split_agenda_event(journal)
+ elsif count == total
+ # All changes are related to agenda items, convert it to an agenda event
+ create_agenda_events(journal)
+ else
+ create_meeting_event(journal)
+ end
+ end
+
+ ##
+ # We want to split journals into multiple events
+ # if they contain meeting AND agenda item changes.
+ def split_agenda_event(journal)
+ agenda_event = create_agenda_events(journal)
+
+ # Create an agenda event
+ unless only_agenda_item_changes?(journal)
+ meeting_event = create_meeting_event(journal)
+ agenda_event << meeting_event if meeting_event
+ end
+
+ agenda_event
+ end
+
+ def create_meeting_event(journal)
+ params = meeting_params(journal)
+ return if params[:data][:details].empty?
+
+ create_event(params)
+ end
+
+ def create_agenda_events(journal)
+ params = mapped_params(journal)
+
+ agenda_changes(journal).map do |agenda_item_id, changes|
+ params[:data] = {
+ id: agenda_item_id,
+ details: changes,
+ initial: initial_change?(changes),
+ deleted: deleted_change?(changes)
+ }
+
+ params[:event_title] = agenda_item_title(journal, agenda_item_id, changes)
+ params[:event_type] = :agenda_item
+
+ create_event(params)
+ end
+ end
+
+ def initial_change?(changes)
+ title_change = changes[:title]
+ work_package_change = changes[:work_package_id]
+
+ (title_change && title_change.first.nil?) || (work_package_change && work_package_change.first.nil?)
+ end
+
+ def deleted_change?(changes)
+ title_change = changes[:title]
+ work_package_change = changes[:work_package_id]
+
+ (title_change && title_change.last.nil?) || (work_package_change && work_package_change.last.nil?)
+ end
+
+ def agenda_item_title(journal, id, details)
+ agenda_journal = journal.agenda_item_journals.detect { |j| j.agenda_item_id == id }
+
+ if agenda_journal&.item_type == "work_package"
+ work_package_title(agenda_journal.work_package_id)
+ elsif details[:work_package_id]
+ work_package_title(details[:work_package_id].first)
+ else
+ title = agenda_journal&.title || details[:title]&.compact&.last
+ title.nil? ? I18n.t(:text_deleted_agenda_item) : I18n.t("text_agenda_item_title", title:)
+ end
+ end
+
+ def work_package_title(work_package_id)
+ if work_package_id.nil?
+ I18n.t(:text_agenda_work_package_deleted)
+ elsif (work_package = WorkPackage.visible.find_by(id: work_package_id))
+ link_to(work_package.to_s, url_helpers.work_package_path(work_package))
+ else
+ I18n.t(:label_agenda_item_undisclosed_wp, id: work_package_id)
+ end
+ end
+
+ def agenda_changes(journal)
+ journal
+ .details
+ .select { |key, _| key.start_with?("agenda_items_") }
+ .reject { |key, _| key.end_with?("_position") }
+ .each_with_object(Hash.new { |h, k| h[k] = {} }) do |(key, values), changes|
+ id, attribute = key.gsub("agenda_items_", "").split("_", 2)
+ changes[id.to_i][attribute.to_sym] = values
+ end
+ end
+
+ def only_agenda_item_changes?(journal)
+ journal.details.all? { |key, _| key.start_with?("agenda_items_") } &&
+ !journal.details.all? { |key, _| key.end_with?("_position") }
+ end
+
+ def event_data(journal)
+ {
+ meeting_title: journal.data.title,
+ meeting_start_time: start_time(journal.data.start_time),
+ meeting_duration: journal.data.duration
+ }
+ end
+
+ def meeting_params(journal)
+ mapped_params(journal)
+ .merge(
+ {
+ event_title: journal.initial? ? I18n.t(:label_initial_meeting_details) : I18n.t(:label_meeting_details),
+ data: {
+ details: filtered_meeting_details(journal.details)
+ }
+ }
+ )
+ end
+
+ def filtered_meeting_details(details)
+ details
+ .reject { |key, _| key.start_with?("agenda_items_") && !key.end_with?("_position") }
+ .reject { |key, value| key.end_with?("_position") && value.first.nil? }
+ .each_with_object({}) do |(key, value), hash|
+ if key =~ /agenda_items_(\d+)_position/
+ hash[:position] ||= {}
+ hash[:position][Regexp.last_match(1).to_i] = value
+ else
+ hash[key.to_sym] = value
+ end
+ end
+ end
+
+ def start_time(journal_time)
+ if journal_time.is_a?(String)
+ DateTime.parse(journal_time)
+ else
+ journal_time
+ end
+ end
+
+ # duplicates necessary behaviour from Activites::Fetcher
+ def event_title(_journal, data)
+ start_time = data[:meeting_start_time]
+ end_time = start_time + data[:meeting_duration].to_f.hours
+
+ fstart_with = format_date start_time
+ fstart_without = format_time start_time, false
+ fend_without = format_time end_time, false
+
+ "#{I18n.t(:label_meeting)}: #{data[:meeting_title]} (#{fstart_with} #{fstart_without}-#{fend_without})"
+ end
+
+ def journals_includes
+ super + %i[agenda_item_journals]
+ end
+
+ def url_helpers
+ @url_helpers ||= OpenProject::StaticRouting::StaticUrlHelpers.new
+ end
+end
diff --git a/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb b/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb
index e24fdc591a6..f3bf487e390 100644
--- a/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb
+++ b/modules/meeting/app/models/journal/meeting_agenda_item_journal.rb
@@ -32,6 +32,7 @@ class Journal::MeetingAgendaItemJournal < Journal::BaseJournal
enum item_type: MeetingAgendaItem::ITEM_TYPES
belongs_to :meeting
+ belongs_to :work_package, optional: true
belongs_to :author, class_name: "User"
belongs_to :agenda_item, class_name: "MeetingAgendaItem"
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 92cc9fe1ad1..c777a551651 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -109,6 +109,21 @@ class Meeting < ApplicationRecord
closed: 5
}
+ # => {"agenda_items_7"=>{"title"=>["New agenda item edited", "New agenda item edited again"], "duration_in_minutes"=>["5", "3"], "notes"=>["Notes added as well", "Notes edited"]}}
+
+# => {"project_id"=>[nil, 14],
+# "user_id"=>[nil, 9],
+# "work_package_id"=>[nil, 48211],
+# "hours"=>[nil, 1.0],
+# "comments"=>[nil, "Alex"],
+# "activity_id"=>[nil, 8],
+# "spent_on"=>[nil, Mon, 31 Jul 2023],
+# "tyear"=>[nil, 2023],
+# "tmonth"=>[nil, 7],
+# "tweek"=>[nil, 31],
+# "costs"=>[nil, 0.0],
+# "logged_by_id"=>[nil, 9]}
+
##
# Return the computed start_time when changed
def start_time
diff --git a/modules/meeting/app/models/meeting/journalized.rb b/modules/meeting/app/models/meeting/journalized.rb
index 7581a02103c..fdc24d8bc83 100644
--- a/modules/meeting/app/models/meeting/journalized.rb
+++ b/modules/meeting/app/models/meeting/journalized.rb
@@ -37,14 +37,20 @@ module Meeting::Journalized
#{format_date o.start_time} \
#{format_time o.start_time, false}-#{format_time o.end_time, false})"
},
- url: Proc.new { |o| { controller: '/meetings', action: 'show', id: o } },
+ url: Proc.new { |o| { controller: "/meetings", action: "show", id: o } },
author: Proc.new(&:user),
- description: ''
+ description: ""
- register_journal_formatted_fields(:plaintext, 'title')
- register_journal_formatted_fields(:fraction, 'duration')
- register_journal_formatted_fields(:datetime, 'start_time')
- register_journal_formatted_fields(:plaintext, 'location')
+ register_journal_formatted_fields(:plaintext, "title")
+ register_journal_formatted_fields(:fraction, "duration")
+ register_journal_formatted_fields(:datetime, "start_date")
+ register_journal_formatted_fields(:meeting_start_time, "start_time")
+ register_journal_formatted_fields(:plaintext, "location")
+
+ register_journal_formatted_fields(:plaintext, "notes")
+ register_journal_formatted_fields(:agenda_item_duration, "duration")
+ register_journal_formatted_fields(:agenda_item_duration, "duration_in_minutes")
+ register_journal_formatted_fields(:agenda_item_position, "position")
def touch_and_save_journals
update_column(:updated_at, Time.current)
diff --git a/modules/meeting/app/views/meetings/history.html.erb b/modules/meeting/app/views/meetings/history.html.erb
new file mode 100644
index 00000000000..00154206ea5
--- /dev/null
+++ b/modules/meeting/app/views/meetings/history.html.erb
@@ -0,0 +1,9 @@
+<%= content_tag("turbo-frame",
+ id: "meetings-history-dialog-frame",
+ class: 'Overlay-form',
+ data: { 'op-turbo-op-primer-async-dialog-target': "frameElement" }) do
+ render(Primer::Alpha::Dialog::Body.new) do
+ render(Activities::DaysComponent.new(events: @events, current_project: @project, activity_page: @activity_page))
+ end
+end
+%>
diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.yml
index 0759612b219..4c927332e7f 100644
--- a/modules/meeting/config/locales/en.yml
+++ b/modules/meeting/config/locales/en.yml
@@ -51,9 +51,9 @@ en:
participants_invited: "Invitees"
project: "Project"
start_date: "Date"
- start_time: "Time"
- start_time_hour: "Starting time"
- meeting_agenda_items:
+ start_time: "Start time"
+ start_time_hour: "Start time"
+ meeting_agenda_item:
title: "Title"
author: "Author"
duration_in_minutes: "Duration (min)"
@@ -178,6 +178,8 @@ en:
label_meeting_delete: "Delete meeting"
label_meeting_created_by: "Created by"
label_meeting_last_updated: "Last updated"
+ label_agenda_items: "Agenda items"
+ label_agenda_items_reordered: "reordered"
label_agenda_item_remove: "Remove from agenda"
label_agenda_item_undisclosed_wp: "Work package #%{id} not visible"
@@ -189,6 +191,12 @@ en:
label_agenda_item_move_down: "Move down"
label_agenda_item_add_notes: "Add notes"
+ text_agenda_item_title: 'Agenda item "%{title}"'
+ text_agenda_work_package_title: 'Agenda item for %{work_package}"'
+ text_agenda_work_package_deleted: 'Agenda item for deleted work package'
+ text_deleted_agenda_item: 'Deleted agenda item'
+
+ label_initial_meeting_details: "Meeting"
label_meeting_details: "Meeting details"
label_meeting_details_edit: "Edit meeting details"
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 5e373fb438d..f9e015eb11e 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -57,6 +57,7 @@ Rails.application.routes.draw do
put :update_participants
put :change_state
post :notify
+ get :history
end
resources :agenda_items, controller: 'meeting_agenda_items' do
collection do
diff --git a/modules/meeting/lib/open_project/journal_formatter/agenda_item_duration.rb b/modules/meeting/lib/open_project/journal_formatter/agenda_item_duration.rb
new file mode 100644
index 00000000000..51c5e10fec8
--- /dev/null
+++ b/modules/meeting/lib/open_project/journal_formatter/agenda_item_duration.rb
@@ -0,0 +1,59 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 OpenProject::JournalFormatter::AgendaItemDuration < JournalFormatter::Base
+ def render(key, values, options = { html: true })
+ label_text = Meeting.human_attribute_name(:duration)
+ label_text = content_tag(:strong, label_text) if options[:html]
+ unit = key.to_s == "duration" ? :hours : :minutes
+
+ mapped = values.map do |v|
+ if v.blank?
+ nil
+ else
+ ::OpenProject::Common::DurationComponent.new(v.to_f, unit, abbreviated: true).text
+ end
+ end
+
+ value = value(mapped.first, mapped.last)
+
+ I18n.t(:text_journal_of, label: label_text, value:)
+ end
+
+ private
+
+ def value(old_value, value)
+ if old_value.nil?
+ I18n.t(:"activity.item.meeting_agenda_item.duration.added", value:)
+ elsif value.nil?
+ I18n.t(:"activity.item.meeting_agenda_item.duration.removed")
+ else
+ I18n.t(:"activity.item.meeting_agenda_item.duration.updated", value:, old_value:)
+ end
+ end
+end
diff --git a/modules/meeting/lib/open_project/journal_formatter/agenda_item_position.rb b/modules/meeting/lib/open_project/journal_formatter/agenda_item_position.rb
new file mode 100644
index 00000000000..20367571a55
--- /dev/null
+++ b/modules/meeting/lib/open_project/journal_formatter/agenda_item_position.rb
@@ -0,0 +1,36 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 OpenProject::JournalFormatter::AgendaItemPosition < JournalFormatter::Base
+ def render(_key, values, options = { html: true })
+ label_text = I18n.t(:label_agenda_items)
+ label_text = content_tag(:strong, label_text) if options[:html]
+
+ I18n.t(:text_journal_of, label: label_text, value: I18n.t(:label_agenda_items_reordered))
+ end
+end
diff --git a/modules/meeting/lib/open_project/journal_formatter/meeting_start_time.rb b/modules/meeting/lib/open_project/journal_formatter/meeting_start_time.rb
new file mode 100644
index 00000000000..a537702c428
--- /dev/null
+++ b/modules/meeting/lib/open_project/journal_formatter/meeting_start_time.rb
@@ -0,0 +1,39 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 OpenProject::JournalFormatter::MeetingStartTime < JournalFormatter::Attribute
+ def format_values(values)
+ values.map do |v|
+ if v.nil?
+ nil
+ else
+ format_time(v)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index 855c1e68d21..b7faee8275b 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -40,7 +40,7 @@ module OpenProject::Meeting
bundled: true do
project_module :meetings do
permission :view_meetings,
- { meetings: %i[index show download_ics participants_dialog],
+ { meetings: %i[index show download_ics participants_dialog history],
meeting_agendas: %i[history show diff],
meeting_minutes: %i[history show diff],
work_package_meetings_tab: %i[index count] },
diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb
index 7976f548f2f..59ba28840d3 100644
--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb
+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb
@@ -192,7 +192,7 @@ RSpec.describe MeetingsController do
expect(response).to render_template :new
expect(response.body)
.to have_css "#errorExplanation li",
- text: "Starting time #{I18n.t('activerecord.errors.messages.invalid_time_format')}"
+ text: "Start time #{I18n.t('activerecord.errors.messages.invalid_time_format')}"
end
end
end
diff --git a/modules/meeting/spec/features/meetings_copy_spec.rb b/modules/meeting/spec/features/meetings_copy_spec.rb
index 6c6b838ee36..bf6a5f30ffb 100644
--- a/modules/meeting/spec/features/meetings_copy_spec.rb
+++ b/modules/meeting/spec/features/meetings_copy_spec.rb
@@ -66,7 +66,7 @@ RSpec.describe "Meetings copy", :js, :with_cuprite do
start_of_meeting = start_time.strftime(twelve_hour_format)
end_of_meeting = (start_time + meeting.duration.hours).strftime(twelve_hour_format)
- "Time: #{date} #{start_of_meeting} - #{end_of_meeting} (GMT+00:00) UTC"
+ "Start time: #{date} #{start_of_meeting} - #{end_of_meeting} (GMT+00:00) UTC"
end
before do
diff --git a/modules/meeting/spec/features/meetings_index_spec.rb b/modules/meeting/spec/features/meetings_index_spec.rb
index 941ac61d057..9bda13f026e 100644
--- a/modules/meeting/spec/features/meetings_index_spec.rb
+++ b/modules/meeting/spec/features/meetings_index_spec.rb
@@ -274,11 +274,11 @@ RSpec.describe "Meetings", "Index", :with_cuprite do
other_project_meeting)
end
- aggregate_failures "Sorting by Time" do
- meetings_page.click_to_sort_by("Time")
+ aggregate_failures "Sorting by Start time" do
+ meetings_page.click_to_sort_by("Start time")
meetings_page.expect_meetings_listed_in_order(meeting,
other_project_meeting)
- meetings_page.click_to_sort_by("Time")
+ meetings_page.click_to_sort_by("Start time")
meetings_page.expect_meetings_listed_in_order(other_project_meeting,
meeting)
end
@@ -400,20 +400,20 @@ RSpec.describe "Meetings", "Index", :with_cuprite do
meeting)
end
- aggregate_failures "Sorting by Time" do
- meetings_page.click_to_sort_by("Time")
+ aggregate_failures "Sorting by Start time" do
+ meetings_page.click_to_sort_by("Start time")
meetings_page.expect_meetings_listed_in_order(meeting,
tomorrows_meeting)
- meetings_page.click_to_sort_by("Time")
+ meetings_page.click_to_sort_by("Start time")
meetings_page.expect_meetings_listed_in_order(tomorrows_meeting,
meeting)
end
- aggregate_failures "Sorting by Time" do
- meetings_page.click_to_sort_by("Time")
+ aggregate_failures "Sorting by Start time" do
+ meetings_page.click_to_sort_by("Start time")
meetings_page.expect_meetings_listed_in_order(meeting,
tomorrows_meeting)
- meetings_page.click_to_sort_by("Time")
+ meetings_page.click_to_sort_by("Start time")
meetings_page.expect_meetings_listed_in_order(tomorrows_meeting,
meeting)
end
diff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rb
new file mode 100644
index 00000000000..49fe73624ff
--- /dev/null
+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb
@@ -0,0 +1,290 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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"
+require_relative "../../support/pages/structured_meeting/history"
+
+RSpec.describe "history",
+ :js,
+ :with_cuprite do
+ include Components::Autocompleter::NgSelectAutocompleteHelpers
+ include Redmine::I18n
+
+ shared_let(:project) { create(:project, enabled_module_names: %w[meetings work_package_tracking]) }
+ shared_let(:other_project) { create(:project, enabled_module_names: %w[work_package_tracking]) }
+ shared_let(:user) do
+ create(:user,
+ lastname: "First",
+ preferences: { time_zone: "Europe/London" },
+ member_with_permissions: {
+ project => %i[view_meetings create_meetings
+ edit_meetings delete_meetings manage_agendas view_work_packages],
+ other_project => %i[view_work_packages]
+ })
+ end
+ shared_let(:work_package) do
+ create(:work_package, project:, subject: "Important task")
+ end
+
+ shared_let(:other_wp) do
+ create(:work_package, project: other_project, subject: "Private WP")
+ end
+
+ shared_let(:view_only_user) do
+ create(:user,
+ lastname: "Second",
+ preferences: { time_zone: "Europe/London" },
+ member_with_permissions: { project => %i[view_meetings view_work_packages] })
+ end
+ shared_let(:no_member_user) do
+ create(:user,
+ lastname: "Third")
+ end
+ shared_let(:meeting) do
+ User.execute_as(user) do
+ create(:structured_meeting,
+ project:,
+ start_time: DateTime.parse("2024-03-28T13:30:00Z"),
+ title: "Some title",
+ duration: 1.5).tap do |m|
+ create(:meeting_participant, :invitee, meeting: m, user: view_only_user)
+ end
+ end
+ end
+
+ let(:show_page) { Pages::StructuredMeeting::Show.new(meeting) }
+ let(:history_page) { Pages::StructuredMeeting::History.new(meeting) }
+
+ it "allows browsing the history", with_settings: { journal_aggregation_time_minutes: 0 } do
+ login_as(view_only_user)
+
+ # Create meeting
+ show_page.visit!
+
+ history_page.open_history_modal
+
+ history_page.expect_event("Meeting",
+ actor: user.name,
+ timestamp: format_time(meeting.created_at.utc),
+ action: "created by")
+
+ # Update meeting
+ login_as(user)
+ meeting.update!(start_time: DateTime.parse("2024-03-29T14:00:00Z"),
+ duration: 1,
+ title: "Updated",
+ location: "Wakanda")
+ login_as(view_only_user)
+
+ show_page.visit!
+
+ history_page.open_history_modal
+ history_page.expect_event("Meeting details",
+ actor: user.name,
+ timestamp: format_time(meeting.updated_at.utc),
+ action: "updated by")
+
+ item = history_page.find_item("Title changed from Some title to Updated")
+ within(item) do
+ expect(page).to have_css(".op-activity-list--item-title", text: "Meeting details")
+ expect(page).to have_css("li", text: "Location changed from https://some-url.com to Wakanda")
+ expect(page).to have_css("li", text: "Start time changed from 03/28/2024 01:30 PM to 03/29/2024 02:00 PM")
+ expect(page).to have_css("li", text: "Duration changed from 1 hr, 30 mins to 1 hr")
+ end
+
+ login_as(user)
+ show_page.visit!
+
+ show_page.add_agenda_item do
+ fill_in "Title", with: "My agenda item"
+ fill_in "Duration (min)", with: "25"
+ end
+
+ show_page.expect_agenda_item(title: "My agenda item")
+ login_as(view_only_user)
+ show_page.visit!
+
+ item = MeetingAgendaItem.find_by(title: "My agenda item")
+ history_page.open_history_modal
+ history_page.expect_event('Agenda item "My agenda item"',
+ timestamp: format_time(item.created_at.utc),
+ actor: user.name,
+ action: "created by")
+
+ within("li.op-activity-list--item", match: :first) do
+ expect(page).to have_css(".op-activity-list--item-title", text: 'Agenda item "My agenda item"')
+ end
+
+ login_as(user)
+ show_page.visit!
+
+ # Update agenda item
+ item = MeetingAgendaItem.find_by(title: "My agenda item")
+ show_page.edit_agenda_item(item) do
+ fill_in "Title", with: "Updated title"
+ fill_in "Duration", with: "5"
+ click_on "Save"
+ end
+
+ history_page.open_history_modal
+ history_page.expect_event(
+ 'Agenda item "Updated title"',
+ actor: user.name,
+ timestamp: format_time(item.updated_at.utc),
+ action: "updated by"
+ )
+
+ within("li.op-activity-list--item", match: :first) do
+ expect(page).to have_css("li", text: "Title changed from My agenda item to Updated title")
+ expect(page).to have_css("li", text: "Duration changed from 25 mins to 5 mins")
+ end
+
+ # Change position, expect only one change
+ login_as(user)
+ show_page.visit!
+
+ show_page.add_agenda_item do
+ fill_in "Title", with: "Second"
+ end
+ second = MeetingAgendaItem.find_by(title: "Second")
+ show_page.select_action(second, I18n.t(:label_sort_higher))
+
+ login_as(view_only_user)
+ show_page.visit!
+
+ history_page.open_history_modal
+
+ item = history_page.find_item("Agenda items reordered") # using this as no error here indicates exactly 1
+ within(item) do
+ expect(page).to have_css(".op-activity-list--item-title", text: "Meeting details")
+ expect(page).to have_text("updated by")
+ expect(page).to have_text(user.name)
+ end
+
+ # Remove agenda item
+ login_as(user)
+ show_page.visit!
+ show_page.remove_agenda_item(second)
+
+ history_page.open_history_modal
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: 'Agenda item "Second"')
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+
+ # Add + Remove linked work package
+ show_page.visit!
+
+ 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
+
+ history_page.open_history_modal
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: work_package.to_s.strip)
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "created by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+
+ show_page.visit!
+ show_page.remove_agenda_item wp_item
+ history_page.open_history_modal
+
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: work_package.to_s.strip)
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+
+
+ # With a work package linked in another project
+ show_page.visit!
+ show_page.add_agenda_item(type: WorkPackage) do
+ select_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),
+ query: "Private",
+ results_selector: "body")
+ end
+
+ show_page.expect_agenda_link other_wp
+ wp_item = MeetingAgendaItem.find_by!(work_package_id: other_wp.id)
+ expect(wp_item).to be_present
+
+ # Is visible for user
+ history_page.open_history_modal
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: other_wp.to_s.strip)
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "created by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+
+ # Is not visible for view_only_user
+ login_as(view_only_user)
+ show_page.visit!
+
+ history_page.open_history_modal
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "created by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+
+ login_as(user)
+ show_page.visit!
+ show_page.remove_agenda_item wp_item
+ history_page.open_history_modal
+
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: other_wp.to_s.strip)
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+
+ # Is not visible for view_only_user
+ login_as(view_only_user)
+ show_page.visit!
+
+ history_page.open_history_modal
+ item = history_page.first_item
+ expect(item).to have_css(".op-activity-list--item-title", text: I18n.t(:label_agenda_item_undisclosed_wp, id: other_wp.id))
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "deleted by")
+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)
+ end
+
+ it "for a user with no permissions, renders an error", with_settings: { journal_aggregation_time_minutes: 0 } do
+ login_as no_member_user
+
+ visit history_meeting_path(meeting)
+
+ expected = "[Error 403] You are not authorized to access this page."
+ expect(page).to have_css(".op-toast.-error", text: expected)
+ end
+end
diff --git a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
index 035933bab4e..763337f9302 100644
--- a/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
+++ b/modules/meeting/spec/features/structured_meetings/structured_meeting_crud_spec.rb
@@ -168,7 +168,7 @@ RSpec.describe "Structured meetings CRUD",
show_page.add_agenda_item do
fill_in "Title", with: "My agenda item"
- fill_in "Duration in minutes", with: "25"
+ fill_in "Duration (min)", with: "25"
end
show_page.expect_agenda_item title: "My agenda item"
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
index 9373c42f271..18ddc376426 100644
--- a/modules/meeting/spec/support/pages/meetings/show.rb
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -66,7 +66,7 @@ module Pages::Meetings
def expect_date_time(expected)
expect(page)
- .to have_content("Time: #{expected}")
+ .to have_content("Start time: #{expected}")
end
def expect_link_to_location(location)
diff --git a/modules/meeting/spec/support/pages/structured_meeting/history.rb b/modules/meeting/spec/support/pages/structured_meeting/history.rb
new file mode 100644
index 00000000000..a4df4a6f691
--- /dev/null
+++ b/modules/meeting/spec/support/pages/structured_meeting/history.rb
@@ -0,0 +1,74 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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 Pages::StructuredMeeting
+ class History < ::Pages::Page
+ def initialize(meeting)
+ super()
+ @meeting = meeting
+ end
+
+ def open_history_modal
+ retry_block do
+ click_link_or_button "op-meetings-header-action-trigger"
+ click_link_or_button "History"
+ end
+ end
+
+ def close_history_modal
+ if page.has_selector?(".Overlay-closeButton", wait: 0)
+ page.find(".Overlay-closeButton").click
+ end
+ end
+
+ def expect_event(title, action:, actor:, timestamp: nil, &)
+ title = page.find(".op-activity-list--item-title", text: title, exact_text: true)
+ subtitle = title.sibling(".op-activity-list--item-subtitle")
+
+ expect(subtitle).to have_text(actor)
+ expect(subtitle).to have_text(action)
+ expect(subtitle).to have_text(timestamp) if timestamp
+
+ if block_given?
+ details = title.find(".op-activity-list--item-details")
+ page.within(details, &)
+ end
+ end
+
+ def first_item
+ page.first(".op-activity-list--item")
+ end
+
+ def find_item(detail)
+ detail = page.find("li.op-activity-list--item-detail", text: detail)
+ item = detail.ancestor(".op-activity-list--item-details").ancestor(".op-activity-list--item")
+
+ item
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/structured_meeting/show.rb b/modules/meeting/spec/support/pages/structured_meeting/show.rb
index 82bdd8f739d..714cac138a6 100644
--- a/modules/meeting/spec/support/pages/structured_meeting/show.rb
+++ b/modules/meeting/spec/support/pages/structured_meeting/show.rb
@@ -75,10 +75,12 @@ module Pages::StructuredMeeting
def remove_agenda_item(item)
accept_confirm(I18n.t("text_are_you_sure")) do
- select_action item, I18n.t(:button_delete)
+ action = item.work_package ? I18n.t(:label_agenda_item_remove) : I18n.t(:button_delete)
+ select_action(item, action)
end
- expect_no_agenda_item(title: item.title)
+ title = item.work_package ? item.work_package.subject : item.title
+ expect_no_agenda_item(title:)
end
def expect_agenda_item(title:)
diff --git a/spec/components/activities/item_subtitle_component_spec.rb b/spec/components/activities/item_subtitle_component_spec.rb
index d761b649a79..70fe7342015 100644
--- a/spec/components/activities/item_subtitle_component_spec.rb
+++ b/spec/components/activities/item_subtitle_component_spec.rb
@@ -35,12 +35,13 @@ RSpec.describe Activities::ItemSubtitleComponent, type: :component do
let(:datetime) { Time.current }
- subject { render_inline(described_class.new(user:, datetime:, is_creation:, journable_type:)) }
+ subject { render_inline(described_class.new(user:, datetime:, is_creation:, is_deletion:, journable_type:)) }
context 'on creation with a user' do
let(:is_creation) { true }
let(:user) { build_stubbed(:user) }
let(:journable_type) { 'WorkPackage' }
+ let(:is_deletion) { false }
it { is_expected.to have_text("created by #{user.name} on #{format_time(datetime)}") }
end
@@ -49,6 +50,7 @@ RSpec.describe Activities::ItemSubtitleComponent, type: :component do
let(:is_creation) { true }
let(:user) { nil }
let(:journable_type) { 'WorkPackage' }
+ let(:is_deletion) { false }
it { is_expected.to have_text("created on #{format_time(datetime)}") }
end
@@ -57,6 +59,7 @@ RSpec.describe Activities::ItemSubtitleComponent, type: :component do
let(:is_creation) { false }
let(:user) { build_stubbed(:user) }
let(:journable_type) { 'WorkPackage' }
+ let(:is_deletion) { false }
it { is_expected.to have_text("updated by #{user.name} on #{format_time(datetime)}") }
end
@@ -65,14 +68,34 @@ RSpec.describe Activities::ItemSubtitleComponent, type: :component do
let(:is_creation) { false }
let(:user) { nil }
let(:journable_type) { 'WorkPackage' }
+ let(:is_deletion) { false }
it { is_expected.to have_text("updated on #{format_time(datetime)}") }
end
+ context 'on delete with a user' do
+ let(:is_creation) { false }
+ let(:user) { build_stubbed(:user) }
+ let(:journable_type) { 'Meeting' }
+ let(:is_deletion) { true }
+
+ it { is_expected.to have_text("deleted by #{user.name} on #{format_time(datetime)}") }
+ end
+
+ context 'on delete without a user' do
+ let(:is_creation) { false }
+ let(:user) { nil }
+ let(:journable_type) { 'Meeting' }
+ let(:is_deletion) { true }
+
+ it { is_expected.to have_text("deleted on #{format_time(datetime)}") }
+ end
+
context 'on TimeEntry creation' do
let(:is_creation) { true }
let(:user) { build_stubbed(:user) }
let(:journable_type) { 'TimeEntry' }
+ let(:is_deletion) { false }
it { is_expected.to have_text("time logged by #{user.name} on #{format_time(datetime)}") }
end
@@ -81,6 +104,7 @@ RSpec.describe Activities::ItemSubtitleComponent, type: :component do
let(:is_creation) { false }
let(:user) { build_stubbed(:user) }
let(:journable_type) { 'TimeEntry' }
+ let(:is_deletion) { false }
it { is_expected.to have_text("logged time updated by #{user.name} on #{format_time(datetime)}") }
end