add with file links option
This commit is contained in:
@@ -42,6 +42,7 @@ class AccountConfig < ApplicationRecord
|
||||
FORCE_SSO_AUTH_KEY = 'force_sso_auth'
|
||||
FLATTEN_RESULT_PDF_KEY = 'flatten_result_pdf'
|
||||
WITH_SIGNATURE_ID = 'with_signature_id'
|
||||
WITH_FILE_LINKS_KEY = 'with_file_links'
|
||||
WITH_SIGNATURE_ID_REASON_KEY = 'with_signature_id_reason'
|
||||
WITH_AUDIT_VALUES_KEY = 'with_audit_values'
|
||||
WITH_SUBMITTER_TIMEZONE_KEY = 'with_submitter_timezone'
|
||||
|
||||
@@ -113,11 +113,13 @@ module Submissions
|
||||
|
||||
configs = submission.account.account_configs.where(key: [AccountConfig::WITH_AUDIT_VALUES_KEY,
|
||||
AccountConfig::WITH_SIGNATURE_ID,
|
||||
AccountConfig::WITH_FILE_LINKS_KEY,
|
||||
AccountConfig::WITH_SUBMITTER_TIMEZONE_KEY])
|
||||
|
||||
last_submitter = submission.submitters.select(&:completed_at).max_by(&:completed_at)
|
||||
|
||||
with_signature_id = configs.find { |c| c.key == AccountConfig::WITH_SIGNATURE_ID }&.value == true
|
||||
with_file_links = configs.find { |c| c.key == AccountConfig::WITH_FILE_LINKS_KEY }&.value == true
|
||||
with_audit_values = configs.find { |c| c.key == AccountConfig::WITH_AUDIT_VALUES_KEY }&.value != false
|
||||
with_submitter_timezone = configs.find { |c| c.key == AccountConfig::WITH_SUBMITTER_TIMEZONE_KEY }&.value == true
|
||||
|
||||
@@ -392,7 +394,12 @@ module Submissions
|
||||
Array.wrap(value).map do |uuid|
|
||||
attachment = submitter.attachments.find { |a| a.uuid == uuid }
|
||||
|
||||
link = r.submissions_preview_url(submission.slug, **Docuseal.default_url_options)
|
||||
link =
|
||||
if with_file_links
|
||||
ActiveStorage::Blob.proxy_url(attachment.blob)
|
||||
else
|
||||
r.submissions_preview_url(submission.slug, **Docuseal.default_url_options)
|
||||
end
|
||||
|
||||
{ link:, text: "#{attachment.filename}\n", style: :link }
|
||||
end,
|
||||
|
||||
@@ -15,9 +15,11 @@ module Submissions
|
||||
configs = submission.account.account_configs.where(key: [AccountConfig::FLATTEN_RESULT_PDF_KEY,
|
||||
AccountConfig::WITH_SIGNATURE_ID,
|
||||
AccountConfig::WITH_SUBMITTER_TIMEZONE_KEY,
|
||||
AccountConfig::WITH_FILE_LINKS_KEY,
|
||||
AccountConfig::WITH_SIGNATURE_ID_REASON_KEY])
|
||||
|
||||
with_signature_id = configs.find { |c| c.key == AccountConfig::WITH_SIGNATURE_ID }&.value == true
|
||||
with_file_links = configs.find { |c| c.key == AccountConfig::WITH_FILE_LINKS_KEY }&.value == true
|
||||
is_flatten = configs.find { |c| c.key == AccountConfig::FLATTEN_RESULT_PDF_KEY }&.value != false
|
||||
with_submitter_timezone = configs.find { |c| c.key == AccountConfig::WITH_SUBMITTER_TIMEZONE_KEY }&.value == true
|
||||
with_signature_id_reason =
|
||||
@@ -34,7 +36,7 @@ module Submissions
|
||||
submitters.preload(attachments_attachments: :blob).each_with_index do |s, index|
|
||||
GenerateResultAttachments.fill_submitter_fields(s, submission.account, pdfs_index,
|
||||
with_signature_id:, is_flatten:, with_headings: index.zero?,
|
||||
with_submitter_timezone:,
|
||||
with_submitter_timezone:, with_file_links:,
|
||||
with_signature_id_reason:)
|
||||
end
|
||||
|
||||
|
||||
@@ -139,12 +139,14 @@ module Submissions
|
||||
def generate_pdfs(submitter)
|
||||
configs = submitter.account.account_configs.where(key: [AccountConfig::FLATTEN_RESULT_PDF_KEY,
|
||||
AccountConfig::WITH_SIGNATURE_ID,
|
||||
AccountConfig::WITH_FILE_LINKS_KEY,
|
||||
AccountConfig::WITH_SUBMITTER_TIMEZONE_KEY,
|
||||
AccountConfig::WITH_SIGNATURE_ID_REASON_KEY])
|
||||
|
||||
with_signature_id = configs.find { |c| c.key == AccountConfig::WITH_SIGNATURE_ID }&.value == true
|
||||
is_flatten = configs.find { |c| c.key == AccountConfig::FLATTEN_RESULT_PDF_KEY }&.value != false
|
||||
with_submitter_timezone = configs.find { |c| c.key == AccountConfig::WITH_SUBMITTER_TIMEZONE_KEY }&.value == true
|
||||
with_file_links = configs.find { |c| c.key == AccountConfig::WITH_FILE_LINKS_KEY }&.value == true
|
||||
with_signature_id_reason =
|
||||
configs.find { |c| c.key == AccountConfig::WITH_SIGNATURE_ID_REASON_KEY }&.value != false
|
||||
|
||||
@@ -192,11 +194,12 @@ module Submissions
|
||||
|
||||
fill_submitter_fields(submitter, submitter.account, pdfs_index, with_signature_id:, is_flatten:,
|
||||
with_submitter_timezone:,
|
||||
with_file_links:,
|
||||
with_signature_id_reason:)
|
||||
end
|
||||
|
||||
def fill_submitter_fields(submitter, account, pdfs_index, with_signature_id:, is_flatten:, with_headings: nil,
|
||||
with_submitter_timezone: false, with_signature_id_reason: true)
|
||||
with_submitter_timezone: false, with_signature_id_reason: true, with_file_links: nil)
|
||||
cell_layouter = HexaPDF::Layout::TextLayouter.new(text_valign: :center, text_align: :center)
|
||||
|
||||
attachments_data_cache = {}
|
||||
@@ -466,6 +469,13 @@ module Submissions
|
||||
|
||||
diff = ((area['h'] * height) / 2) - (lines.sum(&:height) / 2)
|
||||
|
||||
url =
|
||||
if with_file_links
|
||||
ActiveStorage::Blob.proxy_url(attachment.blob)
|
||||
else
|
||||
r.submissions_preview_url(submission.slug, **Docuseal.default_url_options)
|
||||
end
|
||||
|
||||
page[:Annots] << pdf.add(
|
||||
{
|
||||
Type: :Annot, Subtype: :Link,
|
||||
@@ -477,8 +487,7 @@ module Submissions
|
||||
height - (area['y'] * height) - lines[..next_index].sum(&:height) +
|
||||
height_diff - (height_diff.zero? ? diff : 0)
|
||||
],
|
||||
A: { Type: :Action, S: :URI,
|
||||
URI: r.submissions_preview_url(submission.slug, **Docuseal.default_url_options) }
|
||||
A: { Type: :Action, S: :URI, URI: url }
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user