column widths being calculated from config values.

pull/6827/head
Richard 11 years ago
parent 31f39fe776
commit bc2cafa68e
  1. 23
      lib/open_project/pdf_export/taskboard_card/row_element.rb

@ -8,21 +8,28 @@ module OpenProject::PdfExport::TaskboardCard
@column_elements = [] @column_elements = []
# Initialise column elements # Initialise column elements
column_position = 0 x_offset = 0
cols_count = columns_config.count
default_col_width = @orientation[:width] / cols_count
columns_config.each do |key, value| columns_config.each_with_index do |key, value|
# TODO: Intelligently configure the orientation of column elements width = col_width(value)
column_orientation = @orientation.clone column_orientation = @orientation.clone
column_orientation[:x_offset] = column_position * default_col_width column_orientation[:x_offset] = x_offset
column_orientation[:width] = default_col_width column_orientation[:width] = width
x_offset += width
@column_elements << ColumnElement.new(@pdf, key, value, column_orientation, @work_package) @column_elements << ColumnElement.new(@pdf, key, value, column_orientation, @work_package)
column_position += 1
end end
end end
def col_width(col_config)
cols_count = @columns_config.count
w = col_config["width"]
return @orientation[:width] / cols_count if w.nil?
i = w.index("%") or w.length
Float(w.slice(0, i)) / 100 * @orientation[:width]
end
def draw def draw
# Draw columns # Draw columns
@column_elements.each do |c| @column_elements.each do |c|

Loading…
Cancel
Save