add strikethrough
This commit is contained in:
@@ -206,15 +206,16 @@ module Submissions
|
||||
|
||||
submission = submitter.submission
|
||||
|
||||
return pdfs_index if submission.template_fields.blank?
|
||||
|
||||
with_headings = find_last_submitter(submission, submitter:).blank? if with_headings.nil?
|
||||
|
||||
locale = submitter.metadata.fetch('lang', account.locale)
|
||||
|
||||
submission.template_fields.each do |field|
|
||||
next if field['type'] == 'heading' && !with_headings
|
||||
next if field['submitter_uuid'] != submitter.uuid && field['type'] != 'heading'
|
||||
(submission.template_fields || submission.template.fields).each do |field|
|
||||
next if !with_headings &&
|
||||
(field['type'] == 'heading' || (field['type'] == 'strikethrough' && field['conditions'].blank?))
|
||||
|
||||
next if field['submitter_uuid'] != submitter.uuid && field['type'] != 'heading' &&
|
||||
(field['type'] != 'strikethrough' || field['conditions'].present?)
|
||||
|
||||
field.fetch('areas', []).each do |area|
|
||||
pdf = pdfs_index[area['attachment_uuid']]
|
||||
@@ -258,6 +259,7 @@ module Submissions
|
||||
|
||||
value = submitter.values[field['uuid']]
|
||||
value = field['default_value'] if field['type'] == 'heading'
|
||||
value = field['default_value'] if field['type'] == 'strikethrough' && value.nil? && field['conditions'].blank?
|
||||
|
||||
text_align = field.dig('preferences', 'align').to_s.to_sym.presence ||
|
||||
(value.to_s.match?(RTL_REGEXP) ? :right : :left)
|
||||
@@ -448,8 +450,7 @@ module Submissions
|
||||
cv.image(PdfIcons.paperclip_io, at: [0, 0], width: box.content_width)
|
||||
end
|
||||
|
||||
acc << HexaPDF::Layout::TextFragment.create("#{attachment.filename}\n", font:,
|
||||
font_size:)
|
||||
acc << HexaPDF::Layout::TextFragment.create("#{attachment.filename}\n", font:, font_size:)
|
||||
end
|
||||
|
||||
lines = layouter.fit(items, area['w'] * width, height).lines
|
||||
@@ -567,6 +568,43 @@ module Submissions
|
||||
cell_layouter.fit([text], cell_width, [line_height, area['h'] * height].max)
|
||||
.draw(canvas, x, height - (area['y'] * height))
|
||||
end
|
||||
when 'strikethrough'
|
||||
scale = 1000.0 / width
|
||||
|
||||
line_width = 6.0 / scale
|
||||
area_height = area['h'] * height
|
||||
|
||||
if area_height * scale < 40.0
|
||||
canvas.tap do |c|
|
||||
c.stroke_color(field.dig('preferences', 'color').presence || 'red')
|
||||
c.line_width(line_width)
|
||||
c.line(width * area['x'],
|
||||
height - (height * area['y']) - (area_height / 2),
|
||||
(width * area['x']) + (width * area['w']),
|
||||
height - (height * area['y']) - (area_height / 2))
|
||||
c.stroke
|
||||
end
|
||||
else
|
||||
canvas.tap do |c|
|
||||
c.stroke_color(field.dig('preferences', 'color').presence || 'red')
|
||||
c.line_width(line_width)
|
||||
c.line((width * area['x']) + (line_width / 2),
|
||||
height - (height * area['y']) - (line_width / 2),
|
||||
(width * area['x']) + (width * area['w']) - (line_width / 2),
|
||||
height - (height * area['y']) - area_height + (line_width / 2))
|
||||
c.stroke
|
||||
end
|
||||
|
||||
canvas.tap do |c|
|
||||
c.stroke_color(field.dig('preferences', 'color').presence || 'red')
|
||||
c.line_width(line_width)
|
||||
c.line((width * area['x']) + (line_width / 2),
|
||||
height - (height * area['y']) - area_height + (line_width / 2),
|
||||
(width * area['x']) + (width * area['w']) - (line_width / 2),
|
||||
height - (height * area['y']) - (line_width / 2))
|
||||
c.stroke
|
||||
end
|
||||
end
|
||||
else
|
||||
if field['type'] == 'date'
|
||||
value = TimeUtils.format_date_string(value, field.dig('preferences', 'format'), locale)
|
||||
|
||||
Reference in New Issue
Block a user