summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/journals_controller.rb5
-rw-r--r--app/helpers/journals_helper.rb6
-rw-r--r--app/views/issues/_history.html.erb2
-rw-r--r--app/views/journals/_notes_form.html.erb3
-rw-r--r--app/views/journals/update.js.erb2
5 files changed, 16 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 @@
<h4><a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
<%= 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? %></h4>
+ <%= render_private_notes(journal) %></h4>
<% if journal.details.any? %>
<ul class="details">
diff --git a/app/views/journals/_notes_form.html.erb b/app/views/journals/_notes_form.html.erb
index 41650c5d3..e8e73bb18 100644
--- a/app/views/journals/_notes_form.html.erb
+++ b/app/views/journals/_notes_form.html.erb
@@ -7,6 +7,9 @@
:id => "journal_#{@journal.id}_notes",
:class => 'wiki-edit',
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %>
+ <% if @journal.issue.safe_attribute? 'private_notes' %>
+ <%= check_box_tag 'private_notes', '1', @journal.private_notes, :id => "journal_#{@journal.id}_private_notes" %> <label for="journal_<%= @journal.id %>_private_notes"><%= l(:field_private_notes) %></label>
+ <% end %>
<%= call_hook(:view_journals_notes_form_after_notes, { :journal => @journal}) %>
<p><%= submit_tag l(:button_save) %>
<%= preview_link preview_edit_issue_path(:project_id => @project, :id => @journal.issue),
diff --git a/app/views/journals/update.js.erb b/app/views/journals/update.js.erb
index 65c198d59..34adf1567 100644
--- a/app/views/journals/update.js.erb
+++ b/app/views/journals/update.js.erb
@@ -1,7 +1,9 @@
<% if @journal.frozen? %>
$("#change-<%= @journal.id %>").remove();
<% else %>
+ $("#change-<%= @journal.id %>").attr('class', '<%= @journal.css_classes %>');
$("#journal-<%= @journal.id %>-notes").replaceWith('<%= escape_javascript(render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit'))) %>');
+ $("#journal-<%= @journal.id %>-private_notes").replaceWith('<%= escape_javascript(render_private_notes(@journal)) %>');
$("#journal-<%= @journal.id %>-notes").show();
$("#journal-<%= @journal.id %>-form").remove();
<% end %>