|
|
@ -16,7 +16,7 @@ module OpenProject::PdfExport::TaskboardCard |
|
|
|
@config = config |
|
|
|
@config = config |
|
|
|
@work_packages = work_packages |
|
|
|
@work_packages = work_packages |
|
|
|
|
|
|
|
|
|
|
|
page_layout = :landscape |
|
|
|
page_layout = :landscape if config.landscape? else :portrait |
|
|
|
page_size = config.page_size or defaults[:page_size] |
|
|
|
page_size = config.page_size or defaults[:page_size] |
|
|
|
geom = Prawn::Document::PageGeometry::SIZES[page_size] |
|
|
|
geom = Prawn::Document::PageGeometry::SIZES[page_size] |
|
|
|
@paper_width = geom[0] |
|
|
|
@paper_width = geom[0] |
|
|
@ -37,22 +37,28 @@ module OpenProject::PdfExport::TaskboardCard |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def render_pages |
|
|
|
def render_pages |
|
|
|
@work_packages.each do |wp| |
|
|
|
padding = 10 |
|
|
|
@config.per_page.times do |
|
|
|
card_width = 400 |
|
|
|
# Position and size depend on how the cards are to be arranged on the page which is not known yet |
|
|
|
card_height = ((pdf.bounds.height - (padding * @config.per_page )) / @config.per_page) - (padding / @config.per_page) |
|
|
|
padding = 20 |
|
|
|
card_y_offset = pdf.bounds.height - padding |
|
|
|
|
|
|
|
|
|
|
|
orientation = { |
|
|
|
@work_packages.each_with_index do |wp, i| |
|
|
|
y_offset: pdf.bounds.height - padding, |
|
|
|
orientation = { |
|
|
|
x_offset: padding, |
|
|
|
y_offset: card_y_offset, |
|
|
|
width: 400, |
|
|
|
x_offset: padding, |
|
|
|
height: 400 |
|
|
|
width: card_width, |
|
|
|
} |
|
|
|
height: card_height |
|
|
|
|
|
|
|
} |
|
|
|
card_element = CardElement.new(pdf, orientation, config.rows_hash, wp) |
|
|
|
|
|
|
|
card_element.draw |
|
|
|
card_element = CardElement.new(pdf, orientation, config.rows_hash, wp) |
|
|
|
|
|
|
|
card_element.draw |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i + 1) % @config.per_page == 0 |
|
|
|
|
|
|
|
pdf.start_new_page |
|
|
|
|
|
|
|
card_y_offset = pdf.bounds.height - padding |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
card_y_offset -= (card_height + padding) |
|
|
|
end |
|
|
|
end |
|
|
|
pdf.start_new_page |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|