WIP. added custom labels and label counts for lists. investigating failing tests.

pull/6827/head
Richard 11 years ago committed by Jens Ulferts
parent 2ac6fc4d18
commit 0ba8a42e4a
  1. 2
      app/models/export_card_configuration.rb
  2. 26
      lib/open_project/pdf_export/export_card/column_element.rb

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

@ -36,10 +36,6 @@ module OpenProject::PdfExport::ExportCard
def draw def draw
# Get value from model # Get value from model
value = @work_package.send(@property_name) if @work_package.respond_to?(@property_name) else "" value = @work_package.send(@property_name) if @work_package.respond_to?(@property_name) else ""
if value.is_a?(Array)
value = value.map{|c| c.to_s }.join("\n")
end
draw_value(value) draw_value(value)
end end
@ -88,12 +84,24 @@ module OpenProject::PdfExport::ExportCard
# Label and text # Label and text
has_label = @config['has_label'] has_label = @config['has_label']
indented = @config['indented'] indented = @config['indented']
if has_label
custom_label = @config['custom_label']
label_text = if custom_label
"#{custom_label}: "
else
"#{@work_package.class.human_attribute_name(@property_name)}: "
end
if @config['has_count'] && value.is_a?(Array)
label_text = "#{label_text} #{value.count}"
end
else
label_text = ""
end
# Flatten value to a string if it isn't already
value = value.map{|c| c.to_s }.join("\n") if value.is_a?(Array)
value = value.to_s if !value.is_a?(String) 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 if has_label && indented
width_ratio = 0.2 # Note: I don't think it's worth having this in the config width_ratio = 0.2 # Note: I don't think it's worth having this in the config

Loading…
Cancel
Save