From 7d57833740bb546753d6d908ee082e8268044fa3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Nov 2009 14:31:19 +0000 Subject: [PATCH] Adds a 'Move and follow' button on Move/Copy view to be redirected to the created issue(s) rather than the source project issue list (#1847). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3063 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 17 +++++++++++++++-- app/views/issues/move.rhtml | 3 ++- config/locales/bg.yml | 1 + config/locales/bs.yml | 1 + config/locales/ca.yml | 1 + config/locales/cs.yml | 1 + config/locales/da.yml | 1 + config/locales/de.yml | 1 + config/locales/el.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fi.yml | 1 + config/locales/fr.yml | 1 + config/locales/gl.yml | 1 + config/locales/he.yml | 1 + config/locales/hu.yml | 1 + config/locales/it.yml | 1 + config/locales/ja.yml | 1 + config/locales/ko.yml | 1 + config/locales/lt.yml | 1 + config/locales/nl.yml | 1 + config/locales/no.yml | 1 + config/locales/pl.yml | 1 + config/locales/pt-BR.yml | 1 + config/locales/pt.yml | 1 + config/locales/ro.yml | 1 + config/locales/ru.yml | 1 + config/locales/sk.yml | 1 + config/locales/sl.yml | 1 + config/locales/sr.yml | 1 + config/locales/sv.yml | 1 + config/locales/th.yml | 1 + config/locales/tr.yml | 1 + config/locales/uk.yml | 1 + config/locales/vi.yml | 1 + config/locales/zh-TW.yml | 1 + config/locales/zh.yml | 1 + test/functional/issues_controller_test.rb | 13 +++++++++++++ 38 files changed, 65 insertions(+), 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index a4f3de3d1..2fa465f4e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -299,9 +299,14 @@ class IssuesController < ApplicationController if request.post? new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id]) unsaved_issue_ids = [] + moved_issues = [] @issues.each do |issue| issue.init_journal(User.current) - unsaved_issue_ids << issue.id unless issue.move_to(@target_project, new_tracker, params[:copy_options]) + if r = issue.move_to(@target_project, new_tracker, params[:copy_options]) + moved_issues << r + else + unsaved_issue_ids << issue.id + end end if unsaved_issue_ids.empty? flash[:notice] = l(:notice_successful_update) unless @issues.empty? @@ -310,7 +315,15 @@ class IssuesController < ApplicationController :total => @issues.size, :ids => '#' + unsaved_issue_ids.join(', #')) end - redirect_to :controller => 'issues', :action => 'index', :project_id => @project + if params[:follow] + if @issues.size == 1 && moved_issues.size == 1 + redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first + else + redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project) + end + else + redirect_to :controller => 'issues', :action => 'index', :project_id => @project + end return end render :layout => false if request.xhr? diff --git a/app/views/issues/move.rhtml b/app/views/issues/move.rhtml index b0602f681..0d4717f53 100644 --- a/app/views/issues/move.rhtml +++ b/app/views/issues/move.rhtml @@ -25,5 +25,6 @@ <%= check_box_tag "copy_options[copy]", "1" %>

-<%= submit_tag l(:button_move) %> +<%= submit_tag l(:button_move) %> +<%= submit_tag l(:button_move_and_follow), :name => 'follow' %> <% end %> diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 56a14ad5b..69662dbab 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -832,3 +832,4 @@ bg: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/bs.yml b/config/locales/bs.yml index b23b2bbe2..716df4385 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -856,3 +856,4 @@ bs: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/ca.yml b/config/locales/ca.yml index a7903ade8..966df9a8f 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -835,3 +835,4 @@ ca: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/cs.yml b/config/locales/cs.yml index d65895ee3..c1533f62b 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -838,3 +838,4 @@ cs: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/da.yml b/config/locales/da.yml index bb3a14ced..4d433f44c 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -858,3 +858,4 @@ da: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/de.yml b/config/locales/de.yml index 520284e9f..425bcb575 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -858,3 +858,4 @@ de: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/el.yml b/config/locales/el.yml index a54952dfa..032fa1cac 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -838,3 +838,4 @@ el: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/en.yml b/config/locales/en.yml index 574ee9db0..5bd70a420 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -728,6 +728,7 @@ en: button_list: List button_view: View button_move: Move + button_move_and_follow: Move and follow button_back: Back button_cancel: Cancel button_activate: Activate diff --git a/config/locales/es.yml b/config/locales/es.yml index 8776faa3b..d03088d5c 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -879,3 +879,4 @@ es: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/fi.yml b/config/locales/fi.yml index ab677f81b..acdee65a0 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -868,3 +868,4 @@ fi: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 4d3972403..aaa858af5 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -745,6 +745,7 @@ fr: button_list: Lister button_view: Voir button_move: Déplacer + button_move_and_follow: Déplacer et suivre button_back: Retour button_cancel: Annuler button_activate: Activer diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 85b59e8d2..e6f260ae6 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -858,3 +858,4 @@ gl: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/he.yml b/config/locales/he.yml index f344e81cc..16d6800df 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -842,3 +842,4 @@ he: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/hu.yml b/config/locales/hu.yml index f8e0f130e..1c9f7f0cf 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -863,3 +863,4 @@ version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/it.yml b/config/locales/it.yml index 06fd50c99..74132a60a 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -845,3 +845,4 @@ it: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 99f8a4ab6..1cdb14f8e 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -867,3 +867,4 @@ ja: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/ko.yml b/config/locales/ko.yml index be3b8719e..a5b08607d 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -898,3 +898,4 @@ ko: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 021391620..67e65a570 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -868,3 +868,4 @@ lt: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/nl.yml b/config/locales/nl.yml index ae5107d55..191738fd0 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -820,3 +820,4 @@ nl: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/no.yml b/config/locales/no.yml index 39a9ac7f0..6fa2be0fe 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -833,3 +833,4 @@ version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/pl.yml b/config/locales/pl.yml index e5690967c..104a568a8 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -861,3 +861,4 @@ pl: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 1a90ded4d..10d43a66c 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -864,3 +864,4 @@ pt-BR: version_status_open: aberto error_can_not_reopen_issue_on_closed_version: Uma tarefa atribuída a uma versão fechada não pode ser reaberta label_user_anonymous: Anônimo + button_move_and_follow: Move and follow diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 3f4462794..c0133116c 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -850,3 +850,4 @@ pt: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/ro.yml b/config/locales/ro.yml index 9f0cc8763..9a97febd5 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -835,3 +835,4 @@ ro: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/ru.yml b/config/locales/ru.yml index a331afc0d..84f06e8fb 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -946,3 +946,4 @@ ru: version_status_open: открыт error_can_not_reopen_issue_on_closed_version: Задача, назначенная к закрытой версии, не сможет быть открыта снова label_user_anonymous: Аноним + button_move_and_follow: Move and follow diff --git a/config/locales/sk.yml b/config/locales/sk.yml index b715533fb..8f79cb367 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -837,3 +837,4 @@ sk: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/sl.yml b/config/locales/sl.yml index a1d142cd2..9ebcb6c40 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -834,3 +834,4 @@ sl: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/sr.yml b/config/locales/sr.yml index ff7bb9178..dbd0c316e 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -853,3 +853,4 @@ version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 3a2f82e8e..807db8db4 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -886,3 +886,4 @@ sv: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/th.yml b/config/locales/th.yml index 890b10e01..3ca9c46f9 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -835,3 +835,4 @@ th: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/tr.yml b/config/locales/tr.yml index a0f1977d9..01e284391 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -865,3 +865,4 @@ tr: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 4307c91a0..f7f2a66fc 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -834,3 +834,4 @@ uk: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/vi.yml b/config/locales/vi.yml index cdd04a4f5..b12cba75b 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -897,3 +897,4 @@ vi: version_status_open: open error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened label_user_anonymous: Anonymous + button_move_and_follow: Move and follow diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 88f4f5cd2..494e5c808 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -929,3 +929,4 @@ enumeration_doc_categories: 文件分類 enumeration_activities: 活動 (時間追蹤) enumeration_system_activity: 系統活動 + button_move_and_follow: Move and follow diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 29b7cbce3..f1c772fc1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -862,3 +862,4 @@ zh: enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) enumeration_system_activity: 系统活动 + button_move_and_follow: Move and follow diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 1cff860b4..75da3c0c3 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -968,6 +968,12 @@ class IssuesControllerTest < ActionController::TestCase assert_equal 2, Issue.find(1).project_id end + def test_move_one_issue_to_another_project_should_follow_when_needed + @request.session[:user_id] = 2 + post :move, :id => 1, :new_project_id => 2, :follow => '1' + assert_redirected_to '/issues/1' + end + def test_bulk_move_to_another_project @request.session[:user_id] = 2 post :move, :ids => [1, 2], :new_project_id => 2 @@ -997,6 +1003,13 @@ class IssuesControllerTest < ActionController::TestCase end assert_redirected_to 'projects/ecookbook/issues' end + + def test_copy_to_another_project_should_follow_when_needed + @request.session[:user_id] = 2 + post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1' + issue = Issue.first(:order => 'id DESC') + assert_redirected_to :controller => 'issues', :action => 'show', :id => issue + end def test_context_menu_one_issue @request.session[:user_id] = 2 -- 2.39.5