From 7918285ac2e64fe046e590fbb1afb1e1f2fb9422 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 10 Jul 2016 10:33:48 +0000 Subject: [PATCH] Enable updating private_notes property on journal edit form (#22575). Patch by Takenori TAKAKI. git-svn-id: http://svn.redmine.org/redmine/trunk@15620 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/journals_controller.rb | 5 +++- app/helpers/journals_helper.rb | 6 ++++ app/views/issues/_history.html.erb | 2 +- app/views/journals/_notes_form.html.erb | 3 ++ app/views/journals/update.js.erb | 2 ++ test/functional/journals_controller_test.rb | 33 +++++++++++++++++++++ 6 files changed, 49 insertions(+), 2 deletions(-) diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index a0905aed1..6780916b7 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -90,7 +90,10 @@ class JournalsController < ApplicationController def update (render_403; return false) unless @journal.editable_by?(User.current) - @journal.update_attributes(:notes => params[:notes]) if params[:notes] + @journal.notes = params[:notes] if params[:notes] + @journal.private_notes = params[:private_notes].present? + (render_403; return false) if @journal.private_notes_changed? && User.current.allowed_to?(:set_notes_private, @journal.issue.project) == false + @journal.save if @journal.changed? @journal.destroy if @journal.details.empty? && @journal.notes.blank? call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) respond_to do |format| diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index f9dc7c9ea..e31ad2544 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -58,4 +58,10 @@ module JournalsHelper css_classes << " editable" if editable content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) end + + def render_private_notes(journal) + content = journal.private_notes? ? l(:field_is_private) : '' + css_classes = journal.private_notes? ? 'private' : '' + content_tag('span', content.html_safe, :id => "journal-#{journal.id}-private_notes", :class => css_classes) + end end diff --git a/app/views/issues/_history.html.erb b/app/views/issues/_history.html.erb index 307ac909b..603e8f984 100644 --- a/app/views/issues/_history.html.erb +++ b/app/views/issues/_history.html.erb @@ -5,7 +5,7 @@

#<%= journal.indice %> <%= avatar(journal.user, :size => "24") %> <%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %> - <%= content_tag('span', l(:field_is_private), :class => 'private') if journal.private_notes? %>

+ <%= render_private_notes(journal) %> <% if journal.details.any? %>