]> source.dussan.org Git - redmine.git/commitdiff
Display of multi custom fields.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 Jan 2012 22:01:40 +0000 (22:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 Jan 2012 22:01:40 +0000 (22:01 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8726 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/custom_fields_helper.rb
app/helpers/issues_helper.rb
app/helpers/timelog_helper.rb
app/views/versions/_overview.html.erb
lib/redmine/export/pdf.rb
test/functional/issues_controller_test.rb
test/functional/timelog_controller_test.rb

index 639af95fbb1de3cce66965b590e9e86c0944da40..7d1368fa8115da4cbb3d4bbd0f9e43605ac588f1 100644 (file)
@@ -117,7 +117,7 @@ module CustomFieldsHelper
   # Return a string used to display a custom value
   def format_value(value, field_format)
     if value.is_a?(Array)
-      value.collect {|v| format_value(v, field_format)}.join(', ')
+      value.collect {|v| format_value(v, field_format)}.compact.sort.join(', ')
     else
       Redmine::CustomFieldFormat.format_value(value, field_format)
     end
index 0b33d48fbd7975069b9b10488652690122c03ec4..b061840fbd70a461984496f03121a3167a44b298 100644 (file)
@@ -320,7 +320,7 @@ module IssuesHelper
       issues.each do |issue|
         col_values = columns.collect do |column|
           s = if column.is_a?(QueryCustomFieldColumn)
-            cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
+            cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
             show_value(cv)
           else
             value = issue.send(column.name)
index e3c7615b2187abb86af3067b79ab9604e5b79a1a..e27425acba1d81a7deba3eb7e6fea320ed171c68 100644 (file)
@@ -118,7 +118,7 @@ module TimelogHelper
                   entry.hours.to_s.gsub('.', decimal_separator),
                   entry.comments
                   ]
-        fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
+        fields += custom_fields.collect {|f| show_value(entry.custom_field_values.detect {|v| v.custom_field_id == f.id}) }
 
         csv << fields.collect {|c| Redmine::CodesetUtil.from_utf8(
                                      c.to_s,
index aea77af1206fd4ee101e30bf6197779d41821594..a572411581094b31c21b2463ed033a9004c46663 100644 (file)
@@ -5,7 +5,7 @@
 <% end %>
 
 <p><%=h version.description %></p>
-<% if version.custom_values.any? %>
+<% if version.custom_field_values.any? %>
 <ul>
   <% version.custom_field_values.each do |custom_value| %>
     <% if custom_value.value.present? %>
index 8ae7575dee2e87d766ff70ab7a0f8e7575ecfe62..b9efd1a33ac27398b7d1324ba64c7d8b69aa9df6 100644 (file)
@@ -214,7 +214,7 @@ module Redmine
           # fetch all the row values
           col_values = query.columns.collect do |column|
             s = if column.is_a?(QueryCustomFieldColumn)
-              cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
+              cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
               show_value(cv)
             else
               value = issue.send(column.name)
index aa96156b0d22592cd67e33e04afd678b8f4dfea3..a41340ae669f85387cb1420de3f84f51277e52df 100644 (file)
@@ -337,6 +337,18 @@ class IssuesControllerTest < ActionController::TestCase
     assert_equal assigns(:query).available_columns.size + 1, lines[0].split(',').size
   end
 
+  def test_index_csv_with_multi_column_field
+    CustomField.find(1).update_attribute :multiple, true
+    issue = Issue.find(1)
+    issue.custom_field_values = {1 => ['MySQL', 'Oracle']}
+    issue.save!
+
+    get :index, :format => 'csv', :columns => 'all'
+    assert_response :success
+    lines = @response.body.chomp.split("\n")
+    assert lines.detect {|line| line.include?('"MySQL, Oracle"')}
+  end
+
   def test_index_csv_big_5
     with_settings :default_language => "zh-TW" do
       str_utf8  = "\xe4\xb8\x80\xe6\x9c\x88"
@@ -1086,7 +1098,7 @@ class IssuesControllerTest < ActionController::TestCase
     assert_response :success
 
     # TODO: should display links
-    assert_tag :td, :content => 'John Smith, Dave Lopper'
+    assert_tag :td, :content => 'Dave Lopper, John Smith'
   end
 
   def test_show_atom
index b5af1b5b8d87bbc51863243f8dd8eea54cc9787e..d23426c52b845e2b450aefba2f7498cc39d75aa1 100644 (file)
@@ -563,6 +563,18 @@ class TimelogControllerTest < ActionController::TestCase
     assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
   end
 
+  def test_index_csv_export_with_multi_custom_field
+    field = TimeEntryCustomField.create!(:name => 'Test', :field_format => 'list',
+      :multiple => true, :possible_values => ['value1', 'value2'])
+    entry = TimeEntry.find(1)
+    entry.custom_field_values = {field.id => ['value1', 'value2']}
+    entry.save!
+
+    get :index, :project_id => 1, :format => 'csv'
+    assert_response :success
+    assert_include '"value1, value2"', @response.body
+  end
+
   def test_csv_big_5
     user = User.find_by_id(3)
     user.language = "zh-TW"