diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index e04888e..d700d7c 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -307,8 +307,20 @@ module IssuesHelper items << "#{l("field_#{attribute}")}: #{issue.send attribute}" end end - issue.visible_custom_field_values(user).each do |value| - items << "#{value.custom_field.name}: #{show_value(value, false)}" + group_by_keys(issue.project_id, issue.tracker_id, issue.visible_custom_field_values(user)).each do |title, values| + if values.present? + if title.nil? + values.each do |value| + items << "#{value.custom_field.name}: #{show_value(value, false)}" + end + else + item = [ "#{title}" ] + values.each do |value| + item << "#{value.custom_field.name}: #{show_value(value, false)}" + end + items << item + end + end end items end @@ -316,9 +328,12 @@ module IssuesHelper def render_email_issue_attributes(issue, user, html=false) items = email_issue_attributes(issue, user) if html - content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe) + content_tag('ul', items.select{|s| s.is_a? String}.map{|s| content_tag('li', s)}.join("\n").html_safe) + "\n" + + items.select{|s| !s.is_a? String}.map{|item| content_tag('div', item.shift) + "\n" + + content_tag('ul', item.map{|s| content_tag('li', s)}.join("\n").html_safe)}.join("\n").html_safe else - items.map{|s| "* #{s}"}.join("\n") + items.select{|s| s.is_a? String}.map{|s| "* #{s}"}.join("\n") + "\n" + + items.select{|s| !s.is_a? String}.map{|item| "#{item.shift}\n" + item.map{|s| "* #{s}"}.join("\n")}.join("\n") end end diff --git a/lib/redmine/export/pdf/issues_pdf_helper.rb b/lib/redmine/export/pdf/issues_pdf_helper.rb index a9ee230..20efc54 100644 --- a/lib/redmine/export/pdf/issues_pdf_helper.rb +++ b/lib/redmine/export/pdf/issues_pdf_helper.rb @@ -68,51 +68,59 @@ module Redmine right << nil end - half = (issue.visible_custom_field_values.size / 2.0).ceil - issue.visible_custom_field_values.each_with_index do |custom_value, i| - (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)] - end - - if pdf.get_rtl - border_first_top = 'RT' - border_last_top = 'LT' - border_first = 'R' - border_last = 'L' - else - border_first_top = 'LT' - border_last_top = 'RT' - border_first = 'L' - border_last = 'R' - end - - rows = left.size > right.size ? left.size : right.size - rows.times do |i| - heights = [] - pdf.SetFontStyle('B',9) - item = left[i] - heights << pdf.get_string_height(35, item ? "#{item.first}:" : "") - item = right[i] - heights << pdf.get_string_height(35, item ? "#{item.first}:" : "") - pdf.SetFontStyle('',9) - item = left[i] - heights << pdf.get_string_height(60, item ? item.last.to_s : "") - item = right[i] - heights << pdf.get_string_height(60, item ? item.last.to_s : "") - height = heights.max + group_by_keys(issue.project_id, issue.tracker_id, issue.visible_custom_field_values).each do |title, values| + unless title.nil? + pdf.RDMCell(35+155, 5, title, "LRT", 1) + left = [] + right = [] + end - item = left[i] - pdf.SetFontStyle('B',9) - pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0) - pdf.SetFontStyle('',9) - pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0) - - item = right[i] - pdf.SetFontStyle('B',9) - pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0) - pdf.SetFontStyle('',9) - pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2) + half = (values.size / 2.0).ceil + values.each_with_index do |custom_value, i| + (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)] + end - pdf.set_x(base_x) + if pdf.get_rtl + border_first_top = 'RT' + border_last_top = 'LT' + border_first = 'R' + border_last = 'L' + else + border_first_top = 'LT' + border_last_top = 'RT' + border_first = 'L' + border_last = 'R' + end + + rows = left.size > right.size ? left.size : right.size + rows.times do |i| + heights = [] + pdf.SetFontStyle('B',9) + item = left[i] + heights << pdf.get_string_height(35, item ? "#{item.first}:" : "") + item = right[i] + heights << pdf.get_string_height(35, item ? "#{item.first}:" : "") + pdf.SetFontStyle('',9) + item = left[i] + heights << pdf.get_string_height(60, item ? item.last.to_s : "") + item = right[i] + heights << pdf.get_string_height(60, item ? item.last.to_s : "") + height = heights.max + + item = left[i] + pdf.SetFontStyle('B',9) + pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0) + pdf.SetFontStyle('',9) + pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0) + + item = right[i] + pdf.SetFontStyle('B',9) + pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0) + pdf.SetFontStyle('',9) + pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2) + + pdf.set_x(base_x) + end end pdf.SetFontStyle('B',9)