custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value)
end
- def custom_field_tag_for_bulk_edit(name, custom_field)
+ def custom_field_tag_for_bulk_edit(name, custom_field, projects)
field_name = "#{name}[custom_field_values][#{custom_field.id}]"
field_id = "#{name}_custom_field_values_#{custom_field.id}"
field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format)
[l(:general_text_yes), '1'],
[l(:general_text_no), '0']]), :id => field_id)
when "list"
- select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options), :id => field_id)
+ select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options(projects)), :id => field_id)
else
text_field_tag(field_name, '', :id => field_id)
end
when 'version'
obj.project.versions.sort.collect {|u| [u.to_s, u.id.to_s]}
end
+ elsif obj.is_a?(Array)
+ obj.collect {|o| possible_values_options(o)}.inject {|memo, v| memo & v}
else
[]
end
<% end %>
<% @custom_fields.each do |custom_field| %>
- <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field) %></p>
+ <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field, @projects) %></p>
<% end %>
<%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
</p>
<% @custom_fields.each do |custom_field| %>
- <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('time_entry', custom_field) %></p>
+ <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('time_entry', custom_field, @projects) %></p>
<% end %>
<%= call_hook(:view_time_entries_bulk_edit_details_bottom, { :time_entries => @time_entries }) %>
# Redmine - project management software
-# Copyright (C) 2006-2008 Jean-Philippe Lang
+# Copyright (C) 2006-2011 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
assert !field.project_ids.include?(Issue.find(6).project_id)
assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'}
end
+
+ def test_get_bulk_edit_with_user_custom_field
+ field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true)
+
+ @request.session[:user_id] = 2
+ get :bulk_edit, :ids => [1, 2]
+ assert_response :success
+ assert_template 'bulk_edit'
+
+ assert_tag :select,
+ :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
+ :children => {
+ :only => {:tag => 'option'},
+ :count => Project.find(1).users.count + 1
+ }
+ end
+
+ def test_get_bulk_edit_with_version_custom_field
+ field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true)
+
+ @request.session[:user_id] = 2
+ get :bulk_edit, :ids => [1, 2]
+ assert_response :success
+ assert_template 'bulk_edit'
+
+ assert_tag :select,
+ :attributes => {:name => "issue[custom_field_values][#{field.id}]"},
+ :children => {
+ :only => {:tag => 'option'},
+ :count => Project.find(1).versions.count + 1
+ }
+ end
def test_bulk_update
@request.session[:user_id] = 2
assert_equal project.users.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
end
+ def test_possible_values_options_with_array
+ projects = Project.find([1, 2])
+ possible_values_options = @field.possible_values_options(projects)
+ assert possible_values_options.any?
+ assert_equal (projects.first.users & projects.last.users).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options
+ end
+
def test_cast_blank_value
assert_equal nil, @field.cast_value(nil)
assert_equal nil, @field.cast_value("")