Adjust group padding and made some adjustments to config format.

pull/6827/head
Richard 11 years ago
parent 115d7c4a2f
commit a64219fc22
  1. 7
      lib/open_project/pdf_export/export_card/card_element.rb
  2. 2
      lib/open_project/pdf_export/export_card/document_generator.rb
  3. 10
      lib/open_project/pdf_export/export_card/group_element.rb

@ -30,6 +30,7 @@ module OpenProject::PdfExport::ExportCard
heights = assign_row_heights(rows) heights = assign_row_heights(rows)
text_padding = @orientation[:text_padding] text_padding = @orientation[:text_padding]
group_padding = @orientation[:group_padding]
current_row = 0 current_row = 0
current_y_offset = text_padding current_y_offset = text_padding
@ -44,7 +45,8 @@ module OpenProject::PdfExport::ExportCard
width: @orientation[:width], width: @orientation[:width],
height: group_height, height: group_height,
row_heights: row_heights, row_heights: row_heights,
text_padding: text_padding text_padding: text_padding,
group_padding: group_padding
} }
@group_elements << GroupElement.new(@pdf, group_orientation, g_value, @work_package) @group_elements << GroupElement.new(@pdf, group_orientation, g_value, @work_package)
@ -74,9 +76,8 @@ module OpenProject::PdfExport::ExportCard
def reduce_low_priority_rows(rows, assigned_heights, diffs, conflicted_i) def reduce_low_priority_rows(rows, assigned_heights, diffs, conflicted_i)
# Get an array of row indexes sorted by inverse priority # Get an array of row indexes sorted by inverse priority
# TODO RS: The priority should be on the row, not the column
priorities = *(0..rows.count - 1) priorities = *(0..rows.count - 1)
.zip(rows.map { |k, v| first_column_property(v, "priority") or 10 }) .zip(rows.map { |k, v| v["priority"] or 10 })
.sort {|x,y| y[1] <=> x[1]} .sort {|x,y| y[1] <=> x[1]}
.map {|x| x[0]} .map {|x| x[0]}

@ -38,6 +38,7 @@ module OpenProject::PdfExport::ExportCard
def render_pages def render_pages
card_padding = 10 card_padding = 10
group_padding = 5
text_padding = 5 text_padding = 5
card_width = pdf.bounds.width - (card_padding * 2) card_width = pdf.bounds.width - (card_padding * 2)
card_height = ((pdf.bounds.height - (card_padding * config.per_page )) / config.per_page) - (card_padding / config.per_page) card_height = ((pdf.bounds.height - (card_padding * config.per_page )) / config.per_page) - (card_padding / config.per_page)
@ -50,6 +51,7 @@ module OpenProject::PdfExport::ExportCard
width: card_width, width: card_width,
height: card_height, height: card_height,
card_padding: card_padding, card_padding: card_padding,
group_padding: group_padding,
text_padding: text_padding text_padding: text_padding
} }

@ -11,7 +11,7 @@ module OpenProject::PdfExport::ExportCard
@work_package = work_package @work_package = work_package
@row_elements = [] @row_elements = []
current_y_offset = 0 # OR text padding? current_y_offset = 0
row_heights = @orientation[:row_heights] row_heights = @orientation[:row_heights]
@rows_config.each_with_index do |(r_key, r_value), i| @rows_config.each_with_index do |(r_key, r_value), i|
@ -19,7 +19,7 @@ module OpenProject::PdfExport::ExportCard
row_orientation = { row_orientation = {
y_offset: @orientation[:height] - current_y_offset, y_offset: @orientation[:height] - current_y_offset,
x_offset: 0, x_offset: 0,
width: @orientation[:width], width: @orientation[:width] - (@orientation[:group_padding] * 2),
height: row_heights[i], height: row_heights[i],
text_padding: @orientation[:text_padding] text_padding: @orientation[:text_padding]
} }
@ -29,8 +29,10 @@ module OpenProject::PdfExport::ExportCard
end end
def draw def draw
top_left = [@orientation[:x_offset], @orientation[:y_offset]] padding = @orientation[:group_padding]
top_left = [@orientation[:x_offset] + padding, @orientation[:y_offset]]
bounds = @orientation.slice(:width, :height) bounds = @orientation.slice(:width, :height)
bounds[:width] -= padding * 2
@pdf.bounding_box(top_left, bounds) do @pdf.bounding_box(top_left, bounds) do
@pdf.stroke_color '000000' @pdf.stroke_color '000000'
@ -40,8 +42,10 @@ module OpenProject::PdfExport::ExportCard
row.draw row.draw
end end
if (@config["has_border"] or false)
@pdf.stroke_bounds @pdf.stroke_bounds
end end
end
end end
end end

Loading…
Cancel
Save