In the config file the value "indentation: true" will result in the column content being indented from the label if there is a label.

pull/6827/head
Richard 11 years ago
parent 2fb4a8c2ff
commit 24d28384c3
  1. 2
      app/models/export_card_configuration.rb
  2. 49
      lib/open_project/pdf_export/export_card/column_element.rb

@ -12,7 +12,7 @@ class ExportCardConfiguration < ActiveRecord::Base
REQUIRED_COLUMN_KEYS = []
VALID_COLUMN_KEYS = ["has_label", "min_font_size", "max_font_size",
"font_size", "font_style", "text_align", "minimum_lines", "render_if_empty",
"width"]
"width", "indented"]
def assert_required_keys(hash, valid_keys, required_keys)
hash.assert_valid_keys valid_keys

@ -19,12 +19,6 @@ module OpenProject::PdfExport::ExportCard
end
def draw_value(value)
has_label = @config['has_label']
value = value.to_s if !value.is_a?(String)
text = ""
text = text + "#{@work_package.class.human_attribute_name(@property_name)}: " if has_label
text = text + value
# Font size
if @config['font_size']
# Specific size given
@ -49,7 +43,46 @@ module OpenProject::PdfExport::ExportCard
font_style = (@config['font_style'] or "normal").to_sym
text_align = (@config['text_align'] or "left").to_sym
# Draw on pdf
# Label and text
has_label = @config['has_label']
indented = @config['indented']
value = value.to_s if !value.is_a?(String)
label_text = if has_label
"#{@work_package.class.human_attribute_name(@property_name)}: "
else
""
end
if has_label && indented
width_ratio = 0.2 # Note: I don't think it's worth having this in the config
# Label Textbox
offset = [@orientation[:x_offset], @orientation[:height] - (@orientation[:text_padding] / 2)]
box = @pdf.text_box(label_text,
{:height => @orientation[:height],
:width => @orientation[:width] * width_ratio,
:at => offset,
:style => :bold,
:overflow => overflow,
:size => font_size,
:min_font_size => min_font_size,
:align => :left})
# Content Textbox
offset = [@orientation[:x_offset] + (@orientation[:width] * width_ratio), @orientation[:height] - (@orientation[:text_padding] / 2)]
box = @pdf.text_box(value,
{:height => @orientation[:height],
:width => @orientation[:width] * (1 - width_ratio),
:at => offset,
:style => font_style,
:overflow => overflow,
:size => font_size,
:min_font_size => min_font_size,
:align => text_align})
else
text = label_text + value
# Label and Content Textbox
offset = [@orientation[:x_offset], @orientation[:height] - (@orientation[:text_padding] / 2)]
box = @pdf.text_box(text,
{:height => @orientation[:height],
@ -63,4 +96,6 @@ module OpenProject::PdfExport::ExportCard
end
end
end
end
Loading…
Cancel
Save