Compare commits

..
13 Commits
Author SHA1 Message Date
Pete Matsyburka 5684baf1e0 add app url var 2024-08-25 16:03:23 +03:00
Pete Matsyburka b6f307690d add combine pdf toggle 2024-08-25 16:03:23 +03:00
Pete Matsyburka 66c44f8ff5 adjust error page 2024-08-25 16:03:23 +03:00
dependabot[bot] 8f3592c481 Bump rexml from 3.3.3 to 3.3.6 in the bundler group across 1 directory
Bumps the bundler group with 1 update in the / directory: [rexml](https://github.com/ruby/rexml).


Updates `rexml` from 3.3.3 to 3.3.6
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.3.3...v3.3.6)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
  dependency-group: bundler
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-25 16:03:23 +03:00
Pete Matsyburka dc8b1e0741 rescue error 2024-08-25 16:03:23 +03:00
Pete Matsyburka b806a6afc5 disable decline button 2024-08-25 16:03:23 +03:00
Pete Matsyburka d43f8f4dd8 add event data 2024-08-25 16:03:23 +03:00
Pete Matsyburka 37c9bf5741 add reply to 2024-08-25 16:03:23 +03:00
Pete Matsyburka a0d37f516f add audit document id 2024-08-25 16:03:23 +03:00
Pete Matsyburka 2764a18252 decline submission 2024-08-25 16:03:23 +03:00
Pete Matsyburka 96cf228e74 fix upload signature 2024-08-25 16:03:23 +03:00
Pete Matsyburka ff6ff3a51e adjust template resp 2024-08-25 16:03:23 +03:00
Pete Matsyburka 9472a6b5b0 allow to upload initial 2024-08-25 16:03:23 +03:00
45 changed files with 591 additions and 93 deletions

No files matched your search

+1 -1
View File
@@ -434,7 +434,7 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
retriable (3.1.2)
rexml (3.3.3)
rexml (3.3.6)
strscan
rotp (6.3.0)
rqrcode (2.2.0)
@@ -15,6 +15,7 @@ class AccountConfigsController < ApplicationController
AccountConfig::FORCE_SSO_AUTH_KEY,
AccountConfig::FLATTEN_RESULT_PDF_KEY,
AccountConfig::WITH_SIGNATURE_ID,
AccountConfig::COMBINE_PDF_RESULT_KEY,
AccountConfig::REQUIRE_SIGNING_REASON_KEY
].freeze
@@ -11,7 +11,8 @@ module Api
params[:before] = Time.zone.at(params[:before].to_i) if params[:before].present?
submitters = paginate(
submitters.preload(template: :folder, submission: [:submitters, { audit_trail_attachment: :blob }],
submitters.preload(template: :folder, submission: [:submitters, { audit_trail_attachment: :blob,
combined_document_attachment: :blob }],
documents_attachments: :blob, attachments_attachments: :blob),
field: :completed_at
)
@@ -19,6 +19,7 @@ module Api
submissions = paginate(submissions.preload(:created_by_user, :submitters,
template: :folder,
combined_document_attachment: :blob,
audit_trail_attachment: :blob))
render json: {
@@ -77,6 +77,10 @@ module Api
with_urls: true,
with_events: false,
params:)
rescue Submitters::NormalizeValues::BaseError => e
Rollbar.warning(e) if defined?(Rollbar)
render json: { error: e.message }, status: :unprocessable_entity
end
def submitter_params
+10 -5
View File
@@ -17,11 +17,7 @@ class StartFormController < ApplicationController
def update
return redirect_to start_form_path(@template.slug) if @template.archived_at?
@submitter = Submitter.where(submission: @template.submissions.where(expire_at: Time.current..)
.or(@template.submissions.where(expire_at: nil)).where(archived_at: nil))
.order(id: :desc)
.then { |rel| params[:resubmit].present? ? rel.where(completed_at: nil) : rel }
.find_or_initialize_by(**submitter_params.compact_blank)
@submitter = find_or_initialize_submitter(@template, submitter_params)
if @submitter.completed_at?
redirect_to start_form_completed_path(@template.slug, email: submitter_params[:email])
@@ -56,6 +52,15 @@ class StartFormController < ApplicationController
private
def find_or_initialize_submitter(template, submitter_params)
Submitter.where(submission: template.submissions.where(expire_at: Time.current..)
.or(template.submissions.where(expire_at: nil)).where(archived_at: nil))
.order(id: :desc)
.where(declined_at: nil)
.then { |rel| params[:resubmit].present? ? rel.where(completed_at: nil) : rel }
.find_or_initialize_by(**submitter_params.compact_blank)
end
def assign_submission_attributes(submitter, template)
resubmit_submitter =
if params[:resubmit].present?
@@ -33,7 +33,7 @@ class SubmissionsDownloadController < ApplicationController
return head :not_found
end
if params[:combined]
if params[:combined] == 'true'
url = build_combined_url(submitter)
if url
@@ -15,6 +15,7 @@ class SubmitFormController < ApplicationController
return redirect_to submit_form_completed_path(@submitter.slug) if @submitter.completed_at?
return render :archived if @submitter.submission.template.archived_at? || @submitter.submission.archived_at?
return render :expired if @submitter.submission.expired?
return render :declined if @submitter.declined_at?
Submitters.preload_with_pages(@submitter)
@@ -56,6 +57,8 @@ class SubmitFormController < ApplicationController
return render json: { error: 'Form has been expired.' }, status: :unprocessable_entity
end
return render json: { error: 'Form has been declined.' }, status: :unprocessable_entity if submitter.declined_at?
Submitters::SubmitValues.call(submitter, params, request)
head :ok
@@ -0,0 +1,29 @@
# frozen_string_literal: true
class SubmitFormDeclineController < ApplicationController
skip_before_action :authenticate_user!
skip_authorization_check
def create
submitter = Submitter.find_by!(slug: params[:submit_form_slug])
return redirect_to submit_form_path(submitter.slug) if submitter.declined_at? ||
submitter.completed_at? ||
submitter.submission.archived_at? ||
submitter.submission.expired? ||
submitter.submission.template.archived_at?
ApplicationRecord.transaction do
submitter.update!(declined_at: Time.current)
SubmissionEvents.create_with_tracking_data(submitter, 'decline_form', request, { reason: params[:reason] })
end
user = submitter.submission.created_by_user || submitter.template.author
SubmitterMailer.declined_email(submitter, user).deliver_later!
SendFormDeclinedWebhookRequestJob.perform_async('submitter_id' => submitter.id)
redirect_to submit_form_path(submitter.slug)
end
end
@@ -0,0 +1,37 @@
# frozen_string_literal: true
class SubmitFormDownloadController < ApplicationController
skip_before_action :authenticate_user!
skip_authorization_check
FILES_TTL = 5.minutes
def index
submitter = Submitter.find_by!(slug: params[:submit_form_slug])
return redirect_to submitter_download_index_path(submitter.slug) if submitter.completed_at?
return head :unprocessable_entity if submitter.declined_at? ||
submitter.submission.archived_at? ||
submitter.submission.expired? ||
submitter.submission.template.archived_at?
last_completed_submitter = submitter.submission.submitters
.where.not(id: submitter.id)
.where.not(completed_at: nil)
.max_by(&:completed_at)
attachments =
if last_completed_submitter
Submitters.select_attachments_for_download(last_completed_submitter)
else
submitter.submission.template.schema_documents.preload(:blob)
end
urls = attachments.map do |attachment|
ActiveStorage::Blob.proxy_url(attachment.blob, expires_at: FILES_TTL.from_now.to_i)
end
render json: urls
end
end
@@ -5,6 +5,7 @@ class WebhookPreferencesController < ApplicationController
form.viewed
form.started
form.completed
form.declined
template.created
template.updated
submission.created
@@ -181,6 +181,10 @@ export default {
spread: 140
})
}
if (window.decline_button) {
window.decline_button.setAttribute('disabled', 'true')
}
},
methods: {
sendCopyToEmail () {
@@ -50,6 +50,26 @@
</span>
</a>
</span>
<span
class="tooltip"
:data-tip="t('click_to_upload')"
>
<label
class="btn btn-outline btn-sm font-medium inline-flex flex-nowrap"
>
<IconUpload :width="16" />
<input
:key="uploadImageInputKey"
type="file"
hidden
accept="image/*"
@change="drawImage"
>
<span class="hidden sm:inline">
{{ t('upload') }}
</span>
</label>
</span>
<a
v-if="modelValue || computedPreviousValue"
href="#"
@@ -97,7 +117,7 @@
<img
v-if="modelValue || computedPreviousValue"
:src="attachmentsIndex[modelValue || computedPreviousValue].url"
class="mx-auto bg-white border border-base-300 rounded max-h-72"
class="mx-auto bg-white border border-base-300 rounded max-h-44"
>
<canvas
v-show="!modelValue && !computedPreviousValue"
@@ -120,16 +140,18 @@
<script>
import { cropCanvasAndExportToPNG } from './crop_canvas'
import { IconReload, IconTextSize, IconSignature, IconArrowsDiagonalMinimize2 } from '@tabler/icons-vue'
import { IconReload, IconTextSize, IconUpload, IconSignature, IconArrowsDiagonalMinimize2 } from '@tabler/icons-vue'
import SignaturePad from 'signature_pad'
import AppearsOn from './appears_on'
import MarkdownContent from './markdown_content'
import SignatureStep from './signature_step'
const scale = 3
export default {
name: 'InitialsStep',
components: {
IconUpload,
AppearsOn,
IconReload,
IconTextSize,
@@ -178,7 +200,8 @@ export default {
return {
isInitialsStarted: !!this.previousValue,
isUsePreviousValue: true,
isDrawInitials: false
isDrawInitials: false,
uploadImageInputKey: Math.random().toString()
}
},
computed: {
@@ -229,6 +252,15 @@ export default {
this.intersectionObserver?.disconnect()
},
methods: {
drawOnCanvas: SignatureStep.methods.drawOnCanvas,
drawImage (event) {
this.remove()
this.isInitialsStarted = true
this.drawOnCanvas(event.target.files[0], this.$refs.canvas)
this.uploadImageInputKey = Math.random().toString()
},
remove () {
this.$emit('update:model-value', '')
@@ -569,8 +569,11 @@ export default {
this.remove()
this.isSignatureStarted = true
const file = event.target.files[0]
this.drawOnCanvas(event.target.files[0], this.$refs.canvas)
this.uploadImageInputKey = Math.random().toString()
},
drawOnCanvas (file, canvas) {
if (file && file.type.match('image.*')) {
const reader = new FileReader()
@@ -580,7 +583,6 @@ export default {
img.src = event.target.result
img.onload = () => {
const canvas = this.$refs.canvas
const context = canvas.getContext('2d')
const aspectRatio = img.width / img.height
@@ -615,8 +617,6 @@ export default {
}
reader.readAsDataURL(file)
this.uploadImageInputKey = Math.random().toString()
}
},
maybeSetSignedUuid (signedUuid) {
@@ -15,6 +15,10 @@ class ProcessSubmitterCompletionJob
Submissions::EnsureResultGenerated.call(submitter)
if is_all_completed && submitter.completed_at == submitter.submission.submitters.maximum(:completed_at)
if submitter.submission.account.account_configs.exists?(key: AccountConfig::COMBINE_PDF_RESULT_KEY, value: true)
Submissions::GenerateCombinedAttachment.call(submitter)
end
Submissions::GenerateAuditTrail.call(submitter.submission)
enqueue_completed_emails(submitter)
@@ -0,0 +1,51 @@
# frozen_string_literal: true
class SendFormDeclinedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(params = {})
submitter = Submitter.find(params['submitter_id'])
attempt = params['attempt'].to_i
config = Accounts.load_webhook_config(submitter.submission.account)
url = config&.value.presence
return if url.blank?
preferences = Accounts.load_webhook_preferences(submitter.submission.account)
return if preferences['form.declined'] == false
ActiveStorage::Current.url_options = Docuseal.default_url_options
resp = begin
Faraday.post(url,
{
event_type: 'form.declined',
timestamp: Time.current,
data: Submitters::SerializeForWebhook.call(submitter)
}.to_json,
**EncryptedConfig.find_or_initialize_by(account_id: config.account_id,
key: EncryptedConfig::WEBHOOK_SECRET_KEY)&.value.to_h,
'Content-Type' => 'application/json',
'User-Agent' => USER_AGENT)
rescue Faraday::Error
nil
end
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormDeclinedWebhookRequestJob.perform_in((2**attempt).minutes, {
'submitter_id' => submitter.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
+19 -1
View File
@@ -78,6 +78,24 @@ class SubmitterMailer < ApplicationMailer
subject:)
end
def declined_email(submitter, user)
@current_account = submitter.submission.account
@submitter = submitter
@submission = submitter.submission
@user = user
assign_message_metadata('submitter_declined', @submitter)
I18n.with_locale(submitter.account.locale) do
mail(from: from_address_for_submitter(submitter),
to: user.role == 'integration' ? user.friendly_name.sub(/\+\w+@/, '@') : user.friendly_name,
reply_to: @submitter.friendly_name,
subject: I18n.t(:name_declined_by_submitter,
name: @submission.template.name.truncate(20),
submitter: @submitter.name || @submitter.email || @submitter.phone))
end
end
def documents_copy_email(submitter, to: nil, sig: false)
@current_account = submitter.submission.account
@submitter = submitter
@@ -139,7 +157,7 @@ class SubmitterMailer < ApplicationMailer
total_size = 0
audit_trail_data = nil
if with_audit_log && submitter.submission.audit_trail.present?
if with_audit_log && submitter.submission.audit_trail.present? && documents.first&.name != 'combined_document'
audit_trail_data = submitter.submission.audit_trail.download
total_size = audit_trail_data.size
+1
View File
@@ -40,6 +40,7 @@ class AccountConfig < ApplicationRecord
FLATTEN_RESULT_PDF_KEY = 'flatten_result_pdf'
WITH_SIGNATURE_ID = 'with_signature_id'
REQUIRE_SIGNING_REASON_KEY = 'require_signing_reason'
COMBINE_PDF_RESULT_KEY = 'combine_pdf_result_key'
DEFAULT_VALUES = {
SUBMITTER_INVITATION_EMAIL_KEY => {
+6
View File
@@ -86,4 +86,10 @@ class Submission < ApplicationRecord
ActiveStorage::Blob.proxy_url(audit_trail.blob)
end
alias audit_log_url audit_trail_url
def combined_document_url
return if combined_document.blank?
ActiveStorage::Blob.proxy_url(combined_document.blob)
end
end
+1
View File
@@ -48,6 +48,7 @@ class SubmissionEvent < ApplicationRecord
start_form: 'start_form',
view_form: 'view_form',
complete_form: 'complete_form',
decline_form: 'decline_form',
api_complete_form: 'api_complete_form'
}, scope: false
+5 -2
View File
@@ -6,6 +6,7 @@
#
# id :bigint not null, primary key
# completed_at :datetime
# declined_at :datetime
# email :string
# ip :string
# metadata :text not null
@@ -59,7 +60,9 @@ class Submitter < ApplicationRecord
scope :completed, -> { where.not(completed_at: nil) }
def status
if completed_at?
if declined_at?
'declined'
elsif completed_at?
'completed'
elsif opened_at?
'opened'
@@ -83,6 +86,6 @@ class Submitter < ApplicationRecord
end
def status_event_at
completed_at || opened_at || sent_at || created_at
declined_at || completed_at || opened_at || sent_at || created_at
end
end
+12
View File
@@ -123,6 +123,18 @@
</div>
<% end %>
<% end %>
<% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::COMBINE_PDF_RESULT_KEY) %>
<% 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>
Combine completed documents and Audit Log
</span>
<%= f.check_box :value, class: 'toggle', checked: account_config.value, onchange: 'this.form.requestSubmit()' %>
</div>
<% end %>
<% end %>
</div>
<% end %>
<%= render 'integrations' %>
+3 -11
View File
@@ -13,20 +13,13 @@
}
.error-page h1 {
font-weight: 700;
font-size: 3em;
color: #291434;
margin: 0 0 0.1em;
}
.error-page h2 {
font-weight: 700;
font-size: 10em;
color: #3BBFF7;
margin: 0 0 0.1em;
}
.error-page h3 {
.error-page h2 {
font-weight: 600;
font-size: 1.75em;
color: #291434;
@@ -56,9 +49,8 @@
<body class="error-page">
<div class="dialog">
<div>
<h1>DocuSeal</h1>
<h2>404</h2>
<h3>Sorry, we couldn't find this page.</h3>
<h1>404</h1>
<h2>Sorry, we couldn't find this page.</h2>
</div>
<a rel="noopener noreferrer" href="/" class="btn">Back to homepage</a>
</div>
+3 -11
View File
@@ -13,20 +13,13 @@
}
.error-page h1 {
font-weight: 700;
font-size: 3em;
color: #291434;
margin: 0 0 0.1em;
}
.error-page h2 {
font-weight: 700;
font-size: 10em;
color: #FABE22;
margin: 0 0 0.1em;
}
.error-page h3 {
.error-page h2 {
font-weight: 600;
font-size: 1.75em;
color: #291434;
@@ -56,9 +49,8 @@
<body class="error-page">
<div class="dialog">
<div>
<h1>DocuSeal</h1>
<h2>422</h2>
<h3>You're not allowed to access this page</h3>
<h1>422</h1>
<h2>You're not allowed to access this page</h2>
</div>
<a rel="noopener noreferrer" href="/" class="btn">Back to homepage</a>
</div>
+3 -11
View File
@@ -13,20 +13,13 @@
}
.error-page h1 {
font-weight: 700;
font-size: 3em;
color: #291434;
margin: 0 0 0.1em;
}
.error-page h2 {
font-weight: 700;
font-size: 10em;
color: #F97272;
margin: 0 0 0.1em;
}
.error-page h3 {
.error-page h2 {
font-weight: 600;
font-size: 1.75em;
color: #291434;
@@ -56,9 +49,8 @@
<body class="error-page">
<div class="dialog">
<div>
<h1>DocuSeal</h1>
<h2>500</h2>
<h3>We're sorry, but something went wrong</h3>
<h1>500</h1>
<h2>We're sorry, but something went wrong</h2>
</div>
<a rel="noopener noreferrer" href="/" class="btn">Back to homepage</a>
</div>
+19
View File
@@ -0,0 +1,19 @@
<% uuid = SecureRandom.uuid %>
<label id="<%= local_assigns[:button_id] %>" for="<%= uuid %>" class="<%= local_assigns[:btn_class] %>"><%= local_assigns[:btn_text] %></label>
<input type="checkbox" id="<%= uuid %>" class="modal-toggle">
<div id="<%= local_assigns[:id] %>" class="modal items-start !animate-none overflow-y-auto">
<div class="modal-box pt-4 pb-6 px-6 mt-20 max-h-none">
<% if local_assigns[:title] %>
<div class="flex justify-between items-center border-b pb-2 mb-2 font-medium">
<span>
<%= local_assigns[:title] %>
</span>
<label for="<%= uuid %>" class="text-xl">&times;</label>
</div>
<% end %>
<div>
<%= yield %>
</div>
</div>
<label class="modal-backdrop" for="<%= uuid %>">Close</label>
</div>
+21 -9
View File
@@ -1,7 +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) %>
<% with_signature_id, is_combined_enabled = AccountConfig.where(account_id: @submission.account_id, key: [AccountConfig::COMBINE_PDF_RESULT_KEY, AccountConfig::WITH_SIGNATURE_ID], value: true).then { |configs| [configs.any? { |e| e.key == AccountConfig::WITH_SIGNATURE_ID }, configs.any? { |e| e.key == AccountConfig::COMBINE_PDF_RESULT_KEY }] } %>
<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">
@@ -20,7 +20,7 @@
<% if last_submitter = @submission.submitters.to_a.select(&:completed_at?).max_by(&:completed_at) %>
<% is_all_completed = @submission.submitters.to_a.all?(&:completed_at?) %>
<div class="join relative">
<download-button data-src="<%= submitter_download_index_path(last_submitter.slug, { sig: params[:sig] }.compact) %>" class="base-button <%= '!rounded-r-none !pr-2' if is_all_completed %>">
<download-button data-src="<%= submitter_download_index_path(last_submitter.slug, { sig: params[:sig], combined: is_combined_enabled }.compact) %>" class="base-button <%= '!rounded-r-none !pr-2' if is_all_completed && !is_combined_enabled %>">
<span class="flex items-center justify-center space-x-2" data-target="download-button.defaultButton">
<%= svg_icon('download', class: 'w-6 h-6') %>
<span class="hidden md:inline">Download</span>
@@ -30,7 +30,7 @@
<span class="hidden md:inline">Downloading</span>
</span>
</download-button>
<% if is_all_completed %>
<% if is_all_completed && !is_combined_enabled %>
<div class="dropdown dropdown-end">
<label tabindex="0" class="base-button !rounded-l-none !pl-1 !pr-2 !border-l-neutral-500">
<span class="text-sm align-text-top">
@@ -54,8 +54,8 @@
</div>
<% end %>
</div>
<% elsif @submission.submitters.to_a.size == 1 && !@submission.expired? %>
<%= render 'shared/clipboard_copy', text: start_form_url(slug: @submission.template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy Share Link', copied_title: 'Copied to Clipboard' %>
<% elsif @submission.submitters.to_a.size == 1 && !@submission.expired? && !@submission.submitters.to_a.first.declined_at? %>
<%= render 'shared/clipboard_copy', text: submit_form_url(slug: @submission.submitters.to_a.first.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy Share Link', copied_title: 'Copied to Clipboard' %>
<% end %>
</div>
</div>
@@ -143,18 +143,30 @@
<div class="flex items-center space-x-1 mt-1">
<%= svg_icon('writing', class: 'w-5 h-5') %>
<span>
<%= submitter&.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : 'Not completed yet' %>
<% if submitter&.declined_at? %>
Declined on <%= l(submitter.declined_at.in_time_zone(@submission.account.timezone), format: :short, locale: @submission.account.locale) %>
<% else %>
<%= submitter&.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : 'Not completed yet' %>
<% end %>
</span>
</div>
<% if signed_in? && submitter && submitter.email && !submitter.completed_at && !@submission.archived_at? && can?(:update, submitter) && Accounts.can_send_emails?(current_account) && !@submission.expired? %>
<% if submitter&.declined_at? %>
<div class="flex items-center space-x-1 mt-1">
<span>
Reason:
<%= simple_format(submitter.submission_events.find_by(event_type: :decline_form).data['reason']) %>
</span>
</div>
<% end %>
<% if signed_in? && submitter && submitter.email && !submitter.completed_at && !@submission.archived_at? && can?(:update, submitter) && Accounts.can_send_emails?(current_account) && !@submission.expired? && !submitter.declined_at? %>
<div class="mt-2 mb-1">
<%= button_to button_title(title: submitter.sent_at? ? 'Re-send Email' : 'Send Email', disabled_with: 'Sending'), submitter_send_email_index_path(submitter_slug: submitter.slug), class: 'btn btn-sm btn-primary w-full' %>
</div>
<% end %>
<% if signed_in? && submitter && submitter.phone && !submitter.completed_at && !@submission.archived_at? && can?(:update, submitter) && !@submission.expired? %>
<% if signed_in? && submitter && submitter.phone && !submitter.completed_at && !@submission.archived_at? && can?(:update, submitter) && !@submission.expired? && !submitter.declined_at? %>
<%= render 'submissions/send_sms_button', submitter: %>
<% end %>
<% if signed_in? && submitter && !submitter.completed_at? && !@submission.archived_at? && can?(:create, submitter) && !@submission.expired? %>
<% if signed_in? && submitter && !submitter.completed_at? && !@submission.archived_at? && can?(:create, submitter) && !@submission.expired? && !submitter.declined_at? %>
<div class="mt-2 mb-1">
<a class="btn btn-sm btn-primary w-full" target="_blank" href="<%= submit_form_path(slug: submitter.slug) %>">
Sign In-person
@@ -0,0 +1,11 @@
<%= form_for '', url: submit_form_decline_index_path(submitter.slug), method: :post do |f| %>
<div class="mt-4 text-center">
<%= t(:notify_the_sender_with_the_reason_you_declined) %>
</div>
<div class="form-control mt-2">
<%= f.text_area :reason, required: true, class: 'base-input w-full py-2 h-40', dir: 'auto', placeholder: t('provide_a_reason'), style: 'height: 200px', rows: '10' %>
</div>
<toggle-submit dir="auto" class="form-control mt-4">
<%= f.button button_title(title: t(:decline)), class: 'base-button' %>
</toggle-submit>
<% end %>
+21
View File
@@ -0,0 +1,21 @@
<div class="max-w-md mx-auto px-2 mt-12 mb-4">
<div class="space-y-6 mx-auto">
<div class="space-y-6">
<div class="flex items-center justify-center">
<%= render 'start_form/banner' %>
</div>
<div class="flex items-center bg-base-200 rounded-xl p-4 mb-4">
<div class="flex items-center">
<div class="mr-3">
<%= svg_icon('writing_sign', class: 'w-10 h-10') %>
</div>
<div dir="auto">
<p class="text-lg font-bold mb-1"><%= @submitter.submission.template.name %></p>
<p class="text-sm"><%= t('form_has_been_declined_on_html', time: l(@submitter.declined_at, format: :long)) %></p>
</div>
</div>
</div>
</div>
</div>
</div>
<%= render 'shared/attribution', link_path: '/start', account: @submitter.account %>
+24 -1
View File
@@ -8,7 +8,30 @@
<div id="scrollbox">
<div class="mx-auto block pb-72" style="max-width: 1000px">
<%# flex block w-full sticky top-0 z-50 space-x-2 items-center bg-yellow-100 p-2 border-y border-yellow-200 %>
<%= local_assigns[:banner_html] || render('submit_form/banner') %>
<%= local_assigns[:banner_html] || capture do %>
<%= render('submit_form/banner') %>
<div class="sticky top-0 z-50 bg-base-100 py-2 px-2 flex items-center md:-mx-[8px]" style="margin-bottom: -16px">
<div class="text-xl md:text-2xl font-medium focus:text-clip" style="width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
<%= @submitter.submission.template.name %>
</div>
<div class="flex items-center space-x-2" style="margin-left: 20px; flex-shrink: 0">
<div>
<%= render 'shared/html_modal', title: t(:decline), btn_text: t(:decline), btn_class: 'btn btn-sm !px-5', button_id: 'decline_button' do %>
<%= render 'submit_form/decline_form', submitter: @submitter %>
<% end %>
</div>
<download-button data-src="<%= submit_form_download_index_path(@submitter.slug) %>" class="btn btn-neutral text-white btn-sm !px-4">
<span class="flex items-center justify-center space-x-2" data-target="download-button.defaultButton">
<span><%= t('download') %></span>
</span>
<span class="flex items-center justify-center space-x-2 hidden" data-target="download-button.loadingButton">
<%= svg_icon('loader', class: 'w-6 h-6 animate-spin') %>
<span><%= t('downloading') %></span>
</span>
</download-button>
</div>
</div>
<% end %>
<% (@submitter.submission.template_schema || @submitter.submission.template.schema).each do |item| %>
<% document = @submitter.submission.template_schema_documents.find { |a| a.uuid == item['attachment_uuid'] } %>
<% document_annots_index = document.metadata.dig('pdf', 'annotations')&.group_by { |e| e['page'] } || {} %>
@@ -0,0 +1,4 @@
<p><%= t('hi_there') %>,</p>
<p><%= t('name_declined_by_submitter_with_the_following_reason', name: @submitter.submission.template.name, submitter: @submitter.name || @submitter.email || @submitter.phone) %></p>
<%= simple_format(@submitter.submission_events.find_by(event_type: :decline_form).data['reason']) %>
<p><%= link_to t('view'), submission_url(@submitter.submission) %></p>
+3 -3
View File
@@ -1,4 +1,4 @@
<% status_badges = { 'awaiting' => 'badge-info', 'sent' => 'badge-info', 'completed' => 'badge-success', 'opened' => 'badge-warning' } %>
<% status_badges = { 'awaiting' => 'badge-info', 'sent' => 'badge-info', 'completed' => 'badge-success', 'opened' => 'badge-warning', 'declined' => 'badge-error' } %>
<div class="bg-base-200 rounded-2xl flex flex-col sm:flex-row items-strech">
<% if local_assigns[:with_template] %>
<% template = submission.template %>
@@ -69,7 +69,7 @@
</download-button>
</button>
</form>
<% elsif !submission.archived_at? && !template.archived_at? && !submission.expired? %>
<% elsif !submission.archived_at? && !template.archived_at? && !submission.expired? && !submitter.declined_at? %>
<% if current_user.email == submitter.email %>
<form data-turbo="false" method="get" action="<%= submit_form_url(slug: submitter.slug) %>" class="flex-1 md:flex-none">
<button onclick="event.stopPropagation()" class="btn btn-sm btn-neutral btn-outline bg-white w-full md:w-36 flex">
@@ -146,7 +146,7 @@
</download-button>
</button>
</form>
<% elsif !template.archived_at? && !submission.archived_at? && !is_submission_completed && !submission.expired? %>
<% elsif !template.archived_at? && !submission.archived_at? && !is_submission_completed && !submission.expired? && !submitter.declined_at? %>
<div class="relative flex items-center space-x-3">
<% if current_user.email == submitter.email %>
<form data-turbo="false" method="get" action="<%= submit_form_url(slug: submitter.slug) %>">
+146 -5
View File
@@ -18,6 +18,8 @@ en: &en
language_nl: Nederlands
language_ar: العربية
language_ko: 한국어
view: View
hi_there: Hi there
email: Email
form_expired_at_html: 'Form expired on <span class="font-semibold">%{time}</span>'
verification_code_code: 'Verification code: %{code}'
@@ -39,6 +41,15 @@ en: &en
or: or
download_documents: Download documents
downloading: Downloading
download: Download
decline: Decline
declined: Declined
decline_reason: Decline reason
provide_a_reason: Provide a reason
notify_the_sender_with_the_reason_you_declined: Notify the sender with the reason you declined
form_has_been_declined_on_html: 'Form has been declined on <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" declined by %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" has been declined by %{submitter} with the following reason:'
completed_successfully: Completed Successfully
password: Password
sign_in: Sign In
@@ -65,6 +76,17 @@ en: &en
read: Read your data
es: &es
view: Vista
hi_there: Hola
download: Descargar
decline: Rechazar
declined: Rechazado
decline_reason: Motivo de rechazo
provide_a_reason: Proporcione un motivo
notify_the_sender_with_the_reason_you_declined: Notifique al remitente con el motivo por el que rechazó
form_has_been_declined_on_html: 'El formulario ha sido rechazado el <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" rechazado por %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" ha sido rechazado por %{submitter} con el siguiente motivo:'
role: Rol
reason: Razón
form_expired_at_html: 'El formulario expiró el <span class="font-semibold">%{time}</span>'
@@ -109,6 +131,17 @@ es: &es
enter_email_to_continue: Ingresa tu correo electrónico para continuar
it: &it
view: View
hi_there: Bonjour,
download: Télécharger
decline: Refuser
declined: Refusé
decline_reason: Raison du refus
provide_a_reason: Fournir une raison
notify_the_sender_with_the_reason_you_declined: Informer l'expéditeur de la raison pour laquelle vous avez refusé
form_has_been_declined_on_html: 'Le formulaire a été refusé le <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" refusé par %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" a été refusé par %{submitter} pour la raison suivante :'
role: Rôle
reason: Ragione
verification_code_code: 'Codice di verifica: %{code}'
@@ -152,6 +185,17 @@ it: &it
enter_email_to_continue: Inserisci l'email per continuare
fr: &fr
view: Vue
hi_there: Salut,
download: Télécharger
decline: Refuser
declined: Refusé
decline_reason: Raison du refus
provide_a_reason: Fournir une raison
notify_the_sender_with_the_reason_you_declined: Informer l'expéditeur de la raison pour laquelle vous avez refusé
form_has_been_declined_on_html: 'Le formulaire a été refusé le <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" a été refusé par %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" a été refusé par %{submitter} avec la raison suivante :'
email: Email
verification_code_code: 'Code de vérification: %{code}'
digitally_signed_by: Signé numériquement par
@@ -195,13 +239,23 @@ fr: &fr
enter_email_to_continue: Entrez votre e-mail pour continuer
pt: &pt
view: Visualizar
hi_there: Olá,
download: Baixar
decline: Recusar
declined: Recusado
decline_reason: Motivo da recusa
provide_a_reason: Forneça um motivo
notify_the_sender_with_the_reason_you_declined: Notifique o remetente com o motivo que você recusou
form_has_been_declined_on_html: 'O formulário foi recusado em <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" foi recusado por %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" foi recusado por %{submitter} com o seguinte motivo:'
role: Função
email: Email
reason: Razão
verification_code_code: 'Código de verificação: %{code}'
digitally_signed_by: Assinado digitalmente por
form_expired_at_html: 'O formulário expirou em <span class="font-semibold">%{time}</span>'
role: Função
provide_your_email_to_start: Forneça o seu email para começar
start: Iniciar
starting: Iniciando
@@ -238,13 +292,23 @@ pt: &pt
enter_email_to_continue: Insira o e-mail para continuar
de: &de
view: Ansicht
hi_there: Hallo,
download: Herunterladen
decline: Ablehnen
declined: Abgelehnt
decline_reason: Ablehnungsgrund
provide_a_reason: Geben Sie einen Grund an
notify_the_sender_with_the_reason_you_declined: Benachrichtigen Sie den Absender über den Grund für Ihre Ablehnung
form_has_been_declined_on_html: 'Das Formular wurde am <span class="font-semibold">%{time}</span> abgelehnt'
name_declined_by_submitter: '"%{name}" wurde von %{submitter} abgelehnt'
name_declined_by_submitter_with_the_following_reason: '"%{name}" wurde von %{submitter} mit folgendem Grund abgelehnt:'
role: Rolle
verification_code_code: 'Verifizierungscode: %{code}'
reason: Grund
email: E-Mail
form_expired_at_html: 'Das Formular ist am <span class="font-semibold">%{time}</span> abgelaufen'
digitally_signed_by: Digital signiert von
role: Rolle
provide_your_email_to_start: Gib deine E-Mail-Adresse ein, um zu starten
start: Starten
starting: Starten
@@ -281,7 +345,18 @@ de: &de
enter_email_to_continue: E-Mail eingeben, um fortzufahren
pl:
email: Email
view: Widok
hi_there: Cześć,
download: Pobierz
decline: Odrzuć
declined: Odrzucono
decline_reason: Powód odrzucenia
provide_a_reason: Podaj powód
notify_the_sender_with_the_reason_you_declined: Powiadom nadawcę o powodzie, dla którego odrzuciłeś
form_has_been_declined_on_html: 'Formularz został odrzucony o <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" odrzucono przez %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" został odrzucony przez %{submitter} z następującym powodem:'
email: E-mail
verification_code_code: 'Kod weryfikacyjny: %{code}'
digitally_signed_by: Podpis cyfrowy przez
form_expired_at_html: 'Formularz wygasł o <span class="font-semibold">%{time}</span>'
@@ -323,7 +398,18 @@ pl:
enter_email_to_continue: Wprowadź e-mail, aby kontynuować
uk:
email: Email
view: Переглянути
hi_there: Привіт,
download: Завантажити
decline: Відхилити
declined: Відхилено
decline_reason: Причина відхилення
provide_a_reason: Надайте причину
notify_the_sender_with_the_reason_you_declined: Повідомте відправника про причину, з якої ви відхилили
form_has_been_declined_on_html: 'Форму було відхилено о <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" відхилено %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" було відхилено %{submitter} з такою причиною:'
email: E-mail
digitally_signed_by: Цифровий підпис від
verification_code_code: 'Код підтвердження: %{code}'
role: Роль
@@ -365,7 +451,18 @@ uk:
enter_email_to_continue: Введіть електронну пошту, щоб продовжити
cs:
email: Email
view: Zobrazit
hi_there: Ahoj,
download: Stáhnout
decline: Odmítnout
declined: Odmítnuto
decline_reason: Důvod odmítnutí
provide_a_reason: Uveďte důvod
notify_the_sender_with_the_reason_you_declined: Informujte odesílatele o důvodu odmítnutí
form_has_been_declined_on_html: 'Formulář byl odmítnut dne <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" odmítnuto %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" bylo odmítnuto %{submitter} s následujícím důvodem:'
email: E-mail
digitally_signed_by: Digitálně podepsáno uživatelem
verification_code_code: 'Ověřovací kód: %{code}'
role: Role
@@ -407,6 +504,17 @@ cs:
enter_email_to_continue: Zadejte e-mail pro pokračování
he:
view: תצוגה
hi_there: שלום,
download: הורד
decline: דחייה
declined: דחוי
decline_reason: סיבת דחייה
provide_a_reason: אנא ספק סיבה
notify_the_sender_with_the_reason_you_declined: הודע לשולח על הסיבה לדחייה
form_has_been_declined_on_html: 'הטופס נדחה בתאריך <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" נדחה על ידי %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" נדחה על ידי %{submitter} עם הסיבה הבאה:'
email: דוא"ל
digitally_signed_by: חתום דיגיטלית על ידי
role: תפקיד
@@ -449,6 +557,17 @@ he:
enter_email_to_continue: הכנס דוא"ל כדי להמשיך
nl:
view: Bekijken
hi_there: Hallo,
download: Downloaden
decline: Weigeren
declined: Geweigerd
decline_reason: Weigeringsreden
provide_a_reason: Geef een reden op
notify_the_sender_with_the_reason_you_declined: Informeer de afzender over de reden waarom je hebt geweigerd
form_has_been_declined_on_html: 'Formulier is afgewezen op <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" is geweigerd door %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" is geweigerd door %{submitter} met de volgende reden:'
email: E-mail
digitally_signed_by: Digitaal ondertekend door
role: Rol
@@ -492,6 +611,17 @@ nl:
enter_email_to_continue: Voer e-mail in om door te gaan
ar:
view: عرض
hi_there: مرحبا,
download: تحميل
decline: رفض
declined: مرفوض
decline_reason: سبب الرفض
provide_a_reason: قدم سببًا
notify_the_sender_with_the_reason_you_declined: أخطر المرسل بسبب الرفض
form_has_been_declined_on_html: 'تم رفض النموذج في <span class="font-semibold">%{time}</span>'
name_declined_by_submitter: '"%{name}" مرفوض بواسطة %{submitter}'
name_declined_by_submitter_with_the_following_reason: '"%{name}" تم رفضه بواسطة %{submitter} مع السبب التالي:'
email: البريد الإلكتروني
digitally_signed_by: تم التوقيع الرقمي بواسطة
role: الدور
@@ -535,6 +665,17 @@ ar:
enter_email_to_continue: أدخل البريد الإلكتروني للمتابعة
ko:
view: 보기
hi_there: 안녕하세요,
download: 다운로드
decline: 거절
declined: 거절됨
decline_reason: 거절 사유
provide_a_reason: 사유를 제공하세요
notify_the_sender_with_the_reason_you_declined: 거절한 이유로 발신자에게 알리기
form_has_been_declined_on_html: '양식이 <span class="font-semibold">%{time}</span>에 거절되었습니다.'
name_declined_by_submitter: '"%{name}"이(가) %{submitter}에 의해 거절되었습니다.'
name_declined_by_submitter_with_the_following_reason: '"%{name}"이(가) %{submitter}에 의해 다음과 같은 사유로 거절되었습니다:'
email: 이메일
digitally_signed_by: 디지털로 서명됨
role: 역할
+2
View File
@@ -125,6 +125,8 @@ Rails.application.routes.draw do
resources :submit_form, only: %i[show update], path: 's', param: 'slug' do
resources :values, only: %i[index], controller: 'submit_form_values'
resources :download, only: %i[index], controller: 'submit_form_download'
resources :decline, only: %i[create], controller: 'submit_form_decline'
get :completed
end
@@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddDeclinedAtToSubmitters < ActiveRecord::Migration[7.1]
def change
add_column :submitters, :declined_at, :datetime
end
end
+2 -1
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_08_16_121641) do
ActiveRecord::Schema[7.1].define(version: 2024_08_20_180922) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -244,6 +244,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_16_121641) do
t.text "preferences", null: false
t.text "metadata", null: false
t.bigint "account_id", null: false
t.datetime "declined_at"
t.index ["account_id", "id"], name: "index_submitters_on_account_id_and_id"
t.index ["email"], name: "index_submitters_on_email"
t.index ["external_id"], name: "index_submitters_on_external_id"
+2 -2
View File
@@ -6,7 +6,7 @@ module Docuseal
NEWSLETTER_URL = "#{PRODUCT_URL}/newsletters".freeze
ENQUIRIES_URL = "#{PRODUCT_URL}/enquiries".freeze
PRODUCT_NAME = 'DocuSeal'
DEFAULT_APP_URL = 'http://localhost:3000'
DEFAULT_APP_URL = ENV.fetch('APP_URL', 'http://localhost:3000')
GITHUB_URL = 'https://github.com/docusealco/docuseal'
DISCORD_URL = 'https://discord.gg/qygYCDGck9'
TWITTER_URL = 'https://twitter.com/docusealco'
@@ -76,7 +76,7 @@ module Docuseal
return DEFAULT_URL_OPTIONS if multitenant?
@default_url_options ||= begin
value = EncryptedConfig.find_by(key: EncryptedConfig::APP_URL_KEY)&.value
value = EncryptedConfig.find_by(key: EncryptedConfig::APP_URL_KEY)&.value if ENV['APP_URL'].blank?
value ||= DEFAULT_APP_URL
url = Addressable::URI.parse(value)
{ host: url.host, port: url.port, protocol: url.scheme }
+27
View File
@@ -21,6 +21,8 @@ module Submissions
'GBP' => '£'
}.freeze
TESTING_FOOTER = GenerateResultAttachments::TESTING_FOOTER
RTL_REGEXP = TextUtils::RTL_REGEXP
MAX_IMAGE_HEIGHT = 100
@@ -105,6 +107,31 @@ module Submissions
maybe_add_background(canvas, submission, page_size)
end
with_signature_id = submission.account.account_configs
.exists?(key: AccountConfig::WITH_SIGNATURE_ID, value: true)
if with_signature_id || submission.account.testing?
canvas.save_graphics_state do
document_id = Digest::MD5.hexdigest(submission.slug).upcase
canvas.font(FONT_NAME, size: FONT_SIZE)
text =
if submission.account.testing?
if with_signature_id
"#{TESTING_FOOTER} | ID: #{document_id}"
else
TESTING_FOOTER
end
else
"Document ID: #{document_id}"
end
canvas.text(text, at: [2, 4])
end
end
style.frame = style.create_frame(canvas.context, 50)
end
+20 -16
View File
@@ -4,10 +4,10 @@ module Submissions
module SerializeForApi
SERIALIZE_PARAMS = {
only: %i[id slug source submitters_order expire_at created_at updated_at archived_at],
methods: %i[audit_log_url],
methods: %i[audit_log_url combined_document_url],
include: {
submitters: { only: %i[id slug uuid name email phone
completed_at opened_at sent_at
completed_at opened_at sent_at declined_at
created_at updated_at external_id metadata],
methods: %i[status application_key] },
template: { only: %i[id name external_id created_at updated_at],
@@ -23,25 +23,24 @@ module Submissions
serialized_submitters = submitters.map { |submitter| Submitters::SerializeForApi.call(submitter, params:) }
json = submission.as_json(
SERIALIZE_PARAMS.deep_merge(
include: { submission_events: { only: %i[id submitter_id event_type event_timestamp] } }
)
)
json = submission.as_json(SERIALIZE_PARAMS)
json['submission_events'] = Submitters::SerializeForApi.serialize_events(submission.submission_events)
json['combined_document_url'] ||= maybe_build_combined_url(submitters, submission, params)
if submitters.all?(&:completed_at?)
last_submitter = submitters.max_by(&:completed_at)
if params[:include].to_s.include?('combined_document_url')
json[:combined_document_url] = build_combined_url(submitters.max_by(&:completed_at), submission)
end
json[:documents] = serialized_submitters.find { |e| e['id'] == last_submitter.id }['documents']
json[:status] = 'completed'
json[:completed_at] = last_submitter.completed_at
else
json[:documents] = []
json[:status] = submission.expired? ? 'expired' : 'pending'
json[:status] = if submitters.any?(&:declined_at?)
'declined'
else
submission.expired? ? 'expired' : 'pending'
end
json[:completed_at] = nil
end
@@ -50,13 +49,18 @@ module Submissions
json
end
def build_combined_url(submitter, submission)
return unless submitter.completed_at?
def maybe_build_combined_url(submitters, submission, params)
return unless submitters.all?(&:completed_at?)
attachment = submission.combined_document_attachment
attachment ||= Submissions::GenerateCombinedAttachment.call(submitter)
ActiveStorage::Blob.proxy_url(attachment.blob)
if !attachment && params[:include].to_s.include?('combined_document_url')
submitter = submitters.max_by(&:completed_at)
attachment = Submissions::GenerateCombinedAttachment.call(submitter)
end
ActiveStorage::Blob.proxy_url(attachment.blob) if attachment
end
end
end
+6
View File
@@ -21,6 +21,12 @@ module Submitters
end
def select_attachments_for_download(submitter)
if AccountConfig.exists?(account_id: submitter.submission.account_id,
key: AccountConfig::COMBINE_PDF_RESULT_KEY,
value: true) && submitter.submission.combined_document_attachment
return [submitter.submission.combined_document_attachment]
end
original_documents = submitter.submission.template.documents.preload(:blob)
is_more_than_two_images = original_documents.count(&:image?) > 1
+8 -2
View File
@@ -3,7 +3,7 @@
module Submitters
module SerializeForApi
SERIALIZE_PARAMS = {
only: %i[id slug uuid name email phone completed_at external_id
only: %i[id slug uuid name email phone completed_at declined_at external_id
submission_id metadata opened_at sent_at created_at updated_at],
methods: %i[status application_key]
}.freeze
@@ -29,6 +29,7 @@ module Submitters
additional_attrs['values'] = SerializeForWebhook.build_values_array(submitter)
additional_attrs['documents'] = SerializeForWebhook.build_documents_array(submitter) if with_documents
additional_attrs['preferences'] = submitter.preferences.except('default_values')
additional_attrs['submission_events'] = serialize_events(submitter.submission_events) if with_events
additional_attrs['role'] =
(submitter.submission.template_submitters ||
@@ -41,9 +42,14 @@ module Submitters
include_params = {}
include_params[:template] = { only: %i[id name created_at updated_at] } if with_template
include_params[:submission_events] = { only: %i[id submitter_id event_type event_timestamp] } if with_events
submitter.as_json(SERIALIZE_PARAMS.merge(include: include_params)).merge(additional_attrs)
end
def serialize_events(events)
events.map do |event|
event.as_json(only: %i[id submitter_id event_type event_timestamp]).merge('data' => event.data.slice('reason'))
end
end
end
end
+15 -3
View File
@@ -5,7 +5,7 @@ module Submitters
SERIALIZE_PARAMS = {
methods: %i[status application_key],
only: %i[id submission_id email phone name ua ip sent_at opened_at
completed_at created_at updated_at external_id metadata]
completed_at declined_at created_at updated_at external_id metadata]
}.freeze
module_function
@@ -33,8 +33,8 @@ module Submitters
'template' => submitter.template.as_json(only: %i[id name external_id created_at updated_at],
methods: %i[folder_name]),
'submission' => {
**submitter.submission.slice(:id, :audit_log_url, :created_at),
status: submitter.submission.submitters.all?(&:completed_at?) ? 'completed' : 'pending',
**submitter.submission.slice(:id, :audit_log_url, :combined_document_url, :created_at),
status: build_submission_status(submitter.submission),
url: r.submissions_preview_url(submitter.submission.slug, **Docuseal.default_url_options)
})
end
@@ -83,6 +83,18 @@ module Submitters
end
end
def build_submission_status(submission)
submitters = submission.submitters
if submitters.all?(&:completed_at?)
'completed'
elsif submitters.any?(&:declined_at?)
'declined'
else
submission.expired? ? 'expired' : 'pending'
end
end
def build_documents_array(submitter)
submitter.documents.map do |attachment|
{ name: attachment.filename.base, url: rails_storage_proxy_url(attachment) }
+5
View File
@@ -3,6 +3,11 @@
module Templates
module SerializeForApi
SERIALIZE_PARAMS = {
only: %w[
id archived_at fields name preferences schema
slug source submitters created_at updated_at
author_id external_id folder_id
],
methods: %i[application_key folder_name],
include: { author: { only: %i[id email first_name last_name] } }
}.freeze
@@ -11,6 +11,12 @@ class SubmitterMailerPreview < ActionMailer::Preview
SubmitterMailer.completed_email(submitter, User.last)
end
def declined_email
submitter = Submitter.where.not(declined_at: nil).last
SubmitterMailer.declined_email(submitter, User.last)
end
def documents_copy_email
submitter = Submitter.where.not(completed_at: nil).joins(:documents_attachments).last
+1
View File
@@ -6,6 +6,7 @@ module.exports = {
'./app/javascript/submission_form/**/*.vue',
'./app/views/submit_form/**/*.erb',
'./app/views/start_form/**/*.erb',
'./app/views/shared/_html_modal.html.erb',
'./app/views/shared/_button_title.html.erb',
'./app/views/shared/_attribution.html.erb',
'./app/views/scripts/_autosize_field.html.erb',