mirror of
https://github.com/redmine/redmine.git
synced 2025-10-26 07:46:17 +01:00
Mark edited journal notes as "Edited" (#31505).
Patch by Marius BALTEANU. git-svn-id: https://svn.redmine.org/redmine/trunk@21713 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -91,7 +91,9 @@ class JournalsController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
(render_403; return false) unless @journal.editable_by?(User.current)
|
(render_403; return false) unless @journal.editable_by?(User.current)
|
||||||
@journal.safe_attributes = params[:journal]
|
journal_attributes = params[:journal]
|
||||||
|
journal_attributes[:updated_by] = User.current
|
||||||
|
@journal.safe_attributes = journal_attributes
|
||||||
@journal.save
|
@journal.save
|
||||||
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
||||||
call_hook(:controller_journals_edit_post, {:journal => @journal, :params => params})
|
call_hook(:controller_journals_edit_post, {:journal => @journal, :params => params})
|
||||||
|
|||||||
@@ -79,4 +79,10 @@ module JournalsHelper
|
|||||||
css_classes = journal.private_notes? ? 'badge badge-private private' : ''
|
css_classes = journal.private_notes? ? 'badge badge-private private' : ''
|
||||||
content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
|
content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Journal < ActiveRecord::Base
|
|||||||
belongs_to :issue, :foreign_key => :journalized_id
|
belongs_to :issue, :foreign_key => :journalized_id
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
belongs_to :updated_by, :class_name => 'User'
|
||||||
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all, :inverse_of => :journal
|
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all, :inverse_of => :journal
|
||||||
attr_accessor :indice
|
attr_accessor :indice
|
||||||
|
|
||||||
@@ -78,6 +79,7 @@ class Journal < ActiveRecord::Base
|
|||||||
safe_attributes(
|
safe_attributes(
|
||||||
'private_notes',
|
'private_notes',
|
||||||
:if => lambda {|journal, user| user.allowed_to?(:set_notes_private, journal.project)})
|
:if => lambda {|journal, user| user.allowed_to?(:set_notes_private, journal.project)})
|
||||||
|
safe_attributes 'updated_by'
|
||||||
|
|
||||||
# Returns a SQL condition to filter out journals with notes that are not visible to user
|
# Returns a SQL condition to filter out journals with notes that are not visible to user
|
||||||
def self.visible_notes_condition(user=User.current, options={})
|
def self.visible_notes_condition(user=User.current, options={})
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<%= avatar(journal.user) %>
|
<%= avatar(journal.user) %>
|
||||||
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
|
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
|
||||||
<%= render_private_notes_indicator(journal) %>
|
<%= render_private_notes_indicator(journal) %>
|
||||||
|
<%= render_journal_update_info(journal) %>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<% if journal.details.any? %>
|
<% if journal.details.any? %>
|
||||||
|
|||||||
@@ -7,6 +7,13 @@
|
|||||||
$("#journal-<%= @journal.id %>-notes").replaceWith('<%= escape_javascript(render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit'))) %>');
|
$("#journal-<%= @journal.id %>-notes").replaceWith('<%= escape_javascript(render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit'))) %>');
|
||||||
$("#journal-<%= @journal.id %>-notes").show();
|
$("#journal-<%= @journal.id %>-notes").show();
|
||||||
$("#journal-<%= @journal.id %>-form").remove();
|
$("#journal-<%= @journal.id %>-form").remove();
|
||||||
|
var journal_header = $("#change-<%= @journal.id %> h4");
|
||||||
|
var journal_updated_info = journal_header.find("span.update-info");
|
||||||
|
if (journal_updated_info.length > 0) {
|
||||||
|
journal_updated_info.replaceWith('<%= escape_javascript(render_journal_update_info(@journal)) %>');
|
||||||
|
} else {
|
||||||
|
journal_header.append('<%= escape_javascript(render_journal_update_info(@journal)) %>');
|
||||||
|
}
|
||||||
setupWikiTableSortableHeader();
|
setupWikiTableSortableHeader();
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -1129,6 +1129,8 @@ en:
|
|||||||
label_my_bookmarks: My bookmarks
|
label_my_bookmarks: My bookmarks
|
||||||
label_assign_to_me: Assign to me
|
label_assign_to_me: Assign to me
|
||||||
label_default_query: Default query
|
label_default_query: Default query
|
||||||
|
label_edited: Edited
|
||||||
|
label_time_by_author: "%{time} by %{author}"
|
||||||
|
|
||||||
button_login: Login
|
button_login: Login
|
||||||
button_submit: Submit
|
button_submit: Submit
|
||||||
|
|||||||
10
db/migrate/20220714093000_add_journal_updated_on.rb
Normal file
10
db/migrate/20220714093000_add_journal_updated_on.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class AddJournalUpdatedOn < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
add_column :journals, :updated_on, :datetime, :after => :created_on
|
||||||
|
Journal.update_all('updated_on = created_on')
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :journals, :updated_on
|
||||||
|
end
|
||||||
|
end
|
||||||
9
db/migrate/20220714093010_add_journal_updated_by.rb
Normal file
9
db/migrate/20220714093010_add_journal_updated_by.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class AddJournalUpdatedBy < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
add_column :journals, :updated_by_id, :integer, :default => nil, :after => :updated_on
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :journals, :updated_by_id
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -610,6 +610,7 @@ div.journal ul.details a, ul.revision-info a {color:#70A7CD;}
|
|||||||
div.journal ul.details a:hover, ul.revision-info a:hover {color:#D14848;}
|
div.journal ul.details a:hover, ul.revision-info a:hover {color:#D14848;}
|
||||||
body.avatars-on div.journal {padding-left:32px;}
|
body.avatars-on div.journal {padding-left:32px;}
|
||||||
div.journal h4 img.gravatar {margin-left:-32px;}
|
div.journal h4 img.gravatar {margin-left:-32px;}
|
||||||
|
div.journal span.update-info {color: #666; font-size: 0.9em;}
|
||||||
|
|
||||||
#history .tab-content {
|
#history .tab-content {
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
|
|||||||
6
test/fixtures/journals.yml
vendored
6
test/fixtures/journals.yml
vendored
@@ -1,13 +1,16 @@
|
|||||||
---
|
---
|
||||||
journals_001:
|
journals_001:
|
||||||
created_on: <%= 2.days.ago.to_date.to_s(:db) %>
|
created_on: <%= 2.days.ago.to_date.to_s(:db) %>
|
||||||
|
updated_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
notes: "Journal notes"
|
notes: "Journal notes"
|
||||||
id: 1
|
id: 1
|
||||||
journalized_type: Issue
|
journalized_type: Issue
|
||||||
user_id: 1
|
user_id: 1
|
||||||
journalized_id: 1
|
journalized_id: 1
|
||||||
|
updated_by_id: 1
|
||||||
journals_002:
|
journals_002:
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
updated_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
notes: "Some notes with Redmine links: #2, r2."
|
notes: "Some notes with Redmine links: #2, r2."
|
||||||
id: 2
|
id: 2
|
||||||
journalized_type: Issue
|
journalized_type: Issue
|
||||||
@@ -15,6 +18,7 @@ journals_002:
|
|||||||
journalized_id: 1
|
journalized_id: 1
|
||||||
journals_003:
|
journals_003:
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
updated_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
notes: "A comment with inline image: !picture.jpg! and a reference to #1 and r2."
|
notes: "A comment with inline image: !picture.jpg! and a reference to #1 and r2."
|
||||||
id: 3
|
id: 3
|
||||||
journalized_type: Issue
|
journalized_type: Issue
|
||||||
@@ -22,6 +26,7 @@ journals_003:
|
|||||||
journalized_id: 2
|
journalized_id: 2
|
||||||
journals_004:
|
journals_004:
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
updated_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
notes: "A comment with a private version."
|
notes: "A comment with a private version."
|
||||||
id: 4
|
id: 4
|
||||||
journalized_type: Issue
|
journalized_type: Issue
|
||||||
@@ -30,6 +35,7 @@ journals_004:
|
|||||||
journals_005:
|
journals_005:
|
||||||
id: 5
|
id: 5
|
||||||
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
created_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
|
updated_on: <%= 1.days.ago.to_date.to_s(:db) %>
|
||||||
notes: "A comment on a private issue."
|
notes: "A comment on a private issue."
|
||||||
user_id: 2
|
user_id: 2
|
||||||
journalized_type: Issue
|
journalized_type: Issue
|
||||||
|
|||||||
@@ -2894,6 +2894,16 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
assert_select "#change-#{not_visible.id}", 0
|
assert_select "#change-#{not_visible.id}", 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_show_should_mark_notes_as_edited_only_for_edited_notes
|
||||||
|
get :show, :params => {:id => 1}
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
journal = Journal.find(1)
|
||||||
|
journal_title = l(:label_time_by_author, :time => format_time(journal.updated_on), :author => journal.updated_by)
|
||||||
|
assert_select "#change-1 h4 span.update-info[title=?]", journal_title, :text => '· Edited'
|
||||||
|
assert_select "#change-2 h4 span.update-info", 0
|
||||||
|
end
|
||||||
|
|
||||||
def test_show_atom
|
def test_show_atom
|
||||||
with_settings :text_formatting => 'textile' do
|
with_settings :text_formatting => 'textile' do
|
||||||
get(
|
get(
|
||||||
|
|||||||
Reference in New Issue
Block a user