@@ -16,10 +16,10 | |||
|
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, :update, :diff] | |
|
20 | 20 | before_filter :find_issue, :only => [:new] |
|
21 | 21 | before_filter :find_optional_project, :only => [:index] |
|
22 | before_filter :authorize, :only => [:new, :edit, :diff] | |
|
22 | before_filter :authorize, :only => [:new, :edit, :update, :diff] | |
|
23 | 23 | accept_rss_auth :index |
|
24 | 24 | menu_item :issues |
|
25 | 25 | |
@@ -82,19 +82,20 class JournalsController < ApplicationController | |||
|
82 | 82 | |
|
83 | 83 | def edit |
|
84 | 84 | (render_403; return false) unless @journal.editable_by?(User.current) |
|
85 | if request.post? | |
|
86 | @journal.update_attributes(:notes => params[:notes]) if params[:notes] | |
|
87 | @journal.destroy if @journal.details.empty? && @journal.notes.blank? | |
|
88 | call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) | |
|
89 | respond_to do |format| | |
|
90 | format.html { redirect_to issue_path(@journal.journalized) } | |
|
91 | format.js { render :action => 'update' } | |
|
92 | end | |
|
93 | else | |
|
94 | respond_to do |format| | |
|
95 | # TODO: implement non-JS journal update | |
|
96 | format.js | |
|
97 | end | |
|
85 | respond_to do |format| | |
|
86 | # TODO: implement non-JS journal update | |
|
87 | format.js | |
|
88 | end | |
|
89 | end | |
|
90 | ||
|
91 | def update | |
|
92 | (render_403; return false) unless @journal.editable_by?(User.current) | |
|
93 | @journal.update_attributes(:notes => params[:notes]) if params[:notes] | |
|
94 | @journal.destroy if @journal.details.empty? && @journal.notes.blank? | |
|
95 | call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params}) | |
|
96 | respond_to do |format| | |
|
97 | format.html { redirect_to issue_path(@journal.journalized) } | |
|
98 | format.js | |
|
98 | 99 | end |
|
99 | 100 | end |
|
100 | 101 |
@@ -456,8 +456,7 module IssuesHelper | |||
|
456 | 456 | s = l(:text_journal_changed_no_detail, :label => label) |
|
457 | 457 | unless no_html |
|
458 | 458 | diff_link = link_to 'diff', |
|
459 | {:controller => 'journals', :action => 'diff', :id => detail.journal_id, | |
|
460 | :detail_id => detail.id, :only_path => options[:only_path]}, | |
|
459 | diff_journal_url(detail.journal_id, :detail_id => detail.id, :only_path => options[:only_path]), | |
|
461 | 460 | :title => l(:label_view_diff) |
|
462 | 461 | s << " (#{ diff_link })" |
|
463 | 462 | end |
@@ -31,23 +31,23 module JournalsHelper | |||
|
31 | 31 | links = [] |
|
32 | 32 | if !journal.notes.blank? |
|
33 | 33 | links << link_to('', |
|
34 |
|
|
|
34 | quoted_issue_path(issue, :journal_id => journal), | |
|
35 | 35 | :remote => true, |
|
36 | 36 | :method => 'post', |
|
37 | 37 | :title => l(:button_quote), |
|
38 | 38 | :class => 'icon-only icon-comment' |
|
39 | 39 | ) if options[:reply_links] |
|
40 | 40 | links << link_to('', |
|
41 |
|
|
|
41 | edit_journal_path(journal), | |
|
42 | 42 | :remote => true, |
|
43 | 43 | :method => 'get', |
|
44 | 44 | :title => l(:button_edit), |
|
45 | 45 | :class => 'icon-only icon-edit' |
|
46 | 46 | ) if editable |
|
47 | 47 | links << link_to('', |
|
48 |
|
|
|
48 | journal_path(journal, :notes => ""), | |
|
49 | 49 | :remote => true, |
|
50 |
:method => |
|
|
50 | :method => 'put', :data => {:confirm => l(:text_are_you_sure)}, | |
|
51 | 51 | :title => l(:button_delete), |
|
52 | 52 | :class => 'icon-only icon-del' |
|
53 | 53 | ) if editable |
@@ -1,5 +1,6 | |||
|
1 | <%= form_tag({:controller => 'journals', :action => 'edit', :id => @journal}, | |
|
1 | <%= form_tag(journal_path(@journal), | |
|
2 | 2 | :remote => true, |
|
3 | :method => 'put', | |
|
3 | 4 | :id => "journal-#{@journal.id}-form") do %> |
|
4 | 5 | <%= label_tag "notes", l(:description_notes), :class => "hidden-for-sighted" %> |
|
5 | 6 | <%= text_area_tag :notes, @journal.notes, |
@@ -49,8 +49,11 Rails.application.routes.draw do | |||
|
49 | 49 | match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get |
|
50 | 50 | match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue' |
|
51 | 51 | |
|
52 | match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get | |
|
53 | match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post] | |
|
52 | resources :journals, :only => [:edit, :update] do | |
|
53 | member do | |
|
54 | get 'diff' | |
|
55 | end | |
|
56 | end | |
|
54 | 57 | |
|
55 | 58 | get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt' |
|
56 | 59 | get '/issues/gantt', :to => 'gantts#show' |
@@ -105,8 +105,8 Redmine::AccessControl.map do |map| | |||
|
105 | 105 | map.permission :set_issues_private, {} |
|
106 | 106 | map.permission :set_own_issues_private, {}, :require => :loggedin |
|
107 | 107 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload} |
|
108 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin | |
|
109 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin | |
|
108 | map.permission :edit_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin | |
|
109 | map.permission :edit_own_issue_notes, {:journals => [:edit, :update]}, :require => :loggedin | |
|
110 | 110 | map.permission :view_private_notes, {}, :read => true, :require => :member |
|
111 | 111 | map.permission :set_notes_private, {}, :require => :member |
|
112 | 112 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
@@ -199,7 +199,7 class JournalsControllerTest < ActionController::TestCase | |||
|
199 | 199 | |
|
200 | 200 | def test_update_xhr |
|
201 | 201 | @request.session[:user_id] = 1 |
|
202 |
xhr :post, : |
|
|
202 | xhr :post, :update, :id => 2, :notes => 'Updated notes' | |
|
203 | 203 | assert_response :success |
|
204 | 204 | assert_template 'update' |
|
205 | 205 | assert_equal 'text/javascript', response.content_type |
@@ -210,7 +210,7 class JournalsControllerTest < ActionController::TestCase | |||
|
210 | 210 | def test_update_xhr_with_empty_notes_should_delete_the_journal |
|
211 | 211 | @request.session[:user_id] = 1 |
|
212 | 212 | assert_difference 'Journal.count', -1 do |
|
213 |
xhr :post, : |
|
|
213 | xhr :post, :update, :id => 2, :notes => '' | |
|
214 | 214 | assert_response :success |
|
215 | 215 | assert_template 'update' |
|
216 | 216 | assert_equal 'text/javascript', response.content_type |
@@ -21,9 +21,9 class RoutingJournalsTest < Redmine::RoutingTest | |||
|
21 | 21 | def test_journals |
|
22 | 22 | should_route 'POST /issues/1/quoted' => 'journals#new', :id => '1' |
|
23 | 23 | should_route 'GET /issues/changes' => 'journals#index' |
|
24 |
should_route 'GET /journals/diff |
|
|
24 | should_route 'GET /journals/1/diff' => 'journals#diff', :id => '1' | |
|
25 | 25 | |
|
26 |
should_route 'GET /journals/edit |
|
|
27 |
should_route 'P |
|
|
26 | should_route 'GET /journals/1/edit' => 'journals#edit', :id => '1' | |
|
27 | should_route 'PUT /journals/1' => 'journals#update', :id => '1' | |
|
28 | 28 | end |
|
29 | 29 | end |
@@ -68,7 +68,7 class MailerTest < ActiveSupport::TestCase | |||
|
68 | 68 | # should be https://mydomain.foo/journals/diff/3?detail_id=4 |
|
69 | 69 | # but the Rails 4.2 DOM assertion doesn't handle the ? in the |
|
70 | 70 | # attribute value |
|
71 |
'https://mydomain.foo/journals/diff |
|
|
71 | 'https://mydomain.foo/journals/3/diff', | |
|
72 | 72 | 'View differences', |
|
73 | 73 | :text => 'diff' |
|
74 | 74 | # link to an attachment |
@@ -109,7 +109,7 class MailerTest < ActiveSupport::TestCase | |||
|
109 | 109 | # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4 |
|
110 | 110 | # but the Rails 4.2 DOM assertion doesn't handle the ? in the |
|
111 | 111 | # attribute value |
|
112 |
'http://mydomain.foo/rdm/journals/diff |
|
|
112 | 'http://mydomain.foo/rdm/journals/3/diff', | |
|
113 | 113 | 'View differences', |
|
114 | 114 | :text => 'diff' |
|
115 | 115 | # link to an attachment |
@@ -179,7 +179,7 class MailerTest < ActiveSupport::TestCase | |||
|
179 | 179 | # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4 |
|
180 | 180 | # but the Rails 4.2 DOM assertion doesn't handle the ? in the |
|
181 | 181 | # attribute value |
|
182 |
'http://mydomain.foo/rdm/journals/diff |
|
|
182 | 'http://mydomain.foo/rdm/journals/3/diff', | |
|
183 | 183 | 'View differences', |
|
184 | 184 | :text => 'diff' |
|
185 | 185 | # link to an attachment |
General Comments 0
You need to be logged in to leave comments.
Login now