summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-09 18:22:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-09 18:22:11 +0000
commit5e0c1cc5ce9e16f3b4d8d2066bc1c4023afdee78 (patch)
tree4814399d770b5f3fe3197841c3bcf9689ab0e149 /app
parentde7c49c6ca79f87b697744688d57a07e7af17b4c (diff)
downloadredmine-5e0c1cc5ce9e16f3b4d8d2066bc1c4023afdee78.tar.gz
redmine-5e0c1cc5ce9e16f3b4d8d2066bc1c4023afdee78.zip
Bulk-edit custom fields through context menu (#6296).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8824 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/context_menus_controller.rb13
-rw-r--r--app/helpers/context_menus_helper.rb7
-rw-r--r--app/models/custom_field.rb6
-rw-r--r--app/views/context_menus/issues.html.erb14
4 files changed, 39 insertions, 1 deletions
diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb
index defadb230..007cc38e6 100644
--- a/app/controllers/context_menus_controller.rb
+++ b/app/controllers/context_menus_controller.rb
@@ -42,6 +42,19 @@ class ContextMenusController < ApplicationController
@statuses = IssueStatus.find(:all, :order => 'position')
@back = back_url
+ @options_by_custom_field = {}
+ if @can[:edit]
+ custom_fields = @issues.map(&:available_custom_fields).inject {|memo, f| memo & f}.select do |f|
+ %w(bool list user version).include?(f.field_format) && !f.multiple?
+ end
+ custom_fields.each do |field|
+ values = field.possible_values_options(@projects)
+ if values.any?
+ @options_by_custom_field[field] = values
+ end
+ end
+ end
+
render :layout => false
end
diff --git a/app/helpers/context_menus_helper.rb b/app/helpers/context_menus_helper.rb
index 93ec40af9..f2575c913 100644
--- a/app/helpers/context_menus_helper.rb
+++ b/app/helpers/context_menus_helper.rb
@@ -33,4 +33,11 @@ module ContextMenusHelper
end
link_to h(name), url, options
end
+
+ def bulk_update_custom_field_context_menu_link(field, text, value)
+ context_menu_link h(text),
+ {:controller => 'issues', :action => 'bulk_update', :ids => @issues.collect(&:id), :issue => {'custom_field_values' => {field.id => value}}, :back_url => @back},
+ :method => :post,
+ :selected => (@issue && @issue.custom_field_value(field) == value)
+ end
end
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index b8005fea1..8011320b3 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -77,8 +77,10 @@ class CustomField < ActiveRecord::Base
else
[]
end
+ when 'bool'
+ [[l(:general_text_Yes), '1'], [l(:general_text_No), '0']]
else
- read_attribute :possible_values
+ read_attribute(:possible_values) || []
end
end
@@ -86,6 +88,8 @@ class CustomField < ActiveRecord::Base
case field_format
when 'user', 'version'
possible_values_options(obj).collect(&:last)
+ when 'bool'
+ ['1', '0']
else
read_attribute :possible_values
end
diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb
index 135edba99..375758484 100644
--- a/app/views/context_menus/issues.html.erb
+++ b/app/views/context_menus/issues.html.erb
@@ -100,6 +100,20 @@
</li>
<% end %>
+ <% @options_by_custom_field.each do |field, options| %>
+ <li class="folder">
+ <a href="#" class="submenu"><%= h(field.name) %></a>
+ <ul>
+ <% options.each do |text, value| %>
+ <li><%= bulk_update_custom_field_context_menu_link(field, text, value || text) %></li>
+ <% end %>
+ <% unless field.is_required? %>
+ <li><%= bulk_update_custom_field_context_menu_link(field, l(:label_none), '') %></li>
+ <% end %>
+ </ul>
+ </li>
+ <% end %>
+
<% if !@issue.nil? %>
<% if @can[:log_time] -%>
<li><%= context_menu_link l(:button_log_time), {:controller => 'timelog', :action => 'new', :issue_id => @issue},