##// END OF EJS Templates
Display of multi custom fields....
Jean-Philippe Lang -
r8606:79b12c73d9ac
parent child
Show More
@@ -117,7 +117,7 module CustomFieldsHelper
117 117 # Return a string used to display a custom value
118 118 def format_value(value, field_format)
119 119 if value.is_a?(Array)
120 value.collect {|v| format_value(v, field_format)}.join(', ')
120 value.collect {|v| format_value(v, field_format)}.compact.sort.join(', ')
121 121 else
122 122 Redmine::CustomFieldFormat.format_value(value, field_format)
123 123 end
@@ -320,7 +320,7 module IssuesHelper
320 320 issues.each do |issue|
321 321 col_values = columns.collect do |column|
322 322 s = if column.is_a?(QueryCustomFieldColumn)
323 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
323 cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
324 324 show_value(cv)
325 325 else
326 326 value = issue.send(column.name)
@@ -118,7 +118,7 module TimelogHelper
118 118 entry.hours.to_s.gsub('.', decimal_separator),
119 119 entry.comments
120 120 ]
121 fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
121 fields += custom_fields.collect {|f| show_value(entry.custom_field_values.detect {|v| v.custom_field_id == f.id}) }
122 122
123 123 csv << fields.collect {|c| Redmine::CodesetUtil.from_utf8(
124 124 c.to_s,
@@ -5,7 +5,7
5 5 <% end %>
6 6
7 7 <p><%=h version.description %></p>
8 <% if version.custom_values.any? %>
8 <% if version.custom_field_values.any? %>
9 9 <ul>
10 10 <% version.custom_field_values.each do |custom_value| %>
11 11 <% if custom_value.value.present? %>
@@ -214,7 +214,7 module Redmine
214 214 # fetch all the row values
215 215 col_values = query.columns.collect do |column|
216 216 s = if column.is_a?(QueryCustomFieldColumn)
217 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
217 cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
218 218 show_value(cv)
219 219 else
220 220 value = issue.send(column.name)
@@ -337,6 +337,18 class IssuesControllerTest < ActionController::TestCase
337 337 assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
338 338 end
339 339
340 def test_index_csv_with_multi_column_field
341 CustomField.find(1).update_attribute :multiple, true
342 issue = Issue.find(1)
343 issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
344 issue.save!
345
346 get :index, :format => 'csv', :columns => 'all'
347 assert_response :success
348 lines = @response.body.chomp.split("\n")
349 assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
350 end
351
340 352 def test_index_csv_big_5
341 353 with_settings :default_language => "zh-TW" do
342 354 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
@@ -1086,7 +1098,7 class IssuesControllerTest < ActionController::TestCase
1086 1098 assert_response :success
1087 1099
1088 1100 # TODO: should display links
1089 assert_tag :td, :content => 'John Smith, Dave Lopper'
1101 assert_tag :td, :content => 'Dave Lopper, John Smith'
1090 1102 end
1091 1103
1092 1104 def test_show_atom
@@ -563,6 +563,18 class TimelogControllerTest < ActionController::TestCase
563 563 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
564 564 end
565 565
566 def test_index_csv_export_with_multi_custom_field
567 field = TimeEntryCustomField.create!(:name => 'Test', :field_format => 'list',
568 :multiple => true, :possible_values => ['value1', 'value2'])
569 entry = TimeEntry.find(1)
570 entry.custom_field_values = {field.id => ['value1', 'value2']}
571 entry.save!
572
573 get :index, :project_id => 1, :format => 'csv'
574 assert_response :success
575 assert_include '"value1, value2"', @response.body
576 end
577
566 578 def test_csv_big_5
567 579 user = User.find_by_id(3)
568 580 user.language = "zh-TW"
General Comments 0
You need to be logged in to leave comments. Login now