]> source.dussan.org Git - redmine.git/commitdiff
Fixed: custom fields are not displayed in the same order on issue form and view.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 29 Jul 2009 19:04:27 +0000 (19:04 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 29 Jul 2009 19:04:27 +0000 (19:04 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2827 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb
app/views/issues/_form_custom_fields.rhtml
app/views/issues/show.rhtml

index 73ac4be95c43c537f504c0f10d73dedfe1d2e711..beb36b5283baa3a8bae7cfef1ccb4d064325d541 100644 (file)
@@ -33,6 +33,25 @@ module IssuesHelper
       "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
   end
   
+  def render_custom_fields_rows(issue)
+    return if issue.custom_field_values.empty?
+    ordered_values = []
+    half = (issue.custom_field_values.size / 2.0).ceil
+    half.times do |i|
+      ordered_values << issue.custom_field_values[i]
+      ordered_values << issue.custom_field_values[i + half]
+    end
+    s = "<tr>\n"
+    n = 0
+    ordered_values.compact.each do |value|
+      s << "</tr>\n<tr>\n" if n > 0 && (n % 2) == 0
+      s << "\t<th>#{ h(value.custom_field.name) }:</th><td>#{ simple_format_without_paragraph(h(show_value(value))) }</td>\n"
+      n += 1
+    end
+    s << "</tr>\n"
+    s
+  end
+  
   def sidebar_queries
     unless @sidebar_queries
       # User can see public queries and his own queries
index 752fb4d372c20916cdf407a6a32aa67a65053bce..7a66ed3308f87371f8f4263b818e61e28daf01b8 100644 (file)
@@ -1,6 +1,6 @@
 <div class="splitcontentleft">
 <% i = 0 %>
-<% split_on = @issue.custom_field_values.size / 2 %>
+<% split_on = (@issue.custom_field_values.size / 2.0).ceil - 1 %>
 <% @issue.custom_field_values.each do |value| %>
        <p><%= custom_field_tag_with_label :issue, value %></p>
 <% if i == split_on -%>
index 776aa338763ae686d96eb3a4798895acfafa38a1..a7d569268410f00e02d90f7559dd12bbb7f69315 100644 (file)
     <th class="estimated-hours"><%=l(:field_estimated_hours)%>:</th><td><%= l_hours(@issue.estimated_hours) %></td>
     <% end %>
 </tr>
-<tr>
-<% n = 0 -%>
-<% @issue.custom_field_values.each do |value| -%>
-    <th><%=h value.custom_field.name %>:</th><td><%= simple_format_without_paragraph(h(show_value(value))) %></td>
-<% n = n + 1
-   if (n > 1) 
-        n = 0 %>
-        </tr><tr>
- <%end
-end %>
-</tr>
+<%= render_custom_fields_rows(@issue) %>
 <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
 </table>
 <hr />