16 |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
17 |
17 |
|
18 |
18 |
class JournalsController < ApplicationController
|
19 |
|
before_filter :find_journal, :only => [:edit, :diff]
|
|
19 |
before_filter :find_journal, :only => [:edit, :diff, :delete]
|
20 |
20 |
before_filter :find_issue, :only => [:new]
|
21 |
21 |
before_filter :find_optional_project, :only => [:index]
|
22 |
22 |
before_filter :authorize, :only => [:new, :edit, :diff]
|
... | ... | |
94 |
94 |
end
|
95 |
95 |
end
|
96 |
96 |
|
|
97 |
def delete
|
|
98 |
(render_403; return false) unless User.current.allowed_to?(:delete_journal_entries, @project)
|
|
99 |
@journal.destroy
|
|
100 |
respond_to do |format|
|
|
101 |
format.html { render :nothing => true }
|
|
102 |
format.js
|
|
103 |
end
|
|
104 |
end
|
|
105 |
|
97 |
106 |
private
|
98 |
107 |
|
99 |
108 |
def find_journal
|
100 |
|
-- app/helpers/journals_helper.rb
|
|
109 |
++ app/helpers/journals_helper.rb
|
... | ... | |
43 |
43 |
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
44 |
44 |
link_to text, '#', options.merge(:onclick => onclick)
|
45 |
45 |
end
|
|
46 |
|
|
47 |
def render_journal_entry_delete(issue, journal, options={})
|
|
48 |
deletable = User.current.logged? && User.current.allowed_to?(:delete_journal_entries, issue.project)
|
|
49 |
action = "$.ajax({url: '#{url_for({:controller => 'journals', :action => 'delete', :id => journal, :format => 'js'})}', type: 'get'})"
|
|
50 |
confirm = "if (confirm('#{l(:text_journal_confirm_delete)}')) {#{action}}"
|
|
51 |
onclick = "#{confirm};return false;"
|
|
52 |
link = link_to(image_tag('delete.png'), '#',
|
|
53 |
:onclick => onclick,
|
|
54 |
:title => l(:button_delete)) if deletable
|
|
55 |
content_tag('span', link.html_safe, :style => 'float:right;align:right;')
|
|
56 |
end
|
46 |
57 |
end
|
47 |
|
-- app/views/issues/_history.html.erb
|
|
58 |
++ app/views/issues/_history.html.erb
|
... | ... | |
5 |
5 |
<h4><%= link_to "##{journal.indice}", {:anchor => "note-#{journal.indice}"}, :class => "journal-link" %>
|
6 |
6 |
<%= avatar(journal.user, :size => "24") %>
|
7 |
7 |
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
|
8 |
|
<%= content_tag('span', l(:field_is_private), :class => 'private') if journal.private_notes? %></h4>
|
|
8 |
<%= content_tag('span', l(:field_is_private), :class => 'private') if journal.private_notes? %>
|
|
9 |
<%= render_journal_entry_delete(issue, journal) if User.current.allowed_to?(:delete_journal_entries, @project) %>
|
|
10 |
</h4>
|
9 |
11 |
|
10 |
12 |
<% if journal.details.any? %>
|
11 |
13 |
<ul class="details">
|
12 |
|
-- app/views/journals/delete.js.erb
|
|
14 |
++ app/views/journals/delete.js.erb
|
... | ... | |
|
1 |
<% if @journal.frozen? %>
|
|
2 |
$("#change-<%= @journal.id %>").remove();
|
|
3 |
<% end %>
|
|
4 |
|
|
5 |
<%= call_hook(:view_journals_update_js_bottom, { :journal => @journal }) %>
|
... | ... | |
0 |
|
-- config/locales/cs.yml
|
|
6 |
++ config/locales/cs.yml
|
... | ... | |
|
424 |
permission_delete_journal_entries: Mazání záznamů změn
|
... | ... | |
|
863 |
text_journal_confirm_delete: Opravdu chcete smazat tento záznam změny?
|
... | ... | |
862 |
|
-- config/locales/en.yml
|
|
864 |
++ config/locales/en.yml
|
... | ... | |
|
476 |
permission_delete_journal_entries: Delete journal entries
|
... | ... | |
|
1000 |
text_journal_confirm_delete: 'Are you sure you want to delete selected comment?'
|
... | ... | |
999 |
|
-- config/routes.rb
|
|
1001 |
++ config/routes.rb
|
... | ... | |
51 |
51 |
|
52 |
52 |
match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
|
53 |
53 |
match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
|
|
54 |
match '/journals/delete/:id', :to => 'journals#delete', :id => /\d+/, :via => [:get, :delete]
|
54 |
55 |
|
55 |
56 |
get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
|
56 |
57 |
get '/issues/gantt', :to => 'gantts#show'
|
57 |
|
-- lib/redmine.rb
|
|
58 |
++ lib/redmine.rb
|
... | ... | |
116 |
116 |
map.permission :set_notes_private, {}, :require => :member
|
117 |
117 |
map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin
|
118 |
118 |
map.permission :delete_issues, {:issues => :destroy}, :require => :member
|
|
119 |
map.permission :delete_journal_entries, {:journals => :delete}, :require => :member
|
119 |
120 |
# Queries
|
120 |
121 |
map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member
|
121 |
122 |
map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin
|