]> source.dussan.org Git - redmine.git/commitdiff
Merged r19464 from trunk to 4.1-stable (#32859).
authorGo MAEDA <maeda@farend.jp>
Sun, 26 Jan 2020 14:08:46 +0000 (14:08 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 26 Jan 2020 14:08:46 +0000 (14:08 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@19465 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/export/pdf/issues_pdf_helper.rb

index 81f1a817496c3ee8876f3d39c8a50f18568fffff..652622755c3b0a6bf1e498b5474b100797b86463 100644 (file)
@@ -279,8 +279,8 @@ module Redmine
             table_width = col_width.inject(0, :+)
           end
 
-          # use full width if the description or last_notes are displayed
-          if table_width > 0 && (query.has_column?(:description) || query.has_column?(:last_notes))
+          # use full width if the query has block columns (description, last_notes or full width custom fieds)
+          if table_width > 0 && query.block_columns.any?
             col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
             table_width = col_width.inject(0, :+)
           end
@@ -336,18 +336,22 @@ module Redmine
             issues_to_pdf_write_cells(pdf, col_values, col_width, max_height)
             pdf.set_y(base_y + max_height)
 
-            if query.has_column?(:description) && issue.description?
-              pdf.set_x(10)
-              pdf.set_auto_page_break(true, bottom_margin)
-              pdf.RDMwriteHTMLCell(0, 5, 10, '', issue.description.to_s, issue.attachments, "LRBT")
-              pdf.set_auto_page_break(false)
+            query.block_columns.each do |column|
+            if column.is_a?(QueryCustomFieldColumn)
+              cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
+              text = show_value(cv, false)
+            else
+              text = issue.send(column.name)
             end
+            next if text.blank?
 
-            if query.has_column?(:last_notes) && issue.last_notes.present?
-              pdf.set_x(10)
-              pdf.set_auto_page_break(true, bottom_margin)
-              pdf.RDMwriteHTMLCell(0, 5, 10, '', issue.last_notes.to_s, [], "LRBT")
-              pdf.set_auto_page_break(false)
+            pdf.set_x(10)
+            pdf.set_auto_page_break(true, bottom_margin)
+            pdf.SetFontStyle('B',9)
+            pdf.RDMCell(0, 5, column.caption, "LRT", 1)
+            pdf.SetFontStyle('',9)
+            pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
+            pdf.set_auto_page_break(false)
             end
           end