From 732aadf555fd9a5b8db0be9dd8053eef06c6fc9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20B=C4=82LTEANU?= Date: Sun, 12 Jul 2026 01:17:31 +0300 Subject: [PATCH] wip --- app/assets/stylesheets/application.css | 4 ++++ app/controllers/journals_controller.rb | 12 ++++++++++-- app/helpers/journals_helper.rb | 12 +++++++++++- app/models/journal.rb | 6 ++++++ app/views/issues/tabs/_history.html.erb | 2 +- app/views/journals/_history.html.erb | 22 ++++++++++++++++++++++ app/views/journals/history.js.erb | 2 ++ app/views/journals/update.js.erb | 2 +- config/routes.rb | 1 + lib/redmine/preparation.rb | 2 +- 10 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 app/views/journals/_history.html.erb create mode 100644 app/views/journals/history.js.erb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 54579408f..d49d21474 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -2071,6 +2071,10 @@ div.wiki .task-list input.task-list-item-checkbox { } .journals h4.journal-header .update-info { + font-size: 0.9em; +} + +.journals h4.journal-header span.update-info { color: var(--oc-gray-6); font-size: 0.9em; } diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 8e7bcab40..3775bd763 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -18,10 +18,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class JournalsController < ApplicationController - before_action :find_journal, :only => [:edit, :update, :diff] + before_action :find_journal, :only => [:edit, :update, :diff, :history] before_action :find_issue, :only => [:new] before_action :find_optional_project, :only => [:index] - before_action :authorize, :only => [:new, :edit, :update, :diff] + before_action :authorize, :only => [:new, :edit, :update, :diff, :history] accept_atom_auth :index accept_api_auth :update menu_item :issues @@ -64,6 +64,14 @@ class JournalsController < ApplicationController @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value) end + def history + @issue = @journal.issue + @details = @journal.details.where(property: 'attr', prop_key: 'notes').reorder(id: :desc) + respond_to do |format| + format.js + end + end + def new @journal = Journal.visible.find(params[:journal_id]) if params[:journal_id] @content = if @journal diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 4092b7b0f..4e6042b4e 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -82,6 +82,16 @@ module JournalsHelper def render_journal_update_info(journal) return if journal.created_on == journal.updated_on - content_tag('span', "· #{l(:label_edited)}", :title => l(:label_time_by_author, :time => format_time(journal.updated_on), :author => journal.updated_by), :class => 'update-info') + notes_details = journal.details.select {|d| d.property == 'attr' && d.prop_key == 'notes'} + if notes_details.any? + link_to("· #{l(:label_edited)}", + history_journal_path(journal), + :remote => true, + :class => 'update-info', + :title => l(:label_time_by_author, :time => format_time(journal.updated_on), :author => journal.updated_by)) + else + # Only show Edited label, no link since there is nothing to show in note history view + content_tag('span', "· #{l(:label_edited)}", :title => l(:label_time_by_author, :time => format_time(journal.updated_on), :author => journal.updated_by), :class => 'update-info') + end end end diff --git a/app/models/journal.rb b/app/models/journal.rb index 1874feb0c..92a103173 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -125,6 +125,8 @@ class Journal < ApplicationRecord detail.custom_field && detail.custom_field.visible_by?(project, user) elsif detail.property == 'relation' Issue.find_by_id(detail.value || detail.old_value).try(:visible?, user) + elsif detail.property == 'attr' && detail.prop_key == 'notes' + false else true end @@ -268,6 +270,10 @@ class Journal < ApplicationRecord # Generates journal details for attribute and custom field changes def journalize_changes + if !new_record? && notes_changed? + add_attribute_detail('notes', notes_was, notes) + end + # attributes changes if @attributes_before_change attrs = (journalized.journalized_attribute_names + @attributes_before_change.keys).uniq diff --git a/app/views/issues/tabs/_history.html.erb b/app/views/issues/tabs/_history.html.erb index b416a9d37..decbcee4b 100644 --- a/app/views/issues/tabs/_history.html.erb +++ b/app/views/issues/tabs/_history.html.erb @@ -22,7 +22,7 @@
- <% if journal.details.any? %> + <% if journal.visible_details.any? %>