--- app/controllers/journals_controller.rb
+++ app/controllers/journals_controller.rb
@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class JournalsController < ApplicationController
- before_filter :find_journal, :only => [:edit, :diff]
+ before_filter :find_journal, :only => [:edit, :diff, :delete]
before_filter :find_issue, :only => [:new]
before_filter :find_optional_project, :only => [:index]
before_filter :authorize, :only => [:new, :edit, :diff]
@@ -94,6 +94,15 @@
end
end
+ def delete
+ (render_403; return false) unless User.current.allowed_to?(:delete_journal_entries, @project)
+ @journal.destroy
+ respond_to do |format|
+ format.html { render :nothing => true }
+ format.js
+ end
+ end
+
private
def find_journal
--- app/helpers/journals_helper.rb
+++ app/helpers/journals_helper.rb
@@ -43,4 +43,15 @@
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
link_to text, '#', options.merge(:onclick => onclick)
end
+
+ def render_journal_entry_delete(issue, journal, options={})
+ deletable = User.current.logged? && User.current.allowed_to?(:delete_journal_entries, issue.project)
+ action = "$.ajax({url: '#{url_for({:controller => 'journals', :action => 'delete', :id => journal, :format => 'js'})}', type: 'get'})"
+ confirm = "if (confirm('#{l(:text_journal_confirm_delete)}')) {#{action}}"
+ onclick = "#{confirm};return false;"
+ link = link_to(image_tag('delete.png'), '#',
+ :onclick => onclick,
+ :title => l(:button_delete)) if deletable
+ content_tag('span', link.html_safe, :style => 'float:right;align:right;')
+ end
end
--- app/views/issues/_history.html.erb
+++ app/views/issues/_history.html.erb
@@ -5,7 +5,9 @@
<%= link_to "##{journal.indice}", {:anchor => "note-#{journal.indice}"}, :class => "journal-link" %>
<%= 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? %>
+ <%= content_tag('span', l(:field_is_private), :class => 'private') if journal.private_notes? %>
+ <%= render_journal_entry_delete(issue, journal) if User.current.allowed_to?(:delete_journal_entries, @project) %>
+
<% if journal.details.any? %>
--- app/views/journals/delete.js.erb
+++ app/views/journals/delete.js.erb
@@ -0,0 +1,5 @@
+<% if @journal.frozen? %>
+ $("#change-<%= @journal.id %>").remove();
+<% end %>
+
+<%= call_hook(:view_journals_update_js_bottom, { :journal => @journal }) %>
--- config/locales/cs.yml
+++ config/locales/cs.yml
@@ -424,0 +424,1 @@
+ permission_delete_journal_entries: Mazání záznamů změn
@@ -862,0 +863,1 @@
+ text_journal_confirm_delete: Opravdu chcete smazat tento záznam změny?
--- config/locales/en.yml
+++ config/locales/en.yml
@@ -476,0 +476,1 @@
+ permission_delete_journal_entries: Delete journal entries
@@ -999,0 +1000,1 @@
+ text_journal_confirm_delete: 'Are you sure you want to delete selected comment?'
--- config/routes.rb
+++ config/routes.rb
@@ -51,6 +51,7 @@
match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
+ match '/journals/delete/:id', :to => 'journals#delete', :id => /\d+/, :via => [:get, :delete]
get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
get '/issues/gantt', :to => 'gantts#show'
--- lib/redmine.rb
+++ lib/redmine.rb
@@ -116,6 +116,7 @@
map.permission :set_notes_private, {}, :require => :member
map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin
map.permission :delete_issues, {:issues => :destroy}, :require => :member
+ map.permission :delete_journal_entries, {:journals => :delete}, :require => :member
# Queries
map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member
map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin