From 99b03cc31ded6917b04f7e2dc9b92c81587515d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 2 Nov 2016 16:36:45 +0100 Subject: [PATCH] Get array of workpackage children --- .../pdf_export/export_card/column_element.rb | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) 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 15ded5ab7b..ad019b497d 100644 --- a/lib/open_project/pdf_export/export_card/column_element.rb +++ b/lib/open_project/pdf_export/export_card/column_element.rb @@ -36,19 +36,9 @@ module OpenProject::PdfExport::ExportCard def draw # Get value from model if @work_package.respond_to?(@property_name) - value = @work_package.send(@property_name) + value = extract_property else - # Look in Custom Fields - value = "" - available_languages.each do |locale| - I18n.with_locale(locale) do - if (customs = @work_package.custom_field_values.select {|cf| cf.custom_field.name == @property_name} and customs.count > 0) - value = customs.first.value - @custom_field = customs.first.custom_field - end - end - @localised_custom_field_name = @custom_field.name if !!@custom_field - end + value = extract_custom_field end draw_value(value) @@ -56,6 +46,32 @@ module OpenProject::PdfExport::ExportCard private + def extract_property + value = @work_package.send(@property_name) + + case @property_name.to_s + when 'children' + return value.to_a + end + + value + end + + def extract_custom_field + # Look in Custom Fields + value = "" + available_languages.each do |locale| + I18n.with_locale(locale) do + if (customs = @work_package.custom_field_values.select {|cf| cf.custom_field.name == @property_name} and customs.count > 0) + value = customs.first.value + @custom_field = customs.first.custom_field + end + end + @localised_custom_field_name = @custom_field.name if !!@custom_field + end + + value + end def available_languages Setting.available_languages