@@ -68,7 +68,7 module CustomFieldsHelper | |||||
68 | custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value) |
|
68 | custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value) | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def custom_field_tag_for_bulk_edit(name, custom_field) |
|
71 | def custom_field_tag_for_bulk_edit(name, custom_field, projects) | |
72 | field_name = "#{name}[custom_field_values][#{custom_field.id}]" |
|
72 | field_name = "#{name}[custom_field_values][#{custom_field.id}]" | |
73 | field_id = "#{name}_custom_field_values_#{custom_field.id}" |
|
73 | field_id = "#{name}_custom_field_values_#{custom_field.id}" | |
74 | field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) |
|
74 | field_format = Redmine::CustomFieldFormat.find_by_name(custom_field.field_format) | |
@@ -83,7 +83,7 module CustomFieldsHelper | |||||
83 | [l(:general_text_yes), '1'], |
|
83 | [l(:general_text_yes), '1'], | |
84 | [l(:general_text_no), '0']]), :id => field_id) |
|
84 | [l(:general_text_no), '0']]), :id => field_id) | |
85 | when "list" |
|
85 | when "list" | |
86 | select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options), :id => field_id) |
|
86 | select_tag(field_name, options_for_select([[l(:label_no_change_option), '']] + custom_field.possible_values_options(projects)), :id => field_id) | |
87 | else |
|
87 | else | |
88 | text_field_tag(field_name, '', :id => field_id) |
|
88 | text_field_tag(field_name, '', :id => field_id) | |
89 | end |
|
89 | end |
@@ -58,6 +58,8 class CustomField < ActiveRecord::Base | |||||
58 | when 'version' |
|
58 | when 'version' | |
59 | obj.project.versions.sort.collect {|u| [u.to_s, u.id.to_s]} |
|
59 | obj.project.versions.sort.collect {|u| [u.to_s, u.id.to_s]} | |
60 | end |
|
60 | end | |
|
61 | elsif obj.is_a?(Array) | |||
|
62 | obj.collect {|o| possible_values_options(o)}.inject {|memo, v| memo & v} | |||
61 | else |
|
63 | else | |
62 | [] |
|
64 | [] | |
63 | end |
|
65 | end |
@@ -48,7 +48,7 | |||||
48 | <% end %> |
|
48 | <% end %> | |
49 |
|
49 | |||
50 | <% @custom_fields.each do |custom_field| %> |
|
50 | <% @custom_fields.each do |custom_field| %> | |
51 | <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field) %></p> |
|
51 | <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('issue', custom_field, @projects) %></p> | |
52 | <% end %> |
|
52 | <% end %> | |
53 |
|
53 | |||
54 | <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %> |
|
54 | <%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %> |
@@ -36,7 +36,7 | |||||
36 | </p> |
|
36 | </p> | |
37 |
|
37 | |||
38 | <% @custom_fields.each do |custom_field| %> |
|
38 | <% @custom_fields.each do |custom_field| %> | |
39 | <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('time_entry', custom_field) %></p> |
|
39 | <p><label><%= h(custom_field.name) %></label> <%= custom_field_tag_for_bulk_edit('time_entry', custom_field, @projects) %></p> | |
40 | <% end %> |
|
40 | <% end %> | |
41 |
|
41 | |||
42 | <%= call_hook(:view_time_entries_bulk_edit_details_bottom, { :time_entries => @time_entries }) %> |
|
42 | <%= call_hook(:view_time_entries_bulk_edit_details_bottom, { :time_entries => @time_entries }) %> |
@@ -1,5 +1,5 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
@@ -1123,6 +1123,38 class IssuesControllerTest < ActionController::TestCase | |||||
1123 | assert !field.project_ids.include?(Issue.find(6).project_id) |
|
1123 | assert !field.project_ids.include?(Issue.find(6).project_id) | |
1124 | assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} |
|
1124 | assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} | |
1125 | end |
|
1125 | end | |
|
1126 | ||||
|
1127 | def test_get_bulk_edit_with_user_custom_field | |||
|
1128 | field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true) | |||
|
1129 | ||||
|
1130 | @request.session[:user_id] = 2 | |||
|
1131 | get :bulk_edit, :ids => [1, 2] | |||
|
1132 | assert_response :success | |||
|
1133 | assert_template 'bulk_edit' | |||
|
1134 | ||||
|
1135 | assert_tag :select, | |||
|
1136 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, | |||
|
1137 | :children => { | |||
|
1138 | :only => {:tag => 'option'}, | |||
|
1139 | :count => Project.find(1).users.count + 1 | |||
|
1140 | } | |||
|
1141 | end | |||
|
1142 | ||||
|
1143 | def test_get_bulk_edit_with_version_custom_field | |||
|
1144 | field = IssueCustomField.create!(:name => 'Affected version', :field_format => 'version', :is_for_all => true) | |||
|
1145 | ||||
|
1146 | @request.session[:user_id] = 2 | |||
|
1147 | get :bulk_edit, :ids => [1, 2] | |||
|
1148 | assert_response :success | |||
|
1149 | assert_template 'bulk_edit' | |||
|
1150 | ||||
|
1151 | assert_tag :select, | |||
|
1152 | :attributes => {:name => "issue[custom_field_values][#{field.id}]"}, | |||
|
1153 | :children => { | |||
|
1154 | :only => {:tag => 'option'}, | |||
|
1155 | :count => Project.find(1).versions.count + 1 | |||
|
1156 | } | |||
|
1157 | end | |||
1126 |
|
1158 | |||
1127 | def test_bulk_update |
|
1159 | def test_bulk_update | |
1128 | @request.session[:user_id] = 2 |
|
1160 | @request.session[:user_id] = 2 |
@@ -53,6 +53,13 class CustomFieldUserFormatTest < ActiveSupport::TestCase | |||||
53 | assert_equal project.users.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options |
|
53 | assert_equal project.users.sort.map {|u| [u.name, u.id.to_s]}, possible_values_options | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
|
56 | def test_possible_values_options_with_array | |||
|
57 | projects = Project.find([1, 2]) | |||
|
58 | possible_values_options = @field.possible_values_options(projects) | |||
|
59 | assert possible_values_options.any? | |||
|
60 | assert_equal (projects.first.users & projects.last.users).sort.map {|u| [u.name, u.id.to_s]}, possible_values_options | |||
|
61 | end | |||
|
62 | ||||
56 | def test_cast_blank_value |
|
63 | def test_cast_blank_value | |
57 | assert_equal nil, @field.cast_value(nil) |
|
64 | assert_equal nil, @field.cast_value(nil) | |
58 | assert_equal nil, @field.cast_value("") |
|
65 | assert_equal nil, @field.cast_value("") |
General Comments 0
You need to be logged in to leave comments.
Login now