mirror of
https://github.com/docusealco/docuseal.git
synced 2026-06-23 04:10:11 +00:00
Merge from docusealco/wip
This commit is contained in:
+1
-1
@@ -271,7 +271,7 @@ GEM
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
jmespath (1.6.2)
|
||||
json (2.19.8)
|
||||
json (2.19.9)
|
||||
jwt (3.2.0)
|
||||
base64
|
||||
language_server-protocol (3.17.0.5)
|
||||
|
||||
@@ -25,7 +25,10 @@ class PreviewDocumentPageController < ActionController::API
|
||||
preview_image = attachment.preview_images.joins(:blob)
|
||||
.find_by(blob: { filename: ["#{params[:id]}.png", "#{params[:id]}.jpg"] })
|
||||
|
||||
return redirect_to preview_image.url, allow_other_host: true if preview_image
|
||||
if preview_image
|
||||
return redirect_to preview_image.url(time: ActiveStorage::Attachment.service_url_time),
|
||||
allow_other_host: true
|
||||
end
|
||||
|
||||
file_path =
|
||||
if attachment.service.name == :disk
|
||||
@@ -37,7 +40,7 @@ class PreviewDocumentPageController < ActionController::API
|
||||
preview_image =
|
||||
Templates::ProcessDocument.generate_pdf_preview_from_file(attachment, file_path, params[:id].to_i)
|
||||
|
||||
redirect_to preview_image.url, allow_other_host: true
|
||||
redirect_to preview_image.url(time: ActiveStorage::Attachment.service_url_time), allow_other_host: true
|
||||
end
|
||||
|
||||
def find_or_create_document_tempfile_path(attachment)
|
||||
|
||||
@@ -108,12 +108,16 @@ class StartFormController < ApplicationController
|
||||
end
|
||||
|
||||
def can_resubmit?(submitter)
|
||||
submitter.completed_at? && submitter.completed_at > 14.days.ago &&
|
||||
%w[api embed mcp].exclude?(submitter.submission.source) &&
|
||||
submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false
|
||||
end
|
||||
|
||||
def authorize_start!
|
||||
return redirect_to submit_form_path(@resubmit_submitter.slug) if @resubmit_submitter && @template.archived_at?
|
||||
return redirect_to start_form_path(@template.slug) if @template.archived_at?
|
||||
is_archived = @template.archived_at? || @template.account.archived_at?
|
||||
|
||||
return redirect_to submit_form_path(@resubmit_submitter.slug) if @resubmit_submitter && is_archived
|
||||
return redirect_to start_form_path(@template.slug) if is_archived
|
||||
|
||||
return if @resubmit_submitter
|
||||
return if @template.shared_link? || (current_user && current_ability.can?(:read, @template))
|
||||
|
||||
@@ -7,7 +7,8 @@ class SubmitFormDeclineController < ApplicationController
|
||||
before_action :load_submitter
|
||||
|
||||
def create
|
||||
return redirect_to submit_form_path(@submitter.slug) if @submitter.declined_at? ||
|
||||
return redirect_to submit_form_path(@submitter.slug) if declining_disabled? ||
|
||||
@submitter.declined_at? ||
|
||||
@submitter.completed_at? ||
|
||||
@submitter.submission.archived_at? ||
|
||||
@submitter.submission.expired? ||
|
||||
@@ -35,6 +36,10 @@ class SubmitFormDeclineController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def declining_disabled?
|
||||
@submitter.account.account_configs.find_by(key: AccountConfig::ALLOW_TO_DECLINE_KEY)&.value == false
|
||||
end
|
||||
|
||||
def load_submitter
|
||||
@submitter = Submitter.find_by!(slug: params[:submit_form_slug])
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ class SubmittersController < ApplicationController
|
||||
def update
|
||||
submission = @submitter.submission
|
||||
|
||||
if @submitter.submission_events.exists?(event_type: 'start_form') || submission.archived_at? || submission.expired?
|
||||
unless submitter_editable?(submission)
|
||||
return redirect_back fallback_location: submission_path(submission), alert: I18n.t('submitter_cannot_be_updated')
|
||||
end
|
||||
|
||||
@@ -48,6 +48,12 @@ class SubmittersController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def submitter_editable?(submission)
|
||||
!@submitter.submission_events.exists?(event_type: 'start_form') &&
|
||||
!@submitter.completed_at? && !@submitter.declined_at? &&
|
||||
!submission.archived_at? && !submission.expired? && !submission.template&.archived_at?
|
||||
end
|
||||
|
||||
def maybe_resend_email_sms(submitter, params)
|
||||
if params[:send_email] == '1' && submitter.email.present?
|
||||
is_sent_recently = Docuseal.multitenant? &&
|
||||
|
||||
@@ -5,6 +5,8 @@ class SubmittersResubmitController < ApplicationController
|
||||
|
||||
def update
|
||||
return redirect_to submit_form_path(slug: @submitter.slug) if @submitter.email != current_user.email
|
||||
return redirect_to submit_form_path(slug: @submitter.slug) if @submitter.completed_at.blank? ||
|
||||
@submitter.completed_at < 1.month.ago
|
||||
|
||||
submission = @submitter.account.submissions.new(created_by_user: current_user,
|
||||
submitters_order: :preserved,
|
||||
|
||||
@@ -10,7 +10,7 @@ class TemplateDocumentsModifyController < ApplicationController
|
||||
params.require(:documents).map do |item|
|
||||
item.permit(:attachment_uuid,
|
||||
pages: [:attachment_uuid, :page, :rotate,
|
||||
{ redact: [%i[x y w h]], replaced_page: %i[attachment_uuid page] }]).to_h
|
||||
{ redact: [%i[x y w h color]], replaced_page: %i[attachment_uuid page] }]).to_h
|
||||
end
|
||||
|
||||
Templates::ModifyDocuments.call(@template, documents_layout)
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
<div
|
||||
v-for="(rect, rectIndex) in page.redact"
|
||||
:key="`redact-${rectIndex}`"
|
||||
class="absolute bg-black"
|
||||
class="absolute"
|
||||
:class="rect.color === 'white' ? 'bg-white' : 'bg-black'"
|
||||
:style="{
|
||||
left: `${rect.x * 100}%`,
|
||||
top: `${rect.y * 100}%`,
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
<div
|
||||
v-for="(rect, rectIndex) in redactRects"
|
||||
:key="`rect-${rectIndex}`"
|
||||
class="absolute bg-black pointer-events-none"
|
||||
class="absolute pointer-events-none"
|
||||
:class="color === 'white' ? 'bg-white' : 'bg-black'"
|
||||
:style="{
|
||||
left: `${rect.x * 100}%`,
|
||||
top: `${rect.y * 100}%`,
|
||||
@@ -47,6 +48,26 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-56 flex-none border-l px-4 py-4 space-y-2">
|
||||
<div class="flex items-center justify-between mb-1">
|
||||
<span class="text-sm pl-1">{{ t('color') }}</span>
|
||||
<div
|
||||
class="join rounded"
|
||||
style="height: 28px"
|
||||
>
|
||||
<button
|
||||
v-for="option in colors"
|
||||
:key="option"
|
||||
class="btn btn-sm join-item !h-7 !min-h-0 bg-white input-bordered hover:border-base-content/20 hover:bg-base-100/50 px-2"
|
||||
:class="{ '!bg-base-200': color === option }"
|
||||
@click.prevent="color = option"
|
||||
>
|
||||
<span
|
||||
class="block w-10 h-4 border border-base-content/30"
|
||||
:style="{ backgroundColor: option }"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-sm w-full justify-start normal-case font-normal rounded disabled:bg-base-300"
|
||||
:disabled="!hasRedactions && !wasReset"
|
||||
@@ -122,11 +143,15 @@ export default {
|
||||
selectedNodes: {},
|
||||
freeRects: [],
|
||||
rects: [],
|
||||
color: 'black',
|
||||
wasReset: false,
|
||||
marquee: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
colors () {
|
||||
return ['black', 'white']
|
||||
},
|
||||
rotate () {
|
||||
return this.page.rotate || 0
|
||||
},
|
||||
@@ -186,6 +211,10 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
if ((this.page.redact || []).some((rect) => rect.color === 'white')) {
|
||||
this.color = 'white'
|
||||
}
|
||||
|
||||
if (this.imagePage) {
|
||||
this.rects = (this.page.redact || []).map((rect) => ({ ...rect }))
|
||||
|
||||
@@ -238,7 +267,17 @@ export default {
|
||||
return { x, y }
|
||||
},
|
||||
apply () {
|
||||
this.$emit('apply', this.redactRects)
|
||||
const rects = this.redactRects.map((rect) => {
|
||||
const next = { x: rect.x, y: rect.y, w: rect.w, h: rect.h }
|
||||
|
||||
if (this.color === 'white') {
|
||||
next.color = 'white'
|
||||
}
|
||||
|
||||
return next
|
||||
})
|
||||
|
||||
this.$emit('apply', rects)
|
||||
},
|
||||
reset () {
|
||||
this.wasReset = true
|
||||
|
||||
@@ -111,6 +111,7 @@ const en = {
|
||||
flip_horizontal: 'Flip horizontal',
|
||||
flip_vertical: 'Flip vertical',
|
||||
there_is_no_text_to_redact_on_this_page: 'This page contains only images. Redact tool can be used only with text pages',
|
||||
color: 'Color',
|
||||
reset: 'Reset',
|
||||
upload_to_document: 'Upload to "{document}"',
|
||||
replace_existing_document: 'Replace existing document',
|
||||
@@ -351,6 +352,7 @@ const es = {
|
||||
flip_horizontal: 'Voltear horizontal',
|
||||
flip_vertical: 'Voltear vertical',
|
||||
there_is_no_text_to_redact_on_this_page: 'Esta página contiene solo imágenes. La herramienta de censura solo puede usarse con páginas de texto',
|
||||
color: 'Color',
|
||||
reset: 'Restablecer',
|
||||
upload_to_document: 'Subir a "{document}"',
|
||||
replace_existing_document: 'Reemplazar documento existente',
|
||||
@@ -597,6 +599,7 @@ const it = {
|
||||
flip_horizontal: 'Rifletti orizzontale',
|
||||
flip_vertical: 'Rifletti verticale',
|
||||
there_is_no_text_to_redact_on_this_page: 'Questa pagina contiene solo immagini. Lo strumento di oscuramento può essere usato solo con pagine di testo',
|
||||
color: 'Colore',
|
||||
reset: 'Reimposta',
|
||||
upload_to_document: 'Carica in "{document}"',
|
||||
replace_existing_document: 'Sostituisci documento esistente',
|
||||
@@ -837,6 +840,7 @@ const pt = {
|
||||
flip_horizontal: 'Inverter horizontal',
|
||||
flip_vertical: 'Inverter vertical',
|
||||
there_is_no_text_to_redact_on_this_page: 'Esta página contém apenas imagens. A ferramenta de censura só pode ser usada com páginas de texto',
|
||||
color: 'Cor',
|
||||
reset: 'Redefinir',
|
||||
upload_to_document: 'Enviar para "{document}"',
|
||||
replace_existing_document: 'Substituir documento existente',
|
||||
@@ -1083,6 +1087,7 @@ const fr = {
|
||||
flip_horizontal: 'Miroir horizontal',
|
||||
flip_vertical: 'Miroir vertical',
|
||||
there_is_no_text_to_redact_on_this_page: 'Cette page ne contient que des images. L\'outil de caviardage ne peut être utilisé qu\'avec des pages de texte',
|
||||
color: 'Couleur',
|
||||
reset: 'Réinitialiser',
|
||||
upload_to_document: 'Téléverser dans "{document}"',
|
||||
replace_existing_document: 'Remplacer le document existant',
|
||||
@@ -1326,6 +1331,7 @@ const de = {
|
||||
flip_horizontal: 'Horizontal spiegeln',
|
||||
flip_vertical: 'Vertikal spiegeln',
|
||||
there_is_no_text_to_redact_on_this_page: 'Diese Seite enthält nur Bilder. Das Schwärzungswerkzeug kann nur mit Textseiten verwendet werden',
|
||||
color: 'Farbe',
|
||||
reset: 'Zurücksetzen',
|
||||
upload_to_document: 'In "{document}" hochladen',
|
||||
replace_existing_document: 'Vorhandenes Dokument ersetzen',
|
||||
@@ -1569,6 +1575,7 @@ const nl = {
|
||||
flip_horizontal: 'Horizontaal spiegelen',
|
||||
flip_vertical: 'Verticaal spiegelen',
|
||||
there_is_no_text_to_redact_on_this_page: 'Deze pagina bevat alleen afbeeldingen. De redactietool kan alleen worden gebruikt met tekstpagina\'s',
|
||||
color: 'Kleur',
|
||||
reset: 'Opnieuw instellen',
|
||||
upload_to_document: 'Uploaden naar "{document}"',
|
||||
replace_existing_document: 'Bestaand document vervangen',
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<div class="inline-flex items-stretch replace-document-control">
|
||||
<div
|
||||
class="inline-flex items-stretch replace-document-control"
|
||||
:class="{ 'opacity-100': isLoading }"
|
||||
>
|
||||
<label
|
||||
:for="inputId"
|
||||
class="btn btn-neutral btn-xs transition-none replace-document-button"
|
||||
|
||||
@@ -7,7 +7,9 @@ class SendSubmitterInvitationEmailJob
|
||||
submitter = Submitter.find(params['submitter_id'])
|
||||
|
||||
return if submitter.completed_at?
|
||||
return if submitter.declined_at?
|
||||
return if submitter.submission.archived_at?
|
||||
return if submitter.submission.expired?
|
||||
return if submitter.template&.archived_at?
|
||||
return if submitter.submission.source == 'invite' && !Accounts.can_send_emails?(submitter.account, on_events: true)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<% if signature %>
|
||||
<div class="flex justify-center mb-4 relative">
|
||||
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_signature_path, method: :delete, class: 'right-0 top-0 absolute link' %>
|
||||
<img src="<%= signature.url %>" style="height: 130px; width: 100%; object-fit: contain;">
|
||||
<img src="<%= signature.url(time: ActiveStorage::Attachment.service_url_time) %>" style="height: 130px; width: 100%; object-fit: contain;">
|
||||
</div>
|
||||
<% end %>
|
||||
<a href="<%= edit_user_signature_path %>" data-turbo-frame="modal" class="base-button w-full">
|
||||
@@ -49,7 +49,7 @@
|
||||
<% if initials %>
|
||||
<div class="flex justify-center mb-4 relative">
|
||||
<%= button_to button_title(title: t('remove'), disabled_with: t('removing')), user_initials_path, method: :delete, class: 'right-0 top-0 absolute link' %>
|
||||
<img src="<%= initials.url %>" style="height: 130px; width: 100%; object-fit: contain;">
|
||||
<img src="<%= initials.url(time: ActiveStorage::Attachment.service_url_time) %>" style="height: 130px; width: 100%; object-fit: contain;">
|
||||
</div>
|
||||
<% end %>
|
||||
<a href="<%= edit_user_initials_path %>" data-turbo-frame="modal" class="base-button w-full">
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<%= button_to button_title(title: t('send_copy_to_email'), disabled_with: t('sending'), icon: svg_icon('mail_forward', class: 'w-6 h-6')), send_submission_email_index_path, params: { template_slug: @template.slug, email: params[:email] }, class: 'base-button w-full' %>
|
||||
</toggle-submit>
|
||||
<% end %>
|
||||
<% if Templates.filter_undefined_submitters(@template.submitters).size == 1 && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && @template.shared_link? %>
|
||||
<% if Templates.filter_undefined_submitters(@template.submitters).size == 1 && %w[api embed mcp].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && @template.shared_link? %>
|
||||
<toggle-submit class="block">
|
||||
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@template.slug), params: { submitter: params.permit(:name, :email, :phone).compact_blank, resubmit: true }, method: :put, class: 'white-button w-full' %>
|
||||
</toggle-submit>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% is_narrow = area['h'].to_f.positive? && ((area['w'].to_f * local_assigns[:page_width]) / (area['h'].to_f * local_assigns[:page_height])) > 4.5 %>
|
||||
<div class="flex justify-between w-full h-full gap-1 <%= is_narrow && (local_assigns[:with_signature_id] || field.dig('preferences', 'reason_field_uuid').present?) ? 'flex-row' : 'flex-col' %>">
|
||||
<div class="flex overflow-hidden <%= is_narrow && (local_assigns[:with_signature_id] || field.dig('preferences', 'reason_field_uuid').present?) ? 'w-1/2' : 'flex-grow' %>" style="min-height: 50%">
|
||||
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" alt="<%= field['name'].presence || field['title'].presence || field['type'] %>">
|
||||
<img class="object-contain mx-auto" src="<%= attachments_index[value].url(time: ActiveStorage::Attachment.service_url_time) %>" alt="<%= field['name'].presence || field['title'].presence || field['type'] %>">
|
||||
</div>
|
||||
<% if (local_assigns[:with_signature_id] || field.dig('preferences', 'reason_field_uuid').present?) && attachment = attachments_index[value] %>
|
||||
<div class="text-[1vw] lg:text-[0.55rem] lg:leading-[0.65rem] <%= is_narrow ? 'w-1/2' : 'w-full' %>">
|
||||
@@ -35,7 +35,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<% elsif field['type'].in?(['image', 'initials', 'stamp', 'kba']) && attachments_index[value].image? %>
|
||||
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'].presence || field['title'].presence || field['type'] %>">
|
||||
<img class="object-contain mx-auto" src="<%= attachments_index[value].url(time: ActiveStorage::Attachment.service_url_time) %>" loading="lazy" alt="<%= field['name'].presence || field['title'].presence || field['type'] %>">
|
||||
<% elsif field['type'].in?(['file', 'payment', 'image']) %>
|
||||
<autosize-field></autosize-field>
|
||||
<div class="px-0.5 flex flex-col justify-center">
|
||||
|
||||
@@ -83,11 +83,12 @@
|
||||
<div class="overflow-y-auto overflow-x-hidden hidden lg:block w-52 flex-none pr-3 mt-0.5 pt-0.5" tabindex="0">
|
||||
<% values = @submission.submitters.reduce({}) { |acc, sub| acc.merge(sub.values) } %>
|
||||
<% schema = Submissions.filtered_conditions_schema(@submission, values:) %>
|
||||
<% service_url_time = ActiveStorage::Attachment.service_url_time %>
|
||||
<% schema.each do |item| %>
|
||||
<% document = @submission.schema_documents.find { |a| item['attachment_uuid'] == a.uuid } %>
|
||||
<% if document.preview_images.first %>
|
||||
<scroll-to data-selector-id="page-<%= document.uuid %>-0" class="block cursor-pointer">
|
||||
<img src="<%= (document.preview_images.find { |e| e.filename.base.to_i.zero? } || document.preview_images.first).url %>" width="<%= document.preview_images.first.metadata['width'] %>" height="<%= document.preview_images.first.metadata['height'] %>" class="rounded border" loading="lazy" alt="<%= item['name'].presence || document.filename.base %>">
|
||||
<img src="<%= (document.preview_images.find { |e| e.filename.base.to_i.zero? } || document.preview_images.first).url(time: service_url_time) %>" width="<%= document.preview_images.first.metadata['width'] %>" height="<%= document.preview_images.first.metadata['height'] %>" class="rounded border" loading="lazy" alt="<%= item['name'].presence || document.filename.base %>">
|
||||
<div class="pb-2 pt-1.5 text-center" dir="auto">
|
||||
<%= item['name'].presence || document.filename.base %>
|
||||
</div>
|
||||
@@ -111,7 +112,7 @@
|
||||
<% (document.metadata.dig('pdf', 'number_of_pages') || (document.preview_images.loaded? ? preview_images_index.size : document.preview_images.size)).times do |index| %>
|
||||
<% page = preview_images_index[index] || page_blob_struct.new(metadata: lazyload_metadata, url: preview_document_page_path(document.signed_key, "#{index}#{Templates::ProcessDocument::PREVIEW_FORMAT}")) %>
|
||||
<page-container id="<%= "page-#{document.uuid}-#{index}" %>" class="block before:border before:absolute before:top-0 before:bottom-0 before:left-0 before:right-0 before:rounded relative mb-4" style="container-type: size; aspect-ratio: <%= width = page.metadata['width'] %> / <%= height = page.metadata['height'] %>">
|
||||
<img loading="lazy" src="<%= page.url %>" width="<%= width %>" class="rounded" height="<%= height %>" alt="<%= "#{item['name']} - #{t('page')} #{index + 1}" %>">
|
||||
<img loading="lazy" src="<%= page.is_a?(ActiveStorage::Attachment) ? page.url(time: service_url_time) : page.url %>" width="<%= width %>" class="rounded" height="<%= height %>" alt="<%= "#{item['name']} - #{t('page')} #{index + 1}" %>">
|
||||
<div class="top-0 bottom-0 left-0 right-0 absolute">
|
||||
<% document_annots_index[index]&.each do |annot| %>
|
||||
<%= render 'submissions/annotation', annot: %>
|
||||
@@ -267,11 +268,11 @@
|
||||
<% if field['type'].in?(%w[signature initials]) %>
|
||||
<div class="w-full bg-base-300 py-1">
|
||||
<% img_height = attachments_index[value].metadata['height'] %>
|
||||
<img class="object-contain mx-auto" style="<%= 'max-' if img_height %>height: <%= field['type'] == 'signature' ? 100 : 50 %>px" height="<%= img_height %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
||||
<img class="object-contain mx-auto" style="<%= 'max-' if img_height %>height: <%= field['type'] == 'signature' ? 100 : 50 %>px" height="<%= img_height %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url(time: service_url_time) %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
||||
</div>
|
||||
<% elsif field['type'].in?(['image', 'stamp', 'kba']) && attachments_index[value].image? %>
|
||||
<% img_height = attachments_index[value].metadata['height'] %>
|
||||
<img class="object-contain mx-auto" style="<%= 'max-' if img_height %>height: 200px" height="<%= img_height %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
||||
<img class="object-contain mx-auto" style="<%= 'max-' if img_height %>height: 200px" height="<%= img_height %>" width="<%= attachments_index[value].metadata['width'] %>" src="<%= attachments_index[value].url(time: service_url_time) %>" loading="lazy" alt="<%= field['name'] || field['title'] || field['type'] %>">
|
||||
<% elsif field['type'].in?(['file', 'payment', 'image']) %>
|
||||
<div class="flex flex-col justify-center">
|
||||
<% Array.wrap(value).each do |val| %>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<% undefined_submitters = Templates.filter_undefined_submitters(@submitter.submission.template_submitters) %>
|
||||
<% if undefined_submitters.size == 1 && undefined_submitters.first['uuid'] == @submitter.uuid && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && @submitter.template && !@submitter.template.archived_at? %>
|
||||
<% if undefined_submitters.size == 1 && undefined_submitters.first['uuid'] == @submitter.uuid && @submitter.completed_at? && @submitter.completed_at > 14.days.ago && %w[api embed mcp].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && @submitter.template && !@submitter.template.archived_at? %>
|
||||
<div class="divider uppercase"><%= t('or') %></div>
|
||||
<toggle-submit class="block">
|
||||
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), resubmit_form_path, params: { resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<% values = @submitter.submission.submitters.reduce({}) { |acc, sub| acc.merge(sub.values) } %>
|
||||
<% submitters_index = @submitter.submission.submitters.index_by(&:uuid) %>
|
||||
<% page_blob_struct = Struct.new(:url, :metadata) %>
|
||||
<% service_url_time = ActiveStorage::Attachment.service_url_time %>
|
||||
<% schema = Submissions.filtered_conditions_schema(@submitter.submission, values:, include_submitter_uuid: @submitter.uuid) %>
|
||||
<% font_scale = 1000.0 / PdfUtils::US_LETTER_W %>
|
||||
<% decline_modal_id = nil %>
|
||||
@@ -138,7 +139,7 @@
|
||||
<% (document.metadata.dig('pdf', 'number_of_pages') || (document.preview_images.loaded? ? preview_images_index.size : document.preview_images.size)).times do |index| %>
|
||||
<% page = preview_images_index[index] || page_blob_struct.new(metadata: lazyload_metadata, url: preview_document_page_path(document.signed_key, "#{index}#{Templates::ProcessDocument::PREVIEW_FORMAT}")) %>
|
||||
<page-container class="block relative my-4 shadow-md" style="container-type: size; aspect-ratio: <%= width = page.metadata['width'] %> / <%= height = page.metadata['height'] %>">
|
||||
<img loading="lazy" src="<%= page.url %>" width="<%= width %>" height="<%= height %>" alt="<%= "#{item['name']} - #{t('page')} #{index + 1}" %>">
|
||||
<img loading="lazy" src="<%= page.is_a?(ActiveStorage::Attachment) ? page.url(time: service_url_time) : page.url %>" width="<%= width %>" height="<%= height %>" alt="<%= "#{item['name']} - #{t('page')} #{index + 1}" %>">
|
||||
<div id="page-<%= [document.uuid, index].join('-') %>" class="top-0 bottom-0 left-0 right-0 absolute">
|
||||
<% if annots = document_annots_index[index] %>
|
||||
<%= render 'submit_form/annotations', annots: %>
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
<% if Addressable::URI.parse(params[:url]).host == 'docuseal-website.s3.amazonaws.com' %>
|
||||
<div class="h-screen">
|
||||
<div class="text-center p-8 h-full flex items-center justify-center">
|
||||
<div>
|
||||
<%= render 'shared/logo', width: 50, height: 50, class: 'mx-auto animate-bounce' %>
|
||||
<span>
|
||||
<%= t('processing') %>...
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<submit-form>
|
||||
<%= form_for '', url: templates_upload_path, method: :post, class: 'hidden' do %>
|
||||
<button type="submit"></button>
|
||||
<input name="url" value="<%= params[:url] %>">
|
||||
<input name="filename" value="<%= params[:filename] %>">
|
||||
<% end %>
|
||||
</submit-form>
|
||||
<% else %>
|
||||
<confirm-upload>
|
||||
<div class="h-screen">
|
||||
<div class="text-center p-8 h-full flex items-center justify-center">
|
||||
@@ -28,3 +47,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</confirm-upload>
|
||||
<% end %>
|
||||
|
||||
@@ -27,6 +27,8 @@ module DocuSeal
|
||||
|
||||
config.active_storage.analyzers = []
|
||||
|
||||
config.active_storage.previewers = []
|
||||
|
||||
config.active_storage.variant_processor = :disabled
|
||||
|
||||
config.active_storage.content_types_to_serve_as_binary += %w[
|
||||
|
||||
@@ -5,6 +5,14 @@ ActiveSupport.on_load(:active_storage_attachment) do
|
||||
|
||||
has_many_attached :preview_images
|
||||
|
||||
def self.service_url_time
|
||||
return unless Docuseal.multitenant?
|
||||
|
||||
now = Time.current
|
||||
|
||||
now.min < 30 ? now.beginning_of_hour : now.beginning_of_hour + 30.minutes
|
||||
end
|
||||
|
||||
def signed_uuid
|
||||
@signed_uuid ||= ApplicationRecord.signed_id_verifier.generate(uuid, expires_in: 6.hours, purpose: :attachment)
|
||||
end
|
||||
|
||||
+7
-4
@@ -737,7 +737,7 @@ class Pdfium
|
||||
left = rect['x'].to_f * width
|
||||
top = height - (rect['y'].to_f * height)
|
||||
|
||||
[left, top - (rect['h'].to_f * height), left + (rect['w'].to_f * width), top]
|
||||
[left, top - (rect['h'].to_f * height), left + (rect['w'].to_f * width), top, rect['color']]
|
||||
end
|
||||
|
||||
unwrap_form_objects(rect_bounds)
|
||||
@@ -982,7 +982,9 @@ class Pdfium
|
||||
end
|
||||
|
||||
def draw_redaction_rects(rect_bounds)
|
||||
rect_bounds.each do |left, bottom, right, top|
|
||||
rect_bounds.each do |left, bottom, right, top, color|
|
||||
next if color == 'white'
|
||||
|
||||
rect_object = Pdfium.FPDFPageObj_CreateNewRect(left, bottom, right - left, top - bottom)
|
||||
|
||||
raise PdfiumError, 'Failed to create redaction rect' if rect_object.null?
|
||||
@@ -1057,7 +1059,7 @@ class Pdfium
|
||||
a, b, c, d, e, f = matrix
|
||||
det = (a * d) - (b * c)
|
||||
|
||||
rect_bounds.filter_map do |left, bottom, right, top|
|
||||
rect_bounds.filter_map do |left, bottom, right, top, color|
|
||||
corners = [[left, bottom], [right, bottom], [left, top], [right, top]].map do |x, y|
|
||||
u = ((d * (x - e)) - (c * (y - f))) / det
|
||||
v = ((a * (y - f)) - (b * (x - e))) / det
|
||||
@@ -1075,7 +1077,8 @@ class Pdfium
|
||||
|
||||
[px_left, px_top,
|
||||
(xs.max.ceil - px_left).clamp(1, image_width - px_left),
|
||||
(ys.max.ceil - px_top).clamp(1, image_height - px_top)]
|
||||
(ys.max.ceil - px_top).clamp(1, image_height - px_top),
|
||||
color]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -299,19 +299,17 @@ module Templates
|
||||
else image
|
||||
end
|
||||
|
||||
ink = Array.new(image.bands, 0.0)
|
||||
|
||||
pixel_rects.each do |left, top, rect_width, rect_height|
|
||||
image = image.draw_rect(ink, left, top, rect_width, rect_height, fill: true)
|
||||
pixel_rects.each do |left, top, rect_width, rect_height, color|
|
||||
image = image.draw_rect(redaction_ink(image.bands, color), left, top, rect_width, rect_height, fill: true)
|
||||
end
|
||||
|
||||
image.write_to_buffer('.jpg', Q: 50, strip: true)
|
||||
end
|
||||
|
||||
def draw_image_redaction(image, rects)
|
||||
ink = Array.new(image.bands) { |band| band == 3 ? 255.0 : 0.0 }
|
||||
|
||||
rects.each do |rect|
|
||||
ink = redaction_ink(image.bands, rect['color'])
|
||||
|
||||
left = (rect['x'].to_f * image.width).floor.clamp(0, image.width - 1)
|
||||
top = (rect['y'].to_f * image.height).floor.clamp(0, image.height - 1)
|
||||
rect_width = (rect['w'].to_f * image.width).ceil.clamp(1, image.width - left)
|
||||
@@ -323,6 +321,12 @@ module Templates
|
||||
image
|
||||
end
|
||||
|
||||
def redaction_ink(bands, color)
|
||||
value = color == 'white' ? 255.0 : 0.0
|
||||
|
||||
Array.new(bands) { |band| band == 3 ? 255.0 : value }
|
||||
end
|
||||
|
||||
def open_or_build_pdf(attachment, redact: nil, rotate: nil, pdf_size: nil, default_size: nil)
|
||||
data =
|
||||
if attachment.image?
|
||||
|
||||
Reference in New Issue
Block a user