Project

General

Profile

Patch #30919 » GCFep-3.2.patch

Frederico Camara, 2019-02-27 15:03

View differences:

app/helpers/issues_helper.rb
307 307
        items << "#{l("field_#{attribute}")}: #{issue.send attribute}"
308 308
      end
309 309
    end
310
    issue.visible_custom_field_values(user).each do |value|
311
      items << "#{value.custom_field.name}: #{show_value(value, false)}"
310
    group_by_keys(issue.project_id, issue.tracker_id, issue.visible_custom_field_values(user)).each do |title, values|
311
      if values.present?
312
        if title.nil?
313
          values.each do |value|
314
            items << "#{value.custom_field.name}: #{show_value(value, false)}"
315
          end
316
        else   
317
          item = [ "#{title}" ]
318
          values.each do |value|
319
            item << "#{value.custom_field.name}: #{show_value(value, false)}"
320
          end
321
          items << item
322
        end
323
      end
312 324
    end
313 325
    items
314 326
  end
......
316 328
  def render_email_issue_attributes(issue, user, html=false)
317 329
    items = email_issue_attributes(issue, user)
318 330
    if html
319
      content_tag('ul', items.map{|s| content_tag('li', s)}.join("\n").html_safe)
331
      content_tag('ul', items.select{|s| s.is_a? String}.map{|s| content_tag('li', s)}.join("\n").html_safe) + "\n" +
332
      items.select{|s| !s.is_a? String}.map{|item| content_tag('div', item.shift) + "\n" +
333
        content_tag('ul', item.map{|s| content_tag('li', s)}.join("\n").html_safe)}.join("\n").html_safe
320 334
    else
321
      items.map{|s| "* #{s}"}.join("\n")
335
      items.select{|s| s.is_a? String}.map{|s| "* #{s}"}.join("\n") + "\n" +
336
      items.select{|s| !s.is_a? String}.map{|item| "#{item.shift}\n" + item.map{|s| "* #{s}"}.join("\n")}.join("\n")
322 337
    end
323 338
  end
324 339

  
lib/redmine/export/pdf/issues_pdf_helper.rb
68 68
            right << nil
69 69
          end
70 70
  
71
          half = (issue.visible_custom_field_values.size / 2.0).ceil
72
          issue.visible_custom_field_values.each_with_index do |custom_value, i|
73
            (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
74
          end
75
  
76
          if pdf.get_rtl
77
            border_first_top = 'RT'
78
            border_last_top  = 'LT'
79
            border_first = 'R'
80
            border_last  = 'L'
81
          else
82
            border_first_top = 'LT'
83
            border_last_top  = 'RT'
84
            border_first = 'L'
85
            border_last  = 'R'
86
          end
87
  
88
          rows = left.size > right.size ? left.size : right.size
89
          rows.times do |i|
90
            heights = []
91
            pdf.SetFontStyle('B',9)
92
            item = left[i]
93
            heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
94
            item = right[i]
95
            heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
96
            pdf.SetFontStyle('',9)
97
            item = left[i]
98
            heights << pdf.get_string_height(60, item ? item.last.to_s  : "")
99
            item = right[i]
100
            heights << pdf.get_string_height(60, item ? item.last.to_s  : "")
101
            height = heights.max
71
          group_by_keys(issue.project_id, issue.tracker_id, issue.visible_custom_field_values).each do |title, values|
72
            unless title.nil?
73
              pdf.RDMCell(35+155, 5, title, "LRT", 1)
74
              left = []
75
              right = []
76
            end  
102 77
  
103
            item = left[i]
104
            pdf.SetFontStyle('B',9)
105
            pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
106
            pdf.SetFontStyle('',9)
107
            pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0)
108
  
109
            item = right[i]
110
            pdf.SetFontStyle('B',9)
111
            pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "",  (i == 0 ? border_first_top : border_first), '', 0, 0)
112
            pdf.SetFontStyle('',9)
113
            pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2)
78
            half = (values.size / 2.0).ceil
79
            values.each_with_index do |custom_value, i|
80
              (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
81
            end
114 82
  
115
            pdf.set_x(base_x)
83
            if pdf.get_rtl
84
              border_first_top = 'RT'
85
              border_last_top  = 'LT'
86
              border_first = 'R'
87
              border_last  = 'L'
88
            else
89
              border_first_top = 'LT'
90
              border_last_top  = 'RT'
91
              border_first = 'L'
92
              border_last  = 'R'
93
            end
94
    
95
            rows = left.size > right.size ? left.size : right.size
96
            rows.times do |i|
97
              heights = []
98
              pdf.SetFontStyle('B',9)
99
              item = left[i]
100
              heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
101
              item = right[i]
102
              heights << pdf.get_string_height(35, item ? "#{item.first}:" : "")
103
              pdf.SetFontStyle('',9)
104
              item = left[i]
105
              heights << pdf.get_string_height(60, item ? item.last.to_s  : "")
106
              item = right[i]
107
              heights << pdf.get_string_height(60, item ? item.last.to_s  : "")
108
              height = heights.max
109
    
110
              item = left[i]
111
              pdf.SetFontStyle('B',9)
112
              pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
113
              pdf.SetFontStyle('',9)
114
              pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0)
115
    
116
              item = right[i]
117
              pdf.SetFontStyle('B',9)
118
              pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "",  (i == 0 ? border_first_top : border_first), '', 0, 0)
119
              pdf.SetFontStyle('',9)
120
              pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2)
121
    
122
              pdf.set_x(base_x)
123
            end
116 124
          end
117 125
  
118 126
          pdf.SetFontStyle('B',9)
(10-10/24)