* edit_issue_notes: let user edit any notes * edit_own_issue_notes: let user edit his own notes only git-svn-id: http://redmine.rubyforge.org/svn/trunk@1152 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -22,11 +22,11 @@ class JournalsController < ApplicationController
|
||||
def edit
|
||||
if request.post?
|
||||
@journal.update_attributes(:notes => params[:notes]) if params[:notes]
|
||||
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
|
||||
format.js { render :action => 'update' }
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ module JournalsHelper
|
||||
def render_notes(journal, options={})
|
||||
content = ''
|
||||
editable = journal.editable_by?(User.current)
|
||||
if editable
|
||||
if editable && !journal.notes.blank?
|
||||
links = []
|
||||
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
||||
{ :controller => 'journals', :action => 'edit', :id => journal },
|
||||
|
||||
@@ -51,6 +51,7 @@ class Journal < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def editable_by?(usr)
|
||||
usr && usr.admin?
|
||||
project = journalized.project
|
||||
usr && usr.logged? && (usr.allowed_to?(:edit_issue_notes, project) || (self.user == usr && usr.allowed_to?(:edit_own_issue_notes, project)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<% note_id = 1 %>
|
||||
<% for journal in journals %>
|
||||
<div id="change-<%= journal.id %>">
|
||||
<h4><div style="float:right;"><%= link_to "##{note_id}", :anchor => "note-#{note_id}" %></div>
|
||||
<%= content_tag('a', '', :name => "note-#{note_id}")%>
|
||||
<%= format_time(journal.created_on) %> - <%= journal.user.name %></h4>
|
||||
@@ -9,5 +10,6 @@
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= render_notes(journal) unless journal.notes.blank? %>
|
||||
</div>
|
||||
<% note_id += 1 %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
page.replace "journal-#{@journal.id}-notes", render_notes(@journal)
|
||||
page.show "journal-#{@journal.id}-notes"
|
||||
page.remove "journal-#{@journal.id}-form"
|
||||
if @journal.frozen?
|
||||
# journal was destroyed
|
||||
page.remove "change-#{@journal.id}"
|
||||
else
|
||||
page.replace "journal-#{@journal.id}-notes", render_notes(@journal)
|
||||
page.show "journal-#{@journal.id}-notes"
|
||||
page.remove "journal-#{@journal.id}-form"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user