git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5354 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/1.2.0
@@ -68,7 +68,7 @@ module CustomFieldsHelper | |||
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) | |||
@@ -83,7 +83,7 @@ module CustomFieldsHelper | |||
[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 |
@@ -58,6 +58,8 @@ class CustomField < ActiveRecord::Base | |||
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 |
@@ -48,7 +48,7 @@ | |||
<% 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 }) %> |
@@ -36,7 +36,7 @@ | |||
</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 }) %> |
@@ -1,5 +1,5 @@ | |||
# 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 | |||
@@ -1123,6 +1123,38 @@ class IssuesControllerTest < ActionController::TestCase | |||
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 |
@@ -53,6 +53,13 @@ class CustomFieldUserFormatTest < ActiveSupport::TestCase | |||
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("") |