OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#53976] Editing a wp does not show clearly in meetings history (#15182)
Mir Bhatia2dbeb06dd6b3
diff --git a/app/models/journal.rb b/app/models/journal.rbindex 6baa73508eb..95448a87090 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -55,6 +55,7 @@ class Journal < ApplicationRecordregister_journal_formatter :meeting_start_time, OpenProject::JournalFormatter::MeetingStartTimeregister_journal_formatter :agenda_item_position, OpenProject::JournalFormatter::AgendaItemPositionregister_journal_formatter :agenda_item_duration, OpenProject::JournalFormatter::AgendaItemDuration+ register_journal_formatter :meeting_work_package_id, OpenProject::JournalFormatter::MeetingWorkPackageId# 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 JSONBdiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 8b86d08be45..06a22a130d1 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1186,11 +1186,16 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}logged_for: "Logged for"meeting_agenda_item:duration:- added: "set to %{value} minutes"+ added: "set to %{value}"+ added_html: "set to <i>%{value}</i>"removed: "removed"updated: "changed from %{old_value} to %{value}"+ updated_html: "changed from <i>%{old_value}</i> to <i>%{value}</i>"position:updated: "reordered"+ work_package:+ updated: "changed from %{old_value} to %{value}"+ updated_html: "changed from <i>%{old_value}</i> to <i>%{value}</i>"filter:changeset: "Changesets"message: "Forums"diff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erbindex 0509445bdac..94b104b82f4 100644--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb@@ -12,6 +12,7 @@flex_layout(align_items: :center) do |flex|flex.with_column(mr: 2, flex: 1, classes: 'ellipsis') dorender(Primer::Beta::Link.new(href: work_package_path(@meeting_agenda_item.work_package), underline: false,+ test_selector: 'op-meeting-agenda-title',font_size: :normal, font_weight: :bold, target: "_blank")) do@meeting_agenda_item.work_package.subjectend@@ -30,11 +31,11 @@endendelsif @meeting_agenda_item.linked_work_package?- render(Primer::Beta::Text.new(font_size: :small, mr: 2, color: :subtle)) do+ render(Primer::Beta::Text.new(font_size: :small, mr: 2, color: :subtle, test_selector: 'op-meeting-agenda-title')) doI18n.t(:label_agenda_item_undisclosed_wp, id: @meeting_agenda_item.work_package_id)endelsif @meeting_agenda_item.deleted_work_package?- render(Primer::Beta::Text.new(tag: :s, font_size: :small, mr: 2, color: :danger)) do+ render(Primer::Beta::Text.new(tag: :s, font_size: :small, mr: 2, color: :danger, test_selector: 'op-meeting-agenda-title')) doI18n.t(:label_agenda_item_deleted_wp)endelsediff --git a/modules/meeting/app/models/meeting/journalized.rb b/modules/meeting/app/models/meeting/journalized.rbindex fdc24d8bc83..171e4c39875 100644--- a/modules/meeting/app/models/meeting/journalized.rb+++ b/modules/meeting/app/models/meeting/journalized.rb@@ -51,6 +51,7 @@ module Meeting::Journalizedregister_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")+ register_journal_formatted_fields(:meeting_work_package_id, "work_package_id")def touch_and_save_journalsupdate_column(:updated_at, Time.current)diff --git a/modules/meeting/config/locales/en.yml b/modules/meeting/config/locales/en.ymlindex 4c927332e7f..da641b277dd 100644--- a/modules/meeting/config/locales/en.yml+++ b/modules/meeting/config/locales/en.yml@@ -191,6 +191,8 @@ en:label_agenda_item_move_down: "Move down"label_agenda_item_add_notes: "Add notes"+ label_agenda_item_work_package: "Agenda item work package"+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'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.rbindex 51c5e10fec8..60e55237f7a 100644--- a/modules/meeting/lib/open_project/journal_formatter/agenda_item_duration.rb+++ b/modules/meeting/lib/open_project/journal_formatter/agenda_item_duration.rb@@ -40,20 +40,22 @@ class OpenProject::JournalFormatter::AgendaItemDuration < JournalFormatter::Baseendend- value = value(mapped.first, mapped.last)+ value = value(options[:html], mapped.first, mapped.last)I18n.t(:text_journal_of, label: label_text, value:)endprivate- def value(old_value, value)+ def value(html, old_value, value)+ html = html ? "_html" : ""+if old_value.nil?- I18n.t(:"activity.item.meeting_agenda_item.duration.added", value:)+ I18n.t(:"activity.item.meeting_agenda_item.duration.added#{html}", 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:)+ I18n.t(:"activity.item.meeting_agenda_item.duration.updated#{html}", value:, old_value:)endendenddiff --git a/modules/meeting/lib/open_project/journal_formatter/meeting_work_package_id.rb b/modules/meeting/lib/open_project/journal_formatter/meeting_work_package_id.rbnew file mode 100644index 00000000000..53d28da6d9d--- /dev/null+++ b/modules/meeting/lib/open_project/journal_formatter/meeting_work_package_id.rb@@ -0,0 +1,53 @@+#-- 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::MeetingWorkPackageId < JournalFormatter::Base+ def render(_key, values, options = { html: true })+ label_text = I18n.t(:label_agenda_item_work_package)+ label_text = content_tag(:strong, label_text) if options[:html]++ I18n.t(:text_journal_of, label: label_text, value: value(options[:html], values))+ end++ private++ def value(html, values)+ html = html ? "_html" : ""++ new = visible(values.last)+ old = visible(values.first)++ I18n.t(:"activity.item.meeting_agenda_item.work_package.updated#{html}",+ value: new ? new.name : I18n.t(:label_agenda_item_undisclosed_wp, id: values.last),+ old_value: old ? old.name : I18n.t(:label_agenda_item_undisclosed_wp, id: values.first))+ end++ def visible(work_package_id)+ WorkPackage.visible.find_by(id: work_package_id)+ end+enddiff --git a/modules/meeting/spec/features/structured_meetings/history_spec.rb b/modules/meeting/spec/features/structured_meetings/history_spec.rbindex 49fe73624ff..be82d756aa0 100644--- a/modules/meeting/spec/features/structured_meetings/history_spec.rb+++ b/modules/meeting/spec/features/structured_meetings/history_spec.rb@@ -53,7 +53,9 @@ RSpec.describe "history",shared_let(:work_package) docreate(:work_package, project:, subject: "Important task")end-+ shared_let(:changed_wp) do+ create(:work_package, project:, subject: "Changed task")+ endshared_let(:other_wp) docreate(:work_package, project: other_project, subject: "Private WP")end@@ -200,12 +202,12 @@ RSpec.describe "history",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+ # Add linked work packageshow_page.visit!show_page.add_agenda_item(type: WorkPackage) doselect_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),- query: "task",+ query: "Important task",results_selector: "body")end@@ -219,16 +221,37 @@ RSpec.describe "history",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)+ # Update linked work package+ show_page.visit!++ show_page.edit_agenda_item(wp_item) do+ select_autocomplete(find_test_selector("op-agenda-items-wp-autocomplete"),+ query: "Changed task",+ results_selector: "body")+ click_link_or_button "Save"+ end++ show_page.expect_agenda_item title: "Changed task"+ wp_item = MeetingAgendaItem.find_by!(work_package_id: changed_wp.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: changed_wp.to_s.strip)+ expect(item).to have_css(".op-activity-list--item-subtitle", text: "updated by")+ expect(item).to have_css(".op-activity-list--item-subtitle", text: user.name)+ expect(item).to have_css("li", text: "Agenda item work package changed from Important task to Changed task")++ # Remove linked work packageshow_page.visit!show_page.remove_agenda_item wp_itemhistory_page.open_history_modalitem = 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-title", text: changed_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)-# With a work package linked in another projectshow_page.visit!show_page.add_agenda_item(type: WorkPackage) do