From ec399bc4fa81c475f2105243a2926c9e4b8e1c69 Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 4 Feb 2014 09:41:50 +0100 Subject: [PATCH] WIP. config accepts custom_field property and checks model for custom fields if it's true. not tested at all. --- app/models/export_card_configuration.rb | 2 +- .../pdf_export/export_card/column_element.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/export_card_configuration.rb b/app/models/export_card_configuration.rb index 3fed2c52d5..143997ae8f 100644 --- a/app/models/export_card_configuration.rb +++ b/app/models/export_card_configuration.rb @@ -37,7 +37,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", "indented"] + "width", "indented", "custom_field"] def assert_required_keys(hash, valid_keys, required_keys) hash.assert_valid_keys valid_keys diff --git a/lib/open_project/pdf_export/export_card/column_element.rb b/lib/open_project/pdf_export/export_card/column_element.rb index 1a8fb983b6..61ad8298cb 100644 --- a/lib/open_project/pdf_export/export_card/column_element.rb +++ b/lib/open_project/pdf_export/export_card/column_element.rb @@ -35,7 +35,17 @@ module OpenProject::PdfExport::ExportCard def draw # Get value from model - value = @work_package.send(@property_name) if @work_package.respond_to?(@property_name) else "" + if @config['custom_field'] + # Get + vs = work_package.custom_field_values.select {|cf| cf.custom_field.name == property_name} + value = if vs.first && vs.first.value + value vs.first.value + else + "" + end + else + value = @work_package.send(@property_name) if @work_package.respond_to?(@property_name) else "" + end if value.is_a?(Array) value = value.map{|c| c.to_s }.join("\n")