git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3941 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/1.1.0
@@ -19,7 +19,7 @@ class IssuesController < ApplicationController | |||
menu_item :new_issue, :only => [:new, :create] | |||
default_search_scope :issues | |||
before_filter :find_issue, :only => [:show, :edit, :update, :reply] | |||
before_filter :find_issue, :only => [:show, :edit, :update] | |||
before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy] | |||
before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete] | |||
before_filter :authorize, :except => [:index, :changes, :preview, :context_menu] | |||
@@ -200,29 +200,6 @@ class IssuesController < ApplicationController | |||
end | |||
end | |||
def reply | |||
journal = Journal.find(params[:journal_id]) if params[:journal_id] | |||
if journal | |||
user = journal.user | |||
text = journal.notes | |||
else | |||
user = @issue.author | |||
text = @issue.description | |||
end | |||
# Replaces pre blocks with [...] | |||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]') | |||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " | |||
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" | |||
render(:update) { |page| | |||
page.<< "$('notes').value = \"#{escape_javascript content}\";" | |||
page.show 'update' | |||
page << "Form.Element.focus('notes');" | |||
page << "Element.scrollTo('update');" | |||
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;" | |||
} | |||
end | |||
# Bulk edit a set of issues | |||
def bulk_edit | |||
@issues.sort! |
@@ -16,7 +16,31 @@ | |||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
class JournalsController < ApplicationController | |||
before_filter :find_journal | |||
before_filter :find_journal, :only => [:edit] | |||
before_filter :find_issue, :only => [:new] | |||
def new | |||
journal = Journal.find(params[:journal_id]) if params[:journal_id] | |||
if journal | |||
user = journal.user | |||
text = journal.notes | |||
else | |||
user = @issue.author | |||
text = @issue.description | |||
end | |||
# Replaces pre blocks with [...] | |||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]') | |||
content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " | |||
content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" | |||
render(:update) { |page| | |||
page.<< "$('notes').value = \"#{escape_javascript content}\";" | |||
page.show 'update' | |||
page << "Form.Element.focus('notes');" | |||
page << "Element.scrollTo('update');" | |||
page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;" | |||
} | |||
end | |||
def edit | |||
if request.post? | |||
@@ -38,4 +62,12 @@ private | |||
rescue ActiveRecord::RecordNotFound | |||
render_404 | |||
end | |||
# TODO: duplicated in IssuesController | |||
def find_issue | |||
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) | |||
@project = @issue.project | |||
rescue ActiveRecord::RecordNotFound | |||
render_404 | |||
end | |||
end |
@@ -22,7 +22,7 @@ module JournalsHelper | |||
links = [] | |||
if !journal.notes.blank? | |||
links << link_to_remote(image_tag('comment.png'), | |||
{ :url => {:controller => 'issues', :action => 'reply', :id => issue, :journal_id => journal} }, | |||
{ :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} }, | |||
:title => l(:button_quote)) if options[:reply_links] | |||
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes", | |||
{ :controller => 'journals', :action => 'edit', :id => journal }, |
@@ -124,7 +124,7 @@ ActionController::Routing::Routes.draw do |map| | |||
issues_actions.connect 'projects/:project_id/issues', :action => 'create' | |||
issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show' | |||
issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show' | |||
issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/ | |||
issues_actions.connect 'issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/ | |||
issues_actions.connect 'issues/:id/:action', :action => /edit|destroy/, :id => /\d+/ | |||
issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/ | |||
end |
@@ -63,10 +63,10 @@ Redmine::AccessControl.map do |map| | |||
:queries => :index, | |||
:reports => [:issue_report, :issue_report_details]} | |||
map.permission :add_issues, {:issues => [:new, :create, :update_form]} | |||
map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]} | |||
map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :update_form], :journals => [:new]} | |||
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} | |||
map.permission :manage_subtasks, {} | |||
map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]} | |||
map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} | |||
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin | |||
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin | |||
map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin |
@@ -634,20 +634,6 @@ class IssuesControllerTest < ActionController::TestCase | |||
assert_equal 'This is the test_new issue', issue.subject | |||
end | |||
def test_reply_to_issue | |||
@request.session[:user_id] = 2 | |||
get :reply, :id => 1 | |||
assert_response :success | |||
assert_select_rjs :show, "update" | |||
end | |||
def test_reply_to_note | |||
@request.session[:user_id] = 2 | |||
get :reply, :id => 1, :journal_id => 2 | |||
assert_response :success | |||
assert_select_rjs :show, "update" | |||
end | |||
def test_update_using_invalid_http_verbs | |||
@request.session[:user_id] = 2 | |||
subject = 'Updated by an invalid http verb' |
@@ -31,6 +31,20 @@ class JournalsControllerTest < ActionController::TestCase | |||
User.current = nil | |||
end | |||
def test_reply_to_issue | |||
@request.session[:user_id] = 2 | |||
get :new, :id => 1 | |||
assert_response :success | |||
assert_select_rjs :show, "update" | |||
end | |||
def test_reply_to_note | |||
@request.session[:user_id] = 2 | |||
get :new, :id => 1, :journal_id => 2 | |||
assert_response :success | |||
assert_select_rjs :show, "update" | |||
end | |||
def test_get_edit | |||
@request.session[:user_id] = 1 | |||
xhr :get, :edit, :id => 2 |
@@ -88,7 +88,7 @@ class RoutingTest < ActionController::IntegrationTest | |||
should_route :get, "/issues/move/new", :controller => 'issue_moves', :action => 'new' | |||
should_route :post, "/issues/move", :controller => 'issue_moves', :action => 'create' | |||
should_route :post, "/issues/1/quoted", :controller => 'issues', :action => 'reply', :id => '1' | |||
should_route :post, "/issues/1/quoted", :controller => 'journals', :action => 'new', :id => '1' | |||
should_route :get, "/issues/calendar", :controller => 'calendars', :action => 'show' | |||
should_route :post, "/issues/calendar", :controller => 'calendars', :action => 'show' |