add signature id

pull/349/head
Pete Matsyburka 1 year ago
parent 09074e2ac0
commit 43db15b350

@ -13,7 +13,8 @@ class AccountConfigsController < ApplicationController
AccountConfig::FORM_WITH_CONFETTI_KEY,
AccountConfig::DOWNLOAD_LINKS_AUTH_KEY,
AccountConfig::FORCE_SSO_AUTH_KEY,
AccountConfig::FLATTEN_RESULT_PDF_KEY
AccountConfig::FLATTEN_RESULT_PDF_KEY,
AccountConfig::WITH_SIGNATURE_ID
].freeze
InvalidKey = Class.new(StandardError)

@ -16,7 +16,7 @@ module Api
cookies.encrypted[:signature_uuids] = build_new_cookie_signatures_json(submitter, attachment)
end
render json: attachment.as_json(only: %i[uuid], methods: %i[url filename content_type])
render json: attachment.as_json(only: %i[uuid created_at], methods: %i[url filename content_type])
end
def build_new_cookie_signatures_json(submitter, attachment)

@ -15,7 +15,7 @@ class SubmitFormValuesController < ApplicationController
render json: {
value:,
attachment: attachment&.as_json(only: %i[uuid], methods: %i[url filename content_type])
attachment: attachment&.as_json(only: %i[uuid created_at], methods: %i[url filename content_type])
}, head: :ok
end
end

@ -22,6 +22,7 @@ safeRegisterElement('submission-form', class extends HTMLElement {
scrollPadding: this.dataset.scrollPadding || '-80px',
dryRun: this.dataset.dryRun === 'true',
expand: ['true', 'false'].includes(this.dataset.expand) ? this.dataset.expand === 'true' : null,
withSignatureId: this.dataset.withSignatureId === 'true',
withConfetti: this.dataset.withConfetti !== 'false',
withDisclosure: this.dataset.withDisclosure === 'true',
withTypedSignature: this.dataset.withTypedSignature !== 'false',

@ -54,11 +54,37 @@
class="object-contain mx-auto"
:src="stamp.url"
>
<img
<div
v-else-if="field.type === 'signature' && signature"
class="object-contain mx-auto"
:src="signature.url"
class="flex flex-col justify-between h-full overflow-hidden"
>
<div
class="flex-grow flex overflow-hidden"
style="min-height: 50%"
>
<img
class="object-contain mx-auto"
:src="signature.url"
>
</div>
<div
v-if="withSignatureId"
class="w-full mt-1 text-[1vw] lg:text-[0.55rem] lg:leading-[0.65rem]"
>
<div class="truncate uppercase">
ID: {{ signature.uuid }}
</div>
<div>
{{ t('reason') }}: {{ t('digitally_signed_by') }} {{ submitter.name }}
<template v-if="submitter.email">
&lt;{{ submitter.email }}&gt;
</template>
</div>
<div>
{{ new Date(signature.created_at).toLocaleString(undefined, { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZoneName: 'short' }) }}
</div>
</div>
</div>
<img
v-else-if="field.type === 'initials' && initials"
class="object-contain mx-auto"
@ -198,6 +224,15 @@ export default {
type: Object,
required: true
},
submitter: {
type: Object,
required: true
},
withSignatureId: {
type: Boolean,
required: false,
default: false
},
isValueSet: {
type: Boolean,
required: false,

@ -23,7 +23,9 @@
:submittable="true"
:field-index="fieldIndex"
:scroll-padding="scrollPadding"
:submitter="submitter"
:with-field-placeholder="withFieldPlaceholder"
:with-signature-id="withSignatureId"
:is-active="currentStep === step"
:with-label="withLabel && !withFieldPlaceholder"
:is-value-set="step.some((f) => f.uuid in values)"
@ -50,6 +52,15 @@ export default {
required: false,
default: () => []
},
withSignatureId: {
type: Boolean,
required: false,
default: false
},
submitter: {
type: Object,
required: true
},
values: {
type: Object,
required: false,

@ -4,7 +4,9 @@
:steps="stepFields"
:values="values"
:with-field-placeholder="withFieldPlaceholder"
:submitter="submitter"
:scroll-el="scrollEl"
:with-signature-id="withSignatureId"
:attachments-index="attachmentsIndex"
:with-label="!isAnonymousChecboxes && showFieldNames"
:current-step="currentStepFields"
@ -535,6 +537,11 @@ export default {
type: Object,
required: true
},
withSignatureId: {
type: Boolean,
required: false,
default: false
},
scrollPadding: {
type: String,
required: false,

@ -15,6 +15,8 @@ const en = {
take_photo: 'Take photo',
number_phone_is_invalid: '{number} phone is invalid',
file: 'File',
digitally_signed_by: 'Digitally signed by',
reason: 'Reason',
select: 'Select',
checkbox: 'Checkbox',
multiple: 'Multiple',
@ -83,6 +85,8 @@ const es = {
text: 'Texto',
signature: 'Firma',
pay: 'Pagar',
digitally_signed_by: 'Firmado digitalmente por',
reason: 'Razón',
initials: 'Iniciales',
date: 'Fecha',
number: 'Número',
@ -155,6 +159,8 @@ const it = {
already_paid: 'Pagato',
text: 'Testo',
signature: 'Firma',
digitally_signed_by: 'Firmato digitalmente da',
reason: 'Motivo',
initials: 'Iniziali',
date: 'Data',
number: 'Numero',
@ -228,6 +234,8 @@ const de = {
minimize: 'Minimieren',
text: 'Text',
signature: 'Unterschrift',
digitally_signed_by: 'Digital unterschrieben von',
reason: 'Grund',
initials: 'Initialen',
date: 'Datum',
number: 'Nummer',
@ -302,6 +310,8 @@ const fr = {
already_paid: 'Déjà payé',
signature: 'Signature',
initials: 'Initiales',
digitally_signed_by: 'Signé numériquement par',
reason: 'Raison',
pay: 'Payer',
date: 'Date',
number: 'Numéro',
@ -373,6 +383,8 @@ const pl = {
minimize: 'Zminimalizuj',
text: 'Tekst',
already_paid: 'Już zapłacono',
digitally_signed_by: 'Podpisano cyfrowo przez',
reason: 'Powód',
signature: 'Podpis',
initials: 'Inicjały',
date: 'Data',
@ -447,6 +459,8 @@ const uk = {
text: 'Текст',
already_paid: 'Вже оплачено',
signature: 'Підпис',
digitally_signed_by: 'Підписано в електронному вигляді',
reason: 'Причина',
initials: 'Ініціали',
date: 'Дата',
number: 'Число',
@ -523,6 +537,8 @@ const cs = {
initials: 'Iniciály',
date: 'Datum',
number: 'Číslo',
digitally_signed_by: 'Digitálně podepsáno',
reason: 'Důvod',
image: 'Obrázek',
pay: 'Zaplatit',
file: 'Soubor',
@ -594,6 +610,8 @@ const pt = {
text: 'Texto',
signature: 'Assinatura',
initials: 'Iniciais',
digitally_signed_by: 'Assinado digitalmente por',
reason: 'Razão',
date: 'Data',
number: 'Número',
image: 'Imagem',
@ -668,6 +686,8 @@ const he = {
signature: 'חתימה',
initials: 'ראשי תיבות',
date: 'תאריך',
digitally_signed_by: 'חתום דיגיטלית על ידי',
reason: 'סיבה',
number: 'מספר',
image: 'תמונה',
file: 'קובץ',
@ -740,6 +760,8 @@ const nl = {
text: 'Tekst',
already_paid: 'Al betaald',
signature: 'Handtekening',
digitally_signed_by: 'Digitaal ondertekend door',
reason: 'Reden',
initials: 'Initialen',
date: 'Datum',
number: 'Nummer',
@ -815,6 +837,8 @@ const ar = {
initials: 'الاختصارات',
date: 'تاريخ',
number: 'رقم',
digitally_signed_by: 'تم التوقيع رقميًا بواسطة',
reason: 'السبب',
image: 'صورة',
take_photo: 'التقاط صورة',
pay: 'دفع',
@ -888,6 +912,8 @@ const ko = {
signature: '서명',
initials: '이니셜',
date: '날짜',
digitally_signed_by: '디지털 서명이 완료되었습니다',
reason: '이유',
number: '숫자',
pay: '급여',
image: '이미지',

@ -38,6 +38,7 @@ class AccountConfig < ApplicationRecord
DOWNLOAD_LINKS_AUTH_KEY = 'download_links_auth'
FORCE_SSO_AUTH_KEY = 'force_sso_auth'
FLATTEN_RESULT_PDF_KEY = 'flatten_result_pdf'
WITH_SIGNATURE_ID = 'with_signature_id'
DEFAULT_VALUES = {
SUBMITTER_INVITATION_EMAIL_KEY => {

@ -51,6 +51,18 @@
</div>
<% end %>
<% end %>
<% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::WITH_SIGNATURE_ID) %>
<% if can?(:manage, account_config) %>
<%= form_for account_config, url: account_configs_path, method: :post do |f| %>
<%= f.hidden_field :key %>
<div class="flex items-center justify-between py-2.5">
<span>
Add signature ID to the documents
</span>
<%= f.check_box :value, class: 'toggle', checked: account_config.value, onchange: 'this.form.requestSubmit()' %>
</div>
<% end %>
<% end %>
<% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::ALLOW_TYPED_SIGNATURE) %>
<% if can?(:manage, account_config) %>
<%= form_for account_config, url: account_configs_path, method: :post do |f| %>

@ -1,6 +1,28 @@
<% align = field.dig('preferences', 'align') %>
<field-value dir="auto" class="flex absolute text-[1.5vw] lg:text-base <%= align == 'right' ? 'justify-end' : (align == 'center' ? 'justify-center' : '') %>" style="width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%; <%= "font-size: #{field['preferences']['font_size']}pt" if field.dig('preferences', 'font_size') %>">
<% if field['type'].in?(['signature', 'image', 'initials', 'stamp']) %>
<% if field['type'] == 'signature' %>
<div class="flex flex-col justify-between h-full overflow-hidden">
<div class="flex-grow flex overflow-hidden" style="min-height: 50%">
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>">
</div>
<% if local_assigns[:with_signature_id] && attachment = attachments_index[value] %>
<div class="w-full mt-1 text-[1vw] lg:text-[0.55rem] lg:leading-[0.65rem]">
<div class="truncate uppercase">
ID: <%= attachment.uuid %>
</div>
<div>
<%= t('reason') %>: <%= t('digitally_signed_by') %> <%= submitter.name %>
<% if submitter.email %>
&lt;<%= submitter.email %>&gt;
<% end %>
</div>
<div>
<%= l(attachment.created_at.in_time_zone(local_assigns[:timezone]), format: :long, locale: local_assigns[:locale]) %> <%= TimeUtils.timezone_abbr(local_assigns[:timezone], attachment.created_at) %>
</div>
</div>
<% end %>
</div>
<% elsif field['type'].in?(['image', 'initials', 'stamp']) %>
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" loading="lazy">
<% elsif field['type'].in?(['file', 'payment']) %>
<autosize-field></autosize-field>

@ -1,6 +1,7 @@
<% if params[:controller] == 'submissions_preview' %>
<%= render 'submissions/preview_tags' %>
<% end %>
<% with_signature_id = @submission.account.account_configs.exists?(key: AccountConfig::WITH_SIGNATURE_ID, value: true) %>
<div style="max-width: 1600px" class="mx-auto pl-4">
<div class="flex justify-between py-1.5 items-center pr-4 sticky top-0 md:relative z-10 bg-base-100">
<a href="<%= signed_in? && @submission.account_id == current_account&.id ? template_path(@submission.template) : '/' %>" class="flex items-center space-x-3 py-1">
@ -73,6 +74,7 @@
<div id="document_view" class="w-full overflow-y-auto overflow-x-hidden mt-0.5 pt-0.5">
<div class="pr-3.5 pl-0.5">
<% fields_index = Templates.build_field_areas_index(@submission.template_fields || @submission.template.fields) %>
<% submitters_index = @submission.submitters.index_by(&:uuid) %>
<% values = @submission.submitters.reduce({}) { |acc, sub| acc.merge(sub.values) } %>
<% attachments_index = ActiveStorage::Attachment.where(record: @submission.submitters, name: :attachments).preload(:blob).index_by(&:uuid) %>
<% page_blob_struct = Struct.new(:url, :metadata, keyword_init: true) %>
@ -92,7 +94,7 @@
<% fields_index.dig(document.uuid, index)&.each do |(area, field)| %>
<% value = values[field['uuid']] %>
<% next if value.blank? %>
<%= render 'submissions/value', area:, field:, attachments_index:, value:, locale: @submission.account.locale, timezone: @submission.account.timezone %>
<%= render 'submissions/value', area:, field:, attachments_index:, value:, locale: @submission.account.locale, timezone: @submission.account.timezone, submitter: submitters_index[field['submitter_uuid']], with_signature_id: %>
<% end %>
</div>
</div>

@ -1,3 +1,3 @@
<% data_attachments = attachments_index.values.select { |e| e.record_id == submitter.id }.to_json(only: %i[uuid], methods: %i[url filename content_type]) %>
<% data_attachments = attachments_index.values.select { |e| e.record_id == submitter.id }.to_json(only: %i[uuid created_at], methods: %i[url filename content_type]) %>
<% data_fields = (submitter.submission.template_fields || submitter.submission.template.fields).select { |f| f['submitter_uuid'] == submitter.uuid }.to_json %>
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-with-confetti="<%= configs[:with_confetti] %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'] %>" data-completed-message="<%= configs[:completed_message].to_json %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.preferences.key?('go_to_last') ? submitter.preferences['go_to_last'] : submitter.opened_at? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Accounts.can_send_emails?(submitter.submission.account) %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>" data-previous-signature-value="<%= local_assigns[:signature_attachment]&.uuid %>" data-remember-signature="<%= configs[:prefill_signature] %>" data-dry-run="<%= local_assigns[:dry_run] %>" data-expand="<%= local_assigns[:expand] %>" data-scroll-padding="<%= local_assigns[:scroll_padding] %>"></submission-form>
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-with-signature-id="<%= configs[:with_signature_id] %>" data-with-confetti="<%= configs[:with_confetti] %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'] %>" data-completed-message="<%= configs[:completed_message].to_json %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.preferences.key?('go_to_last') ? submitter.preferences['go_to_last'] : submitter.opened_at? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Accounts.can_send_emails?(submitter.submission.account) %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>" data-previous-signature-value="<%= local_assigns[:signature_attachment]&.uuid %>" data-remember-signature="<%= configs[:prefill_signature] %>" data-dry-run="<%= local_assigns[:dry_run] %>" data-expand="<%= local_assigns[:expand] %>" data-scroll-padding="<%= local_assigns[:scroll_padding] %>"></submission-form>

@ -28,7 +28,7 @@
<% next if field['redacted'] && field['submitter_uuid'] != @submitter.uuid %>
<% next if value == '{{date}}' && field['submitter_uuid'] != @submitter.uuid %>
<% next if field.dig('preferences', 'formula').present? && field['submitter_uuid'] == @submitter.uuid %>
<%= render 'submissions/value', area:, field:, attachments_index: @attachments_index, value:, locale: @submitter.account.locale, timezone: @submitter.account.timezone %>
<%= render 'submissions/value', area:, field:, attachments_index: @attachments_index, value:, locale: @submitter.account.locale, timezone: @submitter.account.timezone, submitter: @submitter, with_signature_id: @form_configs[:with_signature_id] %>
<% end %>
</div>
</div>

@ -22,6 +22,7 @@ en: &en
verification_code_code: 'Verification code: %{code}'
digitally_signed_by: Digitally signed by
role: Role
reason: Reason
provide_your_email_to_start: Provide your email to start
start: Start
starting: Starting
@ -64,6 +65,7 @@ en: &en
es: &es
role: Rol
reason: Razón
verification_code_code: 'Código de verificación: %{code}'
email: Correo electrónico
digitally_signed_by: Firmado digitalmente por
@ -106,6 +108,7 @@ es: &es
it: &it
role: Rôle
reason: Ragione
verification_code_code: 'Codice di verifica: %{code}'
email: Email
digitally_signed_by: Firmato digitalmente da
@ -149,6 +152,7 @@ fr: &fr
email: Email
verification_code_code: 'Code de vérification: %{code}'
digitally_signed_by: Signé numériquement par
reason: Raison
role: Rôle
provide_your_email_to_start: Entrez votre adresse email pour commencer
start: Démarrer
@ -189,6 +193,7 @@ fr: &fr
pt: &pt
role: Função
email: Email
reason: Razão
verification_code_code: 'Código de verificação: %{code}'
digitally_signed_by: Assinado digitalmente por
role: Função
@ -230,6 +235,7 @@ pt: &pt
de: &de
role: Rolle
verification_code_code: 'Verifizierungscode: %{code}'
reason: Grund
email: E-Mail
digitally_signed_by: Digital signiert von
role: Rolle
@ -275,6 +281,7 @@ pl:
role: Rola
provide_your_email_to_start: Podaj swój adres email, aby rozpocząć
start: Rozpocznij
reason: Powód
starting: Rozpoczynanie
form_has_been_deleted_by_html: 'Formularz został usunięty przez <span class="font-semibold">%{name}</span>.'
invited_by_html: 'Zaproszony przez <span class="font-semibold">%{name}</span>'
@ -315,6 +322,7 @@ uk:
role: Роль
provide_your_email_to_start: Введіть свій email, щоб почати
start: Почати
reason: Причина
starting: Початок
form_has_been_deleted_by_html: 'Форму було видалено користувачем <span class="font-semibold">%{name}</span>.'
invited_by_html: 'Запрошений користувачем <span class="font-semibold">%{name}</span>'
@ -354,6 +362,7 @@ cs:
verification_code_code: 'Ověřovací kód: %{code}'
role: Role
provide_your_email_to_start: Zadejte svůj email pro zahájení
reason: Důvod
start: Zahájit
starting: Zahajování
form_has_been_deleted_by_html: 'Formulář byl smazán uživatelem <span class="font-semibold">%{name}</span>.'
@ -392,6 +401,7 @@ he:
email: דוא"ל
digitally_signed_by: חתום דיגיטלית על ידי
role: תפקיד
reason: סיבה
verification_code_code: 'קוד אימות: %{code}'
provide_your_email_to_start: ספק את כתובת הדוא"ל שלך כדי להתחיל
start: התחל
@ -435,6 +445,7 @@ nl:
verification_code_code: 'Verificatiecode: %{code}'
provide_your_email_to_start: Geef uw e-mailadres om te beginnen
start: Start
reason: Reden
starting: Starten
form_has_been_deleted_by_html: 'Formulier is verwijderd door <span class="font-semibold">%{name}</span>.'
invited_by_html: 'Uitgenodigd door <span class="font-semibold">%{name}</span>'
@ -478,6 +489,7 @@ ar:
starting: بداية
verification_code_code: 'رمز التحقق: %{code}'
form_has_been_deleted_by_html: 'تم حذف الاستمارة بواسطة <span class="font-semibold">%{name}</span>.'
reason: سبب
invited_by_html: 'تمت الدعوة بواسطة <span class="font-semibold">%{name}</span>'
you_have_been_invited_to_submit_a_form: تمت دعوتك لتقديم استمارة
signed_on_time: 'تم التوقيع في %{time}'
@ -516,6 +528,7 @@ ko:
role: 역할
provide_your_email_to_start: 시작하려면 이메일을 제공하세요
start: 시작
reason: 이유
starting: 시작 중
form_has_been_deleted_by_html: '<span class="font-semibold">%{name}</span>에 의해 양식이 삭제되었습니다.'
invited_by_html: '<span class="font-semibold">%{name}</span>에 의해 초대되었습니다.'

@ -102,6 +102,8 @@ module Submissions
.rectangle(0, 0, box.width, 20)
.rectangle(0, box.height - 20, box.width, 20)
.fill
maybe_add_background(canvas, submission, page_size)
end
style.frame = style.create_frame(canvas.context, 50)
end
@ -336,6 +338,8 @@ module Submissions
'Signed with DocuSeal.co'
end
def maybe_add_background(_canvas, _submission, _page_size); end
def add_logo(column, _submission = nil)
column.image(PdfIcons.logo_io, width: 40, height: 40, position: :float)

@ -88,6 +88,9 @@ module Submissions
def generate_pdfs(submitter)
cell_layouter = HexaPDF::Layout::TextLayouter.new(text_valign: :center, text_align: :center)
with_signature_id = submitter.account.account_configs
.exists?(key: AccountConfig::WITH_SIGNATURE_ID, value: true)
is_flatten =
submitter.account.account_configs
.find_or_initialize_by(key: AccountConfig::FLATTEN_RESULT_PDF_KEY).value != false
@ -97,6 +100,22 @@ module Submissions
pdfs_index = build_pdfs_index(submitter, flatten: is_flatten)
if with_signature_id
pdfs_index.each_value do |pdf|
next if pdf.trailer.info[:DocumentID].present?
pdf.trailer.info[:DocumentID] = Digest::MD5.hexdigest(submitter.submission.slug).upcase
pdf.pages.each do |page|
font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * 9).to_i
cnv = page.canvas(type: :overlay)
cnv.font(FONT_NAME, size: font_size)
cnv.text("Document ID: #{Digest::MD5.hexdigest(submitter.submission.slug).upcase}",
at: [2, 4])
end
end
end
submitter.submission.template_fields.each do |field|
next if field['submitter_uuid'] != submitter.uuid
@ -150,6 +169,69 @@ module Submissions
canvas.font(FONT_NAME, size: font_size)
case field['type']
when ->(type) { type == 'signature' && with_signature_id }
attachment = submitter.attachments.find { |a| a.uuid == value }
attachments_data_cache[attachment.uuid] ||= attachment.download
image = Vips::Image.new_from_buffer(attachments_data_cache[attachment.uuid], '').autorot
id_string = "ID: #{attachment.uuid}".upcase
while true
text = HexaPDF::Layout::TextFragment.create(id_string,
font:,
font_size: (font_size / 1.8).to_i)
result = layouter.fit([text], area['w'] * width, (font_size / 1.8) / 0.65)
break if result.status == :success
id_string = "#{id_string.delete_suffix('...')[0..-2]}..."
break if id_string.length < 8
end
reason_string =
"#{I18n.t('reason')}: #{I18n.t('digitally_signed_by')} " \
"#{submitter.name}#{submitter.email.present? ? " <#{submitter.email}>" : ''}\n" \
"#{I18n.l(attachment.created_at.in_time_zone(submitter.account.timezone),
format: :long, locale: submitter.account.locale)} " \
"#{TimeUtils.timezone_abbr(submitter.account.timezone, attachment.created_at)}"
reason_text = HexaPDF::Layout::TextFragment.create(reason_string,
font:,
font_size: (font_size / 1.8).to_i)
reason_result = layouter.fit([reason_text], area['w'] * width, height)
text_height = result.lines.sum(&:height) + reason_result.lines.sum(&:height)
image_height = (area['h'] * height) - text_height
image_height = (area['h'] * height) / 2 if image_height < (area['h'] * height) / 2
scale = [(area['w'] * width) / image.width, image_height / image.height].min
io = StringIO.new(image.resize([scale * 4, 1].select(&:positive?).min).write_to_buffer('.png'))
layouter.fit([text], area['w'] * width, (font_size / 1.8) / 0.65)
.draw(canvas, (area['x'] * width) + TEXT_LEFT_MARGIN,
height - (area['y'] * height) - TEXT_TOP_MARGIN - image_height)
layouter.fit([reason_text], area['w'] * width, reason_result.lines.sum(&:height))
.draw(canvas, (area['x'] * width) + TEXT_LEFT_MARGIN,
height - (area['y'] * height) - TEXT_TOP_MARGIN -
result.lines.sum(&:height) - image_height)
canvas.image(
io,
at: [
(area['x'] * width) + (area['w'] * width / 2) - ((image.width * scale) / 2),
height - (area['y'] * height) - (image.height * scale / 2) - (image_height / 2)
],
width: image.width * scale,
height: image.height * scale
)
when 'image', 'signature', 'initials', 'stamp'
attachment = submitter.attachments.find { |a| a.uuid == value }

@ -6,6 +6,7 @@ module Submitters
AccountConfig::FORM_COMPLETED_MESSAGE_KEY,
AccountConfig::FORM_WITH_CONFETTI_KEY,
AccountConfig::FORM_PREFILL_SIGNATURE_KEY,
AccountConfig::WITH_SIGNATURE_ID,
AccountConfig::ALLOW_TYPED_SIGNATURE].freeze
module_function
@ -18,8 +19,14 @@ module Submitters
with_typed_signature = find_safe_value(configs, AccountConfig::ALLOW_TYPED_SIGNATURE) != false
with_confetti = find_safe_value(configs, AccountConfig::FORM_WITH_CONFETTI_KEY) != false
prefill_signature = find_safe_value(configs, AccountConfig::FORM_PREFILL_SIGNATURE_KEY) != false
attrs = { completed_button:, with_typed_signature:, with_confetti:, completed_message:, prefill_signature: }
with_signature_id = find_safe_value(configs, AccountConfig::WITH_SIGNATURE_ID) == true
attrs = { completed_button:,
with_typed_signature:,
with_confetti:,
completed_message:,
prefill_signature:,
with_signature_id: }
keys.each do |key|
attrs[key.to_sym] = configs.find { |e| e.key == key.to_s }&.value

Loading…
Cancel
Save