add ability to draw areas for radio options

This commit is contained in:
Pete Matsyburka
2023-11-14 01:30:00 +02:00
parent 9aa68fe955
commit 333a5d6b7b
6 changed files with 138 additions and 13 deletions
@@ -124,7 +124,13 @@ module Submissions
layouter.fit(items, area['w'] * width, height_diff.positive? ? box_height : area['h'] * height)
.draw(canvas, (area['x'] * width) + TEXT_LEFT_MARGIN,
height - (area['y'] * height) + height_diff - TEXT_TOP_MARGIN)
when 'checkbox'
when ->(type) { type == 'checkbox' || (type.in?(%w[multiple radio]) && area['option_uuid'].present?) }
if field['type'].in?(%w[multiple radio])
option = field['options']&.find { |o| o['uuid'] == area['option_uuid'] }
value = Array.wrap(value).include?(option['value'])
end
next unless value == true
scale = [(area['w'] * width) / PdfIcons::WIDTH, (area['h'] * height) / PdfIcons::HEIGHT].min