From cfd7d07b69e27d7f3cfce569fd073ef35e81d474 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 29 Jul 2009 19:04:27 +0000 Subject: [PATCH] Fixed: custom fields are not displayed in the same order on issue form and view. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2827 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/issues_helper.rb | 19 +++++++++++++++++++ app/views/issues/_form_custom_fields.rhtml | 2 +- app/views/issues/show.rhtml | 12 +----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 73ac4be9..beb36b52 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -33,6 +33,25 @@ module IssuesHelper "#{@cached_label_priority}: #{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 = "\n" + n = 0 + ordered_values.compact.each do |value| + s << "\n\n" if n > 0 && (n % 2) == 0 + s << "\t#{ h(value.custom_field.name) }:#{ simple_format_without_paragraph(h(show_value(value))) }\n" + n += 1 + end + s << "\n" + s + end + def sidebar_queries unless @sidebar_queries # User can see public queries and his own queries diff --git a/app/views/issues/_form_custom_fields.rhtml b/app/views/issues/_form_custom_fields.rhtml index 752fb4d3..7a66ed33 100644 --- a/app/views/issues/_form_custom_fields.rhtml +++ b/app/views/issues/_form_custom_fields.rhtml @@ -1,6 +1,6 @@
<% 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| %>

<%= custom_field_tag_with_label :issue, value %>

<% if i == split_on -%> diff --git a/app/views/issues/show.rhtml b/app/views/issues/show.rhtml index 776aa338..a7d56926 100644 --- a/app/views/issues/show.rhtml +++ b/app/views/issues/show.rhtml @@ -45,17 +45,7 @@ <%=l(:field_estimated_hours)%>:<%= l_hours(@issue.estimated_hours) %> <% end %> - -<% n = 0 -%> -<% @issue.custom_field_values.each do |value| -%> - <%=h value.custom_field.name %>:<%= simple_format_without_paragraph(h(show_value(value))) %> -<% n = n + 1 - if (n > 1) - n = 0 %> - - <%end -end %> - +<%= render_custom_fields_rows(@issue) %> <%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
-- 2.11.0