|
|
|
|
@ -166,7 +166,6 @@ module Submissions
|
|
|
|
|
|
|
|
|
|
composer.table(info_rows, cell_style: { padding: [0, 0, 0, 0], border: { width: 0 } })
|
|
|
|
|
|
|
|
|
|
composer.column(columns: 1, gaps: 0, style: { padding: [0, 200, 0, 0] }) do |column|
|
|
|
|
|
submission.template_fields.filter_map do |field|
|
|
|
|
|
next if field['submitter_uuid'] != submitter.uuid
|
|
|
|
|
|
|
|
|
|
@ -177,7 +176,7 @@ module Submissions
|
|
|
|
|
next if Array.wrap(value).compact_blank.blank?
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
column.formatted_text_box(
|
|
|
|
|
composer.formatted_text_box(
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
text: field['name'].to_s.upcase.presence ||
|
|
|
|
|
@ -190,14 +189,18 @@ module Submissions
|
|
|
|
|
attachment = submitter.attachments.find { |a| a.uuid == value }
|
|
|
|
|
image = Vips::Image.new_from_buffer(attachment.download, '').autorot
|
|
|
|
|
|
|
|
|
|
scale = [300.0 / image.width, 300.0 / image.height].min
|
|
|
|
|
scale = [600.0 / image.width, 600.0 / image.height].min
|
|
|
|
|
|
|
|
|
|
io = StringIO.new(image.resize([scale, 1].min).write_to_buffer('.png'))
|
|
|
|
|
resized_image = image.resize([scale, 1].min)
|
|
|
|
|
io = StringIO.new(resized_image.write_to_buffer('.png'))
|
|
|
|
|
|
|
|
|
|
column.image(io, padding: [0, field['type'] == 'initials' ? 200 : 100, 10, 0])
|
|
|
|
|
column.formatted_text_box([{ text: '' }])
|
|
|
|
|
width = field['type'] == 'initials' ? 100 : 200
|
|
|
|
|
height = resized_image.height * (width.to_f / resized_image.width)
|
|
|
|
|
|
|
|
|
|
composer.image(io, width:, height:, margin: [0, 0, 10, 0])
|
|
|
|
|
composer.formatted_text_box([{ text: '' }])
|
|
|
|
|
elsif field['type'] == 'file'
|
|
|
|
|
column.formatted_text_box(
|
|
|
|
|
composer.formatted_text_box(
|
|
|
|
|
Array.wrap(value).map do |uuid|
|
|
|
|
|
attachment = submitter.attachments.find { |a| a.uuid == uuid }
|
|
|
|
|
link =
|
|
|
|
|
@ -208,16 +211,15 @@ module Submissions
|
|
|
|
|
padding: [0, 0, 10, 0]
|
|
|
|
|
)
|
|
|
|
|
elsif field['type'] == 'checkbox'
|
|
|
|
|
column.formatted_text_box([{ text: value.to_s.titleize }], padding: [0, 0, 10, 0])
|
|
|
|
|
composer.formatted_text_box([{ text: value.to_s.titleize }], padding: [0, 0, 10, 0])
|
|
|
|
|
else
|
|
|
|
|
value = I18n.l(Date.parse(value), format: :long, locale: account.locale) if field['type'] == 'date'
|
|
|
|
|
value = value.join(', ') if value.is_a?(Array)
|
|
|
|
|
|
|
|
|
|
column.formatted_text_box([{ text: value.to_s.presence || 'n/a' }], padding: [0, 0, 10, 0])
|
|
|
|
|
composer.formatted_text_box([{ text: value.to_s.presence || 'n/a' }], padding: [0, 0, 10, 0])
|
|
|
|
|
end
|
|
|
|
|
]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
composer.draw_box(divider)
|
|
|
|
|
end
|
|
|
|
|
|