mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5684baf1e0 | ||
|
|
b6f307690d | ||
|
|
66c44f8ff5 | ||
|
|
8f3592c481 | ||
|
|
dc8b1e0741 | ||
|
|
b806a6afc5 | ||
|
|
d43f8f4dd8 | ||
|
|
37c9bf5741 | ||
|
|
a0d37f516f | ||
|
|
2764a18252 | ||
|
|
96cf228e74 | ||
|
|
ff6ff3a51e | ||
|
|
9472a6b5b0 | ||
|
|
5f3a8bf391 | ||
|
|
a0a0fdd1b5 | ||
|
|
7a6f901b09 | ||
|
|
c4f05fbd9e | ||
|
|
50c342ec5c | ||
|
|
a9cfd2bcfc | ||
|
|
e2bdb2acee | ||
|
|
b8828b503c | ||
|
|
d63f62109b | ||
|
|
c04483f0ea | ||
|
|
1efaf30fb7 | ||
|
|
2e462e9633 | ||
|
|
838df5f41d | ||
|
|
32445f0e19 | ||
|
|
5f9067baee | ||
|
|
ad56d5ee14 | ||
|
|
a091d121d9 | ||
|
|
cd9c3ee3c1 | ||
|
|
534c3a2e10 | ||
|
|
7bc8e194df | ||
|
|
de5c4d5bcd |
No files matched your search
@@ -107,6 +107,8 @@ jobs:
|
||||
node-version: 20.9.0
|
||||
- name: Install Chrome
|
||||
uses: browser-actions/setup-chrome@latest
|
||||
with:
|
||||
chrome-version: 125
|
||||
- name: Cache node_modules
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
|
||||
@@ -23,6 +23,7 @@ gem 'image_processing'
|
||||
gem 'jwt'
|
||||
gem 'lograge'
|
||||
gem 'mysql2', require: false
|
||||
gem 'net-smtp', '0.4.0'
|
||||
gem 'oj'
|
||||
gem 'pagy'
|
||||
gem 'pg', require: false
|
||||
|
||||
+3
-2
@@ -326,7 +326,7 @@ GEM
|
||||
net-pop (0.1.2)
|
||||
net-protocol (0.2.2)
|
||||
timeout
|
||||
net-smtp (0.5.0)
|
||||
net-smtp (0.4.0)
|
||||
net-protocol
|
||||
nio4r (2.7.1)
|
||||
nokogiri (1.16.7)
|
||||
@@ -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)
|
||||
@@ -591,6 +591,7 @@ DEPENDENCIES
|
||||
letter_opener_web
|
||||
lograge
|
||||
mysql2
|
||||
net-smtp (= 0.4.0)
|
||||
oj
|
||||
pagy
|
||||
pg
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
class SubmissionEventsController < ApiBaseController
|
||||
load_and_authorize_resource :submission, parent: false
|
||||
|
||||
def index
|
||||
submissions = build_completed_query(@submissions)
|
||||
|
||||
params[:after] = Time.zone.at(params[:after].to_i) if params[:after].present?
|
||||
params[:before] = Time.zone.at(params[:before].to_i) if params[:before].present?
|
||||
|
||||
submissions = paginate(submissions.preload(
|
||||
:created_by_user, :submission_events,
|
||||
template: :folder,
|
||||
submitters: { documents_attachments: :blob, attachments_attachments: :blob },
|
||||
audit_trail_attachment: :blob
|
||||
),
|
||||
field: :completed_at)
|
||||
|
||||
render json: {
|
||||
data: submissions.map do |s|
|
||||
{
|
||||
event_type: 'submission.completed',
|
||||
timestamp: s.completed_at,
|
||||
data: Submissions::SerializeForApi.call(s, s.submitters)
|
||||
}
|
||||
end,
|
||||
pagination: {
|
||||
count: submissions.size,
|
||||
next: submissions.last&.completed_at&.to_i,
|
||||
prev: submissions.first&.completed_at&.to_i
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_completed_query(submissions)
|
||||
submissions = submissions.where(
|
||||
Submitter.where(completed_at: nil).where(
|
||||
Submitter.arel_table[:submission_id].eq(Submission.arel_table[:id])
|
||||
).select(1).arel.exists.not
|
||||
)
|
||||
|
||||
submissions.joins(:submitters)
|
||||
.group(:id)
|
||||
.select(Submission.arel_table[Arel.star],
|
||||
Submitter.arel_table[:completed_at].maximum.as('completed_at'))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -95,6 +95,7 @@ module Api
|
||||
def template_params
|
||||
permitted_params = [
|
||||
:name,
|
||||
:external_id,
|
||||
{
|
||||
submitters: [%i[name uuid]],
|
||||
fields: [[:uuid, :submitter_uuid, :name, :type,
|
||||
|
||||
@@ -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?
|
||||
@@ -82,6 +87,8 @@ class StartFormController < ApplicationController
|
||||
template_submitters: template.submitters,
|
||||
source: :link)
|
||||
|
||||
submitter.account_id = submitter.submission.account_id
|
||||
|
||||
submitter
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,6 +25,7 @@ import PromptPassword from './elements/prompt_password'
|
||||
import EmailsTextarea from './elements/emails_textarea'
|
||||
import ToggleOnSubmit from './elements/toggle_on_submit'
|
||||
import PasswordInput from './elements/password_input'
|
||||
import SearchInput from './elements/search_input'
|
||||
|
||||
import * as TurboInstantClick from './lib/turbo_instant_click'
|
||||
|
||||
@@ -87,6 +88,7 @@ safeRegisterElement('emails-textarea', EmailsTextarea)
|
||||
safeRegisterElement('toggle-cookies', ToggleCookies)
|
||||
safeRegisterElement('toggle-on-submit', ToggleOnSubmit)
|
||||
safeRegisterElement('password-input', PasswordInput)
|
||||
safeRegisterElement('search-input', SearchInput)
|
||||
|
||||
safeRegisterElement('template-builder', class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export default class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
this.input.addEventListener('focus', () => {
|
||||
if (this.title) {
|
||||
this.title.classList.add('hidden', 'md:block')
|
||||
this.input.classList.add('w-60')
|
||||
}
|
||||
})
|
||||
|
||||
this.input.addEventListener('blur', (e) => {
|
||||
if (this.title && !e.target.value) {
|
||||
this.title.classList.remove('hidden')
|
||||
this.input.classList.remove('w-60')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
get input () {
|
||||
return this.querySelector('input')
|
||||
}
|
||||
|
||||
get title () {
|
||||
return document.querySelector(this.dataset.title)
|
||||
}
|
||||
}
|
||||
@@ -181,6 +181,10 @@ export default {
|
||||
spread: 140
|
||||
})
|
||||
}
|
||||
|
||||
if (window.decline_button) {
|
||||
window.decline_button.setAttribute('disabled', 'true')
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sendCopyToEmail () {
|
||||
|
||||
@@ -925,7 +925,7 @@ export default {
|
||||
return field.conditions.reduce((acc, c) => {
|
||||
const field = this.fieldsUuidIndex[c.field_uuid]
|
||||
|
||||
if (['not_empty', 'checked', 'equal', 'contains'].includes(c.action) && !this.checkFieldConditions(field)) {
|
||||
if (['not_empty', 'checked', 'equal', 'contains'].includes(c.action) && field && !this.checkFieldConditions(field)) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
<template
|
||||
v-for="(icon, type) in fieldIcons"
|
||||
v-for="(icon, type) in fieldIconsSorted"
|
||||
:key="type"
|
||||
>
|
||||
<li v-if="(fieldTypes.length === 0 || fieldTypes.includes(type)) && (withPhone || type != 'phone') && (withPayment || type != 'payment')">
|
||||
|
||||
@@ -15,15 +15,19 @@ 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)
|
||||
end
|
||||
|
||||
enqueue_completed_webhooks(submitter)
|
||||
enqueue_completed_webhooks(submitter, is_all_completed:)
|
||||
end
|
||||
|
||||
def enqueue_completed_webhooks(submitter)
|
||||
def enqueue_completed_webhooks(submitter, is_all_completed: false)
|
||||
webhook_config = Accounts.load_webhook_config(submitter.account)
|
||||
|
||||
if webhook_config
|
||||
@@ -31,13 +35,26 @@ class ProcessSubmitterCompletionJob
|
||||
'encrypted_config_id' => webhook_config.id })
|
||||
end
|
||||
|
||||
webhook_ids = submitter.account.webhook_urls.where(
|
||||
Arel::Table.new(:webhook_urls)[:events].matches('%"form.completed"%')
|
||||
).pluck(:id)
|
||||
webhook_urls = submitter.account.webhook_urls
|
||||
|
||||
webhook_ids.each do |webhook_id|
|
||||
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id,
|
||||
'webhook_url_id' => webhook_id })
|
||||
webhook_urls = webhook_urls.where(
|
||||
Arel::Table.new(:webhook_urls)[:events].matches('%"form.completed"%')
|
||||
).or(
|
||||
webhook_urls.where(
|
||||
Arel::Table.new(:webhook_urls)[:events].matches('%"submission.completed"%')
|
||||
)
|
||||
)
|
||||
|
||||
webhook_urls.each do |webhook|
|
||||
if webhook.events.include?('form.completed')
|
||||
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id,
|
||||
'webhook_url_id' => webhook.id })
|
||||
end
|
||||
|
||||
if webhook.events.include?('submission.completed') && is_all_completed
|
||||
SendSubmissionCompletedWebhookRequestJob.perform_async({ 'submission_id' => submitter.submission_id,
|
||||
'webhook_url_id' => webhook.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,47 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SendSubmissionCompletedWebhookRequestJob
|
||||
include Sidekiq::Job
|
||||
|
||||
sidekiq_options queue: :webhooks
|
||||
|
||||
USER_AGENT = 'DocuSeal.co Webhook'
|
||||
|
||||
MAX_ATTEMPTS = 10
|
||||
|
||||
def perform(params = {})
|
||||
submission = Submission.find(params['submission_id'])
|
||||
|
||||
attempt = params['attempt'].to_i
|
||||
|
||||
webhook_url = submission.account.webhook_urls.find(params['webhook_url_id'])
|
||||
|
||||
url = webhook_url.url if webhook_url.events.include?('submission.completed')
|
||||
|
||||
return if url.blank?
|
||||
|
||||
resp = begin
|
||||
Faraday.post(url,
|
||||
{
|
||||
event_type: 'submission.completed',
|
||||
timestamp: Time.current,
|
||||
data: Submissions::SerializeForApi.call(submission)
|
||||
}.to_json,
|
||||
**EncryptedConfig.find_or_initialize_by(account_id: submission.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? || submission.account.account_configs.exists?(key: :plan))
|
||||
SendSubmissionCompletedWebhookRequestJob.perform_in((2**attempt).minutes, {
|
||||
**params,
|
||||
'attempt' => attempt + 1,
|
||||
'last_status' => resp&.status.to_i
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -29,7 +29,7 @@ class Account < ApplicationRecord
|
||||
has_one :default_template_folder, -> { where(name: TemplateFolder::DEFAULT_NAME) },
|
||||
class_name: 'TemplateFolder', dependent: :destroy, inverse_of: :account
|
||||
has_many :submissions, dependent: :destroy
|
||||
has_many :submitters, through: :submissions
|
||||
has_many :submitters, dependent: :destroy
|
||||
has_many :account_linked_accounts, dependent: :destroy
|
||||
has_many :email_events, dependent: :destroy
|
||||
has_many :webhook_urls, dependent: :destroy
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_submissions_on_account_id (account_id)
|
||||
# index_submissions_on_account_id_and_id (account_id,id)
|
||||
# index_submissions_on_created_by_user_id (created_by_user_id)
|
||||
# index_submissions_on_slug (slug) UNIQUE
|
||||
# index_submissions_on_template_id (template_id)
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
+12
-7
@@ -6,6 +6,7 @@
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# completed_at :datetime
|
||||
# declined_at :datetime
|
||||
# email :string
|
||||
# ip :string
|
||||
# metadata :text not null
|
||||
@@ -20,15 +21,17 @@
|
||||
# values :text not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint not null
|
||||
# external_id :string
|
||||
# submission_id :bigint not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_submitters_on_email (email)
|
||||
# index_submitters_on_external_id (external_id)
|
||||
# index_submitters_on_slug (slug) UNIQUE
|
||||
# index_submitters_on_submission_id (submission_id)
|
||||
# index_submitters_on_account_id_and_id (account_id,id)
|
||||
# index_submitters_on_email (email)
|
||||
# index_submitters_on_external_id (external_id)
|
||||
# index_submitters_on_slug (slug) UNIQUE
|
||||
# index_submitters_on_submission_id (submission_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
@@ -36,8 +39,8 @@
|
||||
#
|
||||
class Submitter < ApplicationRecord
|
||||
belongs_to :submission
|
||||
belongs_to :account
|
||||
has_one :template, through: :submission
|
||||
has_one :account, through: :submission
|
||||
|
||||
attribute :values, :string, default: -> { {} }
|
||||
attribute :preferences, :string, default: -> { {} }
|
||||
@@ -57,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'
|
||||
@@ -81,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
|
||||
@@ -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' %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<form action="<%= root_path %>" method="get" class="bg-base-200 px-1.5 rounded-xl py-1">
|
||||
<form action="<%= root_path %>" method="get" class="bg-base-200 px-1.5 rounded-xl py-1 whitespace-nowrap">
|
||||
<toggle-cookies data-value="templates" data-key="dashboard_view" class="sm:tooltip tooltip-top" data-tip="Templates">
|
||||
<button class="<%= local_assigns[:selected] == 'submissions' ? 'btn !border !rounded-lg btn-square !p-0 !btn-sm !h-8 !w-9' : 'btn btn-neutral !rounded-lg btn-square !p-0 hover:text-neutral-300 !btn-sm !h-8 !w-9 disabled:btn-neutral' %>">
|
||||
<%= svg_icon('layout_grid', class: 'w-6 h-6 stroke-2') %>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html data-theme="docuseal" lang="<%= I18n.locale %>">
|
||||
<head>
|
||||
<%= render 'layouts/head_tags' %>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<% if ENV['ROLLBAR_CLIENT_TOKEN'] %>
|
||||
|
||||
@@ -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">×</label>
|
||||
</div>
|
||||
<% end %>
|
||||
<div>
|
||||
<%= yield %>
|
||||
</div>
|
||||
</div>
|
||||
<label class="modal-backdrop" for="<%= uuid %>">Close</label>
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
<form action="<%= url_for %>" method="get" class="items-center hidden md:flex">
|
||||
<form action="<%= url_for %>" method="get" class="items-center flex">
|
||||
<% if params[:status].present? %>
|
||||
<input name="status" value="<%= params[:status] %>" class="hidden">
|
||||
<% end %>
|
||||
@@ -9,7 +9,9 @@
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<input id="search" name="q" value="<%= params[:q] %>" class="input input-ghost text-lg pr-10 -mr-12 <%= 'pl-8 input-outlined' if params[:q].present? %>" placeholder="<%= local_assigns[:placeholder] %>">
|
||||
<search-input data-title="<%= local_assigns[:title_selector] || 'h1' %>">
|
||||
<input id="search" name="q" value="<%= params[:q] %>" class="input input-ghost text-lg pr-10 -mr-12 w-0 md:w-64 <%= 'pl-8 input-outlined w-64' if params[:q].present? %>" placeholder="<%= local_assigns[:placeholder] %>">
|
||||
</search-input>
|
||||
<button type="submit" title="Search" class="btn btn-ghost btn-circle" onclick="window.search.value || document.activeElement === window.search ? null : [event.preventDefault(), window.search.focus()]">
|
||||
<span class="enabled">
|
||||
<%= svg_icon('search', class: 'w-6 h-6 stroke-2') %>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex justify-between mb-4 items-center">
|
||||
<h1 class="text-4xl font-bold">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||
<div>
|
||||
<h1 class="text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||
</div>
|
||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||
<%= render 'shared/search_input', placeholder: 'Search...' %>
|
||||
<% end %>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="mr-2">
|
||||
<%= render 'dashboard/toggle_view', selected: 'submissions' %>
|
||||
</div>
|
||||
<h1 class="text-3xl sm:text-4xl font-bold">Submissions</h1>
|
||||
<h1 class="text-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h1>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||
|
||||
@@ -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 %>
|
||||
@@ -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 %>
|
||||
@@ -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>
|
||||
@@ -5,7 +5,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex justify-between mb-4 items-center">
|
||||
<h1 class="text-4xl font-bold flex items-center space-x-2">
|
||||
<h1 class="text-4xl font-bold flex items-center space-x-2 md:flex <%= 'hidden' if params[:q].present? %>">
|
||||
<%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %>
|
||||
<span class="peer">
|
||||
<%= @template_folder.name %>
|
||||
|
||||
@@ -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 %>
|
||||
@@ -7,12 +7,12 @@
|
||||
<div class="font-medium items-start w-full group-hover:link text-sm flex space-x-1">
|
||||
<%= svg_icon('file_text', class: 'w-4 h-4 mt-0.5 flex-shrink-0') %>
|
||||
<span style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||
<%= template.name %>
|
||||
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
||||
<%= svg_icon('arrow_right', class: 'w-4 h-4 sm:inline group-hover:visible invisible hidden') %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-shrink-0 sm:mt-2">
|
||||
<div class="flex-shrink-0 sm:mt-2 max-w-[50%] md:max-w-full">
|
||||
<div class="flex text-xs flex-col text-base-content/60 space-y-0.5">
|
||||
<span class="flex items-center space-x-1">
|
||||
<%= svg_icon('user', class: 'w-4 h-4 flex-shrink-0') %>
|
||||
@@ -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) %>">
|
||||
@@ -195,6 +195,11 @@
|
||||
<%= button_to button_title(title: nil, disabled_with: 'Arch', icon: svg_icon('archive', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Archive', method: :delete, onclick: 'event.stopPropagation()' %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% if local_assigns[:archived] && can?(:destroy, submission) %>
|
||||
<span data-tip="Remove" class="sm:tooltip tooltip-top">
|
||||
<%= button_to button_title(title: nil, disabled_with: 'Rem', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission, permanently: true), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Remove', method: :delete, data: { turbo_confirm: 'Submission deletion is irreversible and will permanently remove all associated signed documents with it. Are you sure?' }, onclick: 'event.stopPropagation()' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</a>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="h-36 relative group">
|
||||
<a href="<%= template_path(template) %>" class="flex h-full flex-col justify-between rounded-2xl pt-6 px-7 w-full bg-base-200 peer">
|
||||
<div class="pb-4 text-xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||
<%= template.name %>
|
||||
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
||||
</div>
|
||||
<div class="pb-6 pt-1 space-y-1">
|
||||
<p class="flex items-center space-x-1 text-xs text-base-content/60">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="flex flex-col items-start md:flex-row space-y-2 md:space-y-0 md:space-x-2 md:justify-between md:items-start mb-6 md:mb-3">
|
||||
<div class="relative flex items-start justify-between w-full space-x-0">
|
||||
<div>
|
||||
<h1 class="text-4xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||
<h1 class="text-3xl md:text-4xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
||||
<% if template.archived_at? %>
|
||||
<span class="ml-1 badge badge-outline badge-lg align-middle">Archived</span>
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
<% if !@pagy.count.zero? || params[:q].present? || params[:status].present? %>
|
||||
<div class="<%= is_show_tabs ? 'mb-4' : 'mb-6' %>">
|
||||
<div class="flex justify-between items-center md:items-end">
|
||||
<p class="text-3xl font-bold">Submissions</p>
|
||||
<div>
|
||||
<h2 class="text-3xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h2>
|
||||
</div>
|
||||
<div class="flex justify-end space-x-2">
|
||||
<% if params[:q].present? || params[:status].present? || @pagy.pages > 1 %>
|
||||
<%= render 'shared/search_input' %>
|
||||
<%= render 'shared/search_input', title_selector: 'h2' %>
|
||||
<% end %>
|
||||
<%= link_to new_template_submissions_export_path(@template), class: 'hidden md:flex btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
|
||||
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex justify-between mb-4 items-center">
|
||||
<h1 class="text-4xl font-bold"><span class="hidden md:inline">Document</span> Templates <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||
<div>
|
||||
<h1 class="text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>"><span class="hidden md:inline">Document</span> Templates <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||
</div>
|
||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||
<%= render 'shared/search_input', placeholder: 'Search...' %>
|
||||
<% end %>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="flex justify-between mb-6 md:items-end flex-col md:flex-row">
|
||||
<p class="text-3xl font-bold">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></p>
|
||||
<div class="flex space-x-2 mt-3 md:mt-0">
|
||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||
<%= render 'shared/search_input' %>
|
||||
<% end %>
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold md:block">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||
</div>
|
||||
<div class="flex space-x-2 mt-3 md:mt-0 justify-end">
|
||||
<%= render 'shared/search_input' %>
|
||||
<%= link_to new_template_submissions_export_path(@template), class: 'order-3 md:order-1 btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
|
||||
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
|
||||
<span>Export</span>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<%= render 'dashboard/toggle_view', selected: 'templates' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<h1 class="text-3xl sm:text-4xl font-bold"><span class="hidden md:inline">Document</span> Templates</h1>
|
||||
<h1 class="text-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>"><span class="hidden md:inline">Document</span> Templates</h1>
|
||||
</div>
|
||||
<div class="flex space-x-2">
|
||||
<% if params[:q].present? || @pagy.pages > 1 || @template_folders.present? %>
|
||||
|
||||
@@ -126,39 +126,32 @@ Rails.application.configure do
|
||||
config.lograge.enabled = true
|
||||
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']
|
||||
|
||||
if ENV['MULTITENANT'] == 'true'
|
||||
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
||||
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
||||
|
||||
config.lograge.custom_payload do |controller|
|
||||
params =
|
||||
begin
|
||||
controller.request.try(:params) || {}
|
||||
rescue StandardError
|
||||
{}
|
||||
end
|
||||
config.lograge.custom_payload do |controller|
|
||||
params =
|
||||
begin
|
||||
controller.request.try(:params) || {}
|
||||
rescue StandardError
|
||||
{}
|
||||
end
|
||||
|
||||
{
|
||||
fwd: controller.request.remote_ip,
|
||||
params: {
|
||||
id: params[:id],
|
||||
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
|
||||
slug: (params[:slug] ||
|
||||
params[:submitter_slug] ||
|
||||
params[:submission_slug] ||
|
||||
params[:submit_form_slug] ||
|
||||
params[:template_slug]).to_s.last(5)
|
||||
}.compact_blank,
|
||||
host: controller.request.host,
|
||||
uid: controller.instance_variable_get(:@current_user).try(:id)
|
||||
}
|
||||
end
|
||||
else
|
||||
config.lograge.formatter = Lograge::Formatters::Json.new
|
||||
|
||||
config.lograge.custom_payload do |controller|
|
||||
{
|
||||
fwd: controller.request.remote_ip
|
||||
}
|
||||
end
|
||||
{
|
||||
fwd: controller.request.remote_ip,
|
||||
params: {
|
||||
id: params[:id],
|
||||
template_id: params[:template_id],
|
||||
submission_id: params[:submission_id],
|
||||
submitter_id: params[:submitter_id],
|
||||
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
|
||||
slug: (params[:slug] ||
|
||||
params[:submitter_slug] ||
|
||||
params[:submission_slug] ||
|
||||
params[:submit_form_slug] ||
|
||||
params[:template_slug]).to_s.first(5)
|
||||
}.compact_blank,
|
||||
host: controller.request.host,
|
||||
uid: controller.instance_variable_get(:@current_user).try(:id)
|
||||
}
|
||||
end
|
||||
end
|
||||
+146
-5
@@ -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: 역할
|
||||
|
||||
@@ -49,6 +49,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
scope 'events' do
|
||||
resources :form_events, only: %i[index], path: 'form/:type'
|
||||
resources :submission_events, only: %i[index], path: 'submission/:type'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,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,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddAccountIdToSubmitters < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_reference :submitters, :account, index: false, null: true
|
||||
|
||||
add_index :submitters, %i[account_id id]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,32 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PopulateSubmitterAccountId < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction
|
||||
|
||||
class MigrationSubmitter < ApplicationRecord
|
||||
self.table_name = 'submitters'
|
||||
belongs_to :submission, class_name: 'MigrationSubmission'
|
||||
end
|
||||
|
||||
class MigrationSubmission < ApplicationRecord
|
||||
self.table_name = 'submissions'
|
||||
end
|
||||
|
||||
def up
|
||||
MigrationSubmitter.where(account_id: nil).preload(:submission).find_each do |submitter|
|
||||
submitter.update_columns(account_id: submitter.submission.account_id)
|
||||
end
|
||||
|
||||
if MigrationSubmitter.exists?(account_id: nil)
|
||||
MigrationSubmitter.where(account_id: nil).preload(:submission).find_each do |submitter|
|
||||
submitter.update_columns(account_id: submitter.submission.account_id)
|
||||
end
|
||||
end
|
||||
|
||||
change_column_null :submitters, :account_id, false
|
||||
end
|
||||
|
||||
def down
|
||||
nil
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UpdateSubmissionAccountIdIndex < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_index :submissions, %i[account_id id]
|
||||
remove_index :submissions, :account_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveActiveStorageUniqIndex < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
remove_index :active_storage_attachments, %i[record_type record_id name blob_id],
|
||||
unique: true,
|
||||
name: 'index_active_storage_attachments_uniqueness'
|
||||
|
||||
add_index :active_storage_attachments, %i[record_type record_id name blob_id]
|
||||
end
|
||||
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
|
||||
+6
-3
@@ -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_01_125558) 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"
|
||||
|
||||
@@ -64,7 +64,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
||||
t.bigint "blob_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
||||
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
||||
t.index ["record_type", "record_id", "name", "blob_id"], name: "idx_on_record_type_record_id_name_blob_id_0be5805727"
|
||||
t.index ["uuid"], name: "index_active_storage_attachments_on_uuid"
|
||||
end
|
||||
|
||||
@@ -219,7 +219,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
||||
t.text "preferences", null: false
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "expire_at"
|
||||
t.index ["account_id"], name: "index_submissions_on_account_id"
|
||||
t.index ["account_id", "id"], name: "index_submissions_on_account_id_and_id"
|
||||
t.index ["created_by_user_id"], name: "index_submissions_on_created_by_user_id"
|
||||
t.index ["slug"], name: "index_submissions_on_slug", unique: true
|
||||
t.index ["template_id"], name: "index_submissions_on_template_id"
|
||||
@@ -243,6 +243,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
||||
t.string "external_id"
|
||||
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"
|
||||
t.index ["slug"], name: "index_submitters_on_slug", unique: true
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class Ability
|
||||
can :manage, TemplateFolder, account_id: user.account_id
|
||||
can :manage, TemplateSharing, template: { account_id: user.account_id }
|
||||
can :manage, Submission, account_id: user.account_id
|
||||
can :manage, Submitter, submission: { account_id: user.account_id }
|
||||
can :manage, Submitter, account_id: user.account_id
|
||||
can :manage, User, account_id: user.account_id
|
||||
can :manage, EncryptedConfig, account_id: user.account_id
|
||||
can :manage, EncryptedUserConfig, user_id: user.id
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ActionMailerConfigsInterceptor
|
||||
OPEN_TIMEOUT = 15
|
||||
READ_TIMEOUT = 25
|
||||
OPEN_TIMEOUT = ENV.fetch('SMTP_OPEN_TIMEOUT', '15').to_i
|
||||
READ_TIMEOUT = ENV.fetch('SMTP_READ_TIMEOUT', '25').to_i
|
||||
|
||||
module_function
|
||||
|
||||
|
||||
+2
-2
@@ -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 }
|
||||
|
||||
@@ -67,6 +67,7 @@ module Submissions
|
||||
|
||||
submission.submitters.new(email: normalize_email(email),
|
||||
uuid: template.submitters.first['uuid'],
|
||||
account_id: user.account_id,
|
||||
preferences:,
|
||||
sent_at: mark_as_sent ? Time.current : nil)
|
||||
|
||||
|
||||
@@ -155,16 +155,14 @@ module Submissions
|
||||
submitter_preferences = Submitters.normalize_preferences(submission.account, user, attrs)
|
||||
values = attrs[:values] || {}
|
||||
|
||||
phone_field_uuid =
|
||||
(submission.template_fields || submission.template.fields).find do |f|
|
||||
values[f['uuid']].present? && f['type'] == 'phone'
|
||||
end&.dig('uuid')
|
||||
phone_field_uuid = find_phone_field(submission, values)&.dig('uuid')
|
||||
|
||||
submitter =
|
||||
submission.submitters.new(
|
||||
email:,
|
||||
phone: (attrs[:phone] || values[phone_field_uuid]).to_s.gsub(/[^0-9+]/, ''),
|
||||
name: attrs[:name],
|
||||
account_id: user.account_id,
|
||||
external_id: attrs[:external_id].presence || attrs[:application_key],
|
||||
completed_at: attrs[:completed].present? ? Time.current : nil,
|
||||
values: values.except(phone_field_uuid),
|
||||
@@ -183,6 +181,12 @@ module Submissions
|
||||
submitter
|
||||
end
|
||||
|
||||
def find_phone_field(submission, values)
|
||||
(submission.template_fields || submission.template.fields).find do |f|
|
||||
values[f['uuid']].present? && f['type'] == 'phone'
|
||||
end
|
||||
end
|
||||
|
||||
def assign_completed_attributes(submitter)
|
||||
submitter.values = Submitters::SubmitValues.merge_default_values(submitter)
|
||||
submitter.values = Submitters::SubmitValues.merge_formula_values(submitter)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -58,13 +58,15 @@ module Submissions
|
||||
submitter.submission.template_schema.map do |item|
|
||||
pdf = pdfs_index[item['attachment_uuid']]
|
||||
|
||||
attachment = build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
||||
uuid: item['attachment_uuid'],
|
||||
name: item['name'])
|
||||
if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
||||
pdf = normalize_image_pdf(pdf)
|
||||
|
||||
image_pdfs << pdf if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
||||
image_pdfs << pdf
|
||||
end
|
||||
|
||||
attachment
|
||||
build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
||||
uuid: item['attachment_uuid'],
|
||||
name: item['name'])
|
||||
end
|
||||
|
||||
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
|
||||
@@ -74,6 +76,8 @@ module Submissions
|
||||
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
||||
end
|
||||
|
||||
images_pdf = normalize_image_pdf(images_pdf)
|
||||
|
||||
images_pdf_attachment =
|
||||
build_pdf_attachment(
|
||||
pdf: images_pdf,
|
||||
@@ -590,6 +594,14 @@ module Submissions
|
||||
pdf
|
||||
end
|
||||
|
||||
def normalize_image_pdf(pdf)
|
||||
io = StringIO.new
|
||||
pdf.write(io)
|
||||
io.rewind
|
||||
|
||||
HexaPDF::Document.new(io:)
|
||||
end
|
||||
|
||||
def sign_reason(name)
|
||||
format(SIGN_REASON, name:)
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,5 +4,9 @@ FactoryBot.define do
|
||||
factory :submitter do
|
||||
submission
|
||||
email { Faker::Internet.email }
|
||||
|
||||
before(:create) do |submitter, _|
|
||||
submitter.account_id = submitter.submission.account_id
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user