From a2ce6e236c397a527deb18cc2196371855d27c41 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Barth Date: Fri, 3 Sep 2010 19:54:24 +0000 Subject: [PATCH] Allow mass status update through context menu. #3411 NB: it cannot be done with issues from different projects, same as other fields. This will be addressed separately, see #5332. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4055 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/context_menus_controller.rb | 6 ++++++ app/views/context_menus/issues.html.erb | 21 +++++++++++-------- .../context_menus_controller_test.rb | 5 ++++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb index 442f85b37..e437a18dc 100644 --- a/app/controllers/context_menus_controller.rb +++ b/app/controllers/context_menus_controller.rb @@ -6,6 +6,12 @@ class ContextMenusController < ApplicationController if (@issues.size == 1) @issue = @issues.first @allowed_statuses = @issue.new_statuses_allowed_to(User.current) + else + @allowed_statuses = @issues.map do |i| + i.new_statuses_allowed_to(User.current) + end.inject do |memo,s| + memo & s + end end projects = @issues.collect(&:project).compact.uniq @project = projects.first if projects.size == 1 diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb index dc11b5fdb..efd8cde0e 100644 --- a/app/views/context_menus/issues.html.erb +++ b/app/views/context_menus/issues.html.erb @@ -4,20 +4,23 @@ <% if !@issue.nil? -%>
  • <%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'edit', :id => @issue}, :class => 'icon-edit', :disabled => !@can[:edit] %>
  • -
  • - <%= l(:field_status) %> - -
  • <% else %>
  • <%= context_menu_link l(:button_edit), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id)}, :class => 'icon-edit', :disabled => !@can[:edit] %>
  • <% end %> + <% unless @allowed_statuses.empty? %> +
  • + <%= l(:field_status) %> + +
  • + <% end %> + <% unless @trackers.nil? %>
  • <%= l(:field_tracker) %> diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index 764350879..0ebae695a 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -12,7 +12,7 @@ class ContextMenusControllerTest < ActionController::TestCase :attributes => { :href => '/issues/1/edit', :class => 'icon-edit' } assert_tag :tag => 'a', :content => 'Closed', - :attributes => { :href => '/issues/1?issue%5Bstatus_id%5D=5', + :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :class => '' } assert_tag :tag => 'a', :content => 'Immediate', :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&issue%5Bpriority_id%5D=8', @@ -59,6 +59,9 @@ class ContextMenusControllerTest < ActionController::TestCase assert_tag :tag => 'a', :content => 'Edit', :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', :class => 'icon-edit' } + assert_tag :tag => 'a', :content => 'Closed', + :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&issue%5Bstatus_id%5D=5', + :class => '' } assert_tag :tag => 'a', :content => 'Immediate', :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2&issue%5Bpriority_id%5D=8', :class => '' }