Adds an option for displaying the issue description on the issue list (#3447).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10948 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-12-06 17:48:19 +00:00
parent 43fb321195
commit 8201761e77
12 changed files with 124 additions and 24 deletions
+8 -1
View File
@@ -403,6 +403,9 @@ class TCPDF
Error("Incorrect orientation: #{orientation}")
end
@fw = @w_pt/@k
@fh = @h_pt/@k
@cur_orientation = @def_orientation
@w = @w_pt/@k
@h = @h_pt/@k
@@ -3615,9 +3618,9 @@ class TCPDF
restspace = GetPageHeight() - GetY() - GetBreakMargin();
writeHTML(html, true, fill); # write html text
SetX(x)
currentY = GetY();
@auto_page_break = false;
# check if a new page has been created
if (@page > pagenum)
@@ -3625,11 +3628,13 @@ class TCPDF
currentpage = @page;
@page = pagenum;
SetY(GetPageHeight() - restspace - GetBreakMargin());
SetX(x)
Cell(w, restspace - 1, "", b, 0, 'L', 0);
b = b2;
@page += 1;
while @page < currentpage
SetY(@t_margin); # put cursor at the beginning of text
SetX(x)
Cell(w, @page_break_trigger - @t_margin, "", b, 0, 'L', 0);
@page += 1;
end
@@ -3638,10 +3643,12 @@ class TCPDF
end
# design a cell around the text on last page
SetY(@t_margin); # put cursor at the beginning of text
SetX(x)
Cell(w, currentY - @t_margin, "", b, 0, 'L', 0);
else
SetY(y); # put cursor at the beginning of text
# design a cell around the text
SetX(x)
Cell(w, [h, (currentY - y)].max, "", border, 0, 'L', 0);
end
@auto_page_break = true;
+22 -9
View File
@@ -34,12 +34,12 @@ module Redmine
include Redmine::I18n
attr_accessor :footer_date
def initialize(lang)
def initialize(lang, orientation='P')
@@k_path_cache = Rails.root.join('tmp', 'pdf')
FileUtils.mkdir_p @@k_path_cache unless File::exist?(@@k_path_cache)
set_language_if_valid lang
pdf_encoding = l(:general_pdf_encoding).upcase
super('P', 'mm', 'A4', (pdf_encoding == 'UTF-8'), pdf_encoding)
super(orientation, 'mm', 'A4', (pdf_encoding == 'UTF-8'), pdf_encoding)
case current_language.to_s.downcase
when 'vi'
@font_for_content = 'DejaVuSans'
@@ -236,7 +236,7 @@ module Redmine
# fetch row values
def fetch_row_values(issue, query, level)
query.columns.collect do |column|
query.inline_columns.collect do |column|
s = if column.is_a?(QueryCustomFieldColumn)
cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
show_value(cv)
@@ -263,10 +263,10 @@ module Redmine
# by captions
pdf.SetFontStyle('B',8)
col_padding = pdf.GetStringWidth('OO')
col_width_min = query.columns.map {|v| pdf.GetStringWidth(v.caption) + col_padding}
col_width_min = query.inline_columns.map {|v| pdf.GetStringWidth(v.caption) + col_padding}
col_width_max = Array.new(col_width_min)
col_width_avg = Array.new(col_width_min)
word_width_max = query.columns.map {|c|
word_width_max = query.inline_columns.map {|c|
n = 10
c.caption.split.each {|w|
x = pdf.GetStringWidth(w) + col_padding
@@ -370,13 +370,13 @@ module Redmine
# render it background to find the max height used
base_x = pdf.GetX
base_y = pdf.GetY
max_height = issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
max_height = issues_to_pdf_write_cells(pdf, query.inline_columns, col_width, row_height, true)
pdf.Rect(base_x, base_y, table_width + col_id_width, max_height, 'FD');
pdf.SetXY(base_x, base_y);
# write the cells on page
pdf.RDMCell(col_id_width, row_height, "#", "T", 0, 'C', 1)
issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
issues_to_pdf_write_cells(pdf, query.inline_columns, col_width, row_height, true)
issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
pdf.SetY(base_y + max_height);
@@ -387,7 +387,7 @@ module Redmine
# Returns a PDF string of a list of issues
def issues_to_pdf(issues, project, query)
pdf = ITCPDF.new(current_language)
pdf = ITCPDF.new(current_language, "L")
title = query.new_record? ? l(:label_issue_plural) : query.name
title = "#{project} - #{title}" if project
pdf.SetTitle(title)
@@ -407,11 +407,17 @@ module Redmine
# column widths
table_width = page_width - right_margin - 10 # fixed left margin
col_width = []
unless query.columns.empty?
unless query.inline_columns.empty?
col_width = calc_col_width(issues, query, table_width - col_id_width, pdf)
table_width = col_width.inject(0) {|s,v| s += v}
end
# use full width if the description is displayed
if table_width > 0 && query.has_column?(:description)
col_width = col_width.map {|w| w = w * (page_width - right_margin - 10 - col_id_width) / table_width}
table_width = col_width.inject(0) {|s,v| s += v}
end
# title
pdf.SetFontStyle('B',11)
pdf.RDMCell(190,10, title)
@@ -454,6 +460,13 @@ module Redmine
issues_to_pdf_write_cells(pdf, col_values, col_width, row_height)
issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
pdf.SetY(base_y + max_height);
if query.has_column?(:description) && issue.description?
pdf.SetX(10)
pdf.SetAutoPageBreak(true, 20)
pdf.RDMwriteHTMLCell(0, 5, 10, 0, issue.description.to_s, issue.attachments, "LRBT")
pdf.SetAutoPageBreak(false)
end
end
if issues.size == Setting.issues_export_limit.to_i