Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/export_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def to_csv
end

def map_field_with_value(child, fields)
fields.map { |field| format_field_for_export(field, child[field.name] || child.send(field.name), child) }

fields.map do |field|
value = child[field.name] || (child.send(field.name) if child.respond_to?(field.name))
format_field_for_export(field, value, child)
end
end

def metadata_fields(fields, extras)
Expand All @@ -82,7 +86,16 @@ def to_full_pdf

def format_field_for_export(field, value, child = nil)
return '' if value.blank?
return value.join(', ') if field.type == Field::CHECK_BOXES
if field.type == Field::CHECK_BOXES
return case value.class
when Array
value.join(', ')
when String
value
else
value
end
end
if child
# TODO: rubocop:disable CommentAnnotation
# child['photo_url'] = child_photo_url(child, child.primary_photo_id) unless (child.primary_photo_id.nil? || child.primary_photo_id == "")
Expand Down