Compare commits

..
38 Commits
Author SHA1 Message Date
Pete Matsyburka 16e5c13633 fix erblint 2024-07-01 08:05:09 +03:00
Pete Matsyburka fff1831768 add gpt link 2024-06-30 16:21:19 +03:00
Pete Matsyburka f91a318e94 fix drawer 2024-06-29 20:10:28 +03:00
Pete Matsyburka ed06e17b23 adjust field attrs 2024-06-29 11:29:59 +03:00
Pete Matsyburka 63e1be7dfe remove border 2024-06-29 08:52:16 +03:00
Pete Matsyburka 16044612bd fix form fields 2024-06-29 08:44:19 +03:00
Pete Matsyburka 27d8880414 border alert 2024-06-29 00:04:10 +03:00
Pete Matsyburka a0aae6a9de add currencies 2024-06-28 23:34:15 +03:00
Alex Turchyn 749043dfbb process acro form fields 2024-06-28 21:42:39 +03:00
Pete Matsyburka 320fe02e35 remove upload signature button from drawn type 2024-06-28 16:56:51 +03:00
Pete Matsyburka 6f4b9d4a4e double click on builder checkbox 2024-06-28 16:28:37 +03:00
Pete Matsyburka a589cf9471 focus field input 2024-06-27 17:41:08 +03:00
Pete Matsyburka 7fc7283191 copy and paste fields 2024-06-27 15:14:39 +03:00
Pete Matsyburka af03560494 add radio select default value settings 2024-06-27 13:11:48 +03:00
Pete Matsyburka 988d1b93a5 double click to toggle signing date 2024-06-27 12:40:10 +03:00
Pete Matsyburka ab0278198a adjust phone step 2024-06-26 16:18:33 +03:00
Pete Matsyburka fbc649ab59 add extra links 2024-06-26 13:34:47 +03:00
Pete Matsyburka 6b5adc2504 select us date format 2024-06-25 21:49:44 +03:00
Pete Matsyburka 7c4307ef10 fix query 2024-06-25 21:11:48 +03:00
Pete Matsyburka de744e2f6c adjust invite email 2024-06-25 19:05:50 +03:00
Pete Matsyburka c171597c7f adjust max retries 2024-06-25 08:45:38 +03:00
Pete Matsyburka 3034c00bb3 use sidekiq 2024-06-24 21:10:58 +03:00
Pete Matsyburka 9539c476c0 remove legacy tracking param 2024-06-24 14:33:33 +03:00
Pete Matsyburka 4552c72860 add index on external id 2024-06-24 13:27:14 +03:00
Pete Matsyburka 85f8a92721 optimize query 2024-06-23 12:20:01 +03:00
Pete Matsyburka 049b9c78c2 add retries 2024-06-23 09:16:34 +03:00
Pete Matsyburka acf06084bf simplify job params 2024-06-22 10:50:07 +03:00
Pete Matsyburka 61da477733 reorder 2024-06-22 10:50:07 +03:00
Pete Matsyburka fdeec548a3 adjust message 2024-06-22 10:50:07 +03:00
Pete Matsyburka ff0d486831 fix clone template folder 2024-06-22 10:50:07 +03:00
Pete Matsyburka d5bf54ee26 adjust tempalte preferences 2024-06-22 10:50:07 +03:00
Pete Matsyburka 7616774613 use latest alpine 2024-06-21 00:46:11 +03:00
Pete Matsyburka 27c4dc7eca font size in the UI 2024-06-20 22:15:45 +03:00
Pete Matsyburka 4ae834d6f7 skip optional signature 2024-06-20 17:52:40 +03:00
Pete Matsyburka b71a66a082 add font size preference 2024-06-20 16:14:18 +03:00
Pete Matsyburka 80cc38542c fix email attachments 2024-06-18 20:09:58 +03:00
Pete Matsyburka 185aecec42 increase signature size 2024-06-18 17:18:23 +03:00
Pete Matsyburka 8c092eba78 allow to permanently delete submissions 2024-06-18 16:54:15 +03:00
86 changed files with 1085 additions and 240 deletions

No files matched your search

+1
View File
@@ -36,3 +36,4 @@ yarn-debug.log*
/attachments
/docuseal
/ee
dump.rdb
+3
View File
@@ -76,5 +76,8 @@ Rails/SkipsModelValidations:
Rails/ApplicationController:
Enabled: false
Rails/Output:
Enabled: false
Capybara/ClickLinkOrButtonStyle:
Enabled: false
+4 -4
View File
@@ -1,4 +1,4 @@
FROM ruby:3.3.1-alpine3.18 as fonts
FROM ruby:3.3.1-alpine as fonts
WORKDIR /fonts
@@ -6,7 +6,7 @@ RUN apk --no-cache add fontforge wget && wget https://github.com/satbyy/go-noto-
RUN fontforge -lang=py -c 'font1 = fontforge.open("FreeSans.ttf"); font2 = fontforge.open("NotoSansSymbols2-Regular.ttf"); font1.mergeFonts(font2); font1.generate("FreeSans.ttf")'
FROM ruby:3.3.1-alpine3.18 as webpack
FROM ruby:3.3.1-alpine as webpack
ENV RAILS_ENV=production
ENV NODE_ENV=production
@@ -32,7 +32,7 @@ COPY ./app/views ./app/views
RUN echo "gem 'shakapacker'" > Gemfile && ./bin/shakapacker
FROM ruby:3.3.1-alpine3.18 as app
FROM ruby:3.3.1-alpine as app
ENV RAILS_ENV=production
ENV BUNDLE_WITHOUT="development:test"
@@ -41,7 +41,7 @@ ENV OPENSSL_CONF=/app/openssl_legacy.cnf
WORKDIR /app
RUN apk add --no-cache sqlite-dev libpq-dev mariadb-dev vips-dev vips-poppler poppler-utils vips-heif gcompat ttf-freefont && mkdir /fonts && rm /usr/share/fonts/freefont/FreeSans.otf
RUN apk add --no-cache sqlite-dev libpq-dev mariadb-dev vips-dev vips-poppler poppler-utils redis vips-heif gcompat ttf-freefont && mkdir /fonts && rm /usr/share/fonts/freefont/FreeSans.otf
RUN echo $'.include = /etc/ssl/openssl.cnf\n\
\n\
+2 -2
View File
@@ -27,7 +27,7 @@ gem 'pagy'
gem 'pg', require: false
gem 'premailer-rails'
gem 'pretender'
gem 'puma'
gem 'puma', require: false
gem 'rack'
gem 'rails'
gem 'rails_autolink'
@@ -37,7 +37,7 @@ gem 'rqrcode'
gem 'ruby-vips'
gem 'rubyXL'
gem 'shakapacker'
gem 'sidekiq', require: ENV.key?('REDIS_URL')
gem 'sidekiq'
gem 'sqlite3', require: false, force_ruby_platform: true
gem 'strip_attributes'
gem 'turbo-rails'
@@ -64,14 +64,14 @@ module Api
submissions = create_submissions(@template, params)
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_later(submission)
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => submission.id })
end
Submissions.send_signature_requests(submissions)
submissions.each do |submission|
if submission.submitters.all?(&:completed_at?) && submission.submitters.last
ProcessSubmitterCompletionJob.perform_later(submission.submitters.last)
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => submission.submitters.last.id })
end
end
@@ -89,11 +89,15 @@ module Api
end
def destroy
@submission.update!(archived_at: Time.current)
if params[:permanently] == 'true'
@submission.destroy!
else
@submission.update!(archived_at: Time.current)
SendSubmissionArchivedWebhookRequestJob.perform_later(@submission)
SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id)
end
render json: @submission.as_json(only: %i[id], methods: %i[archived_at])
render json: @submission.as_json(only: %i[id archived_at])
end
private
@@ -8,8 +8,7 @@ module Api
def create
submitter = Submitter.find_by!(slug: params[:submitter_slug])
if params[:t] == SubmissionEvents.build_tracking_param(submitter, 'click_email') ||
params[:t] == SubmissionEvents.build_tracking_param_legacy(submitter, 'click_email')
if params[:t] == SubmissionEvents.build_tracking_param(submitter, 'click_email')
SubmissionEvents.create_with_tracking_data(submitter, 'click_email', request)
end
@@ -13,7 +13,7 @@ module Api
SubmissionEvents.create_with_tracking_data(submitter, 'view_form', request)
SendFormViewedWebhookRequestJob.perform_later(submitter)
SendFormViewedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id })
render json: {}
end
+1 -1
View File
@@ -66,7 +66,7 @@ module Api
end
if @submitter.completed_at?
ProcessSubmitterCompletionJob.perform_later(@submitter)
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => @submitter.id })
elsif normalized_params[:send_email] || normalized_params[:send_sms]
Submitters.send_signature_requests([@submitter])
end
@@ -20,7 +20,7 @@ module Api
Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
SendTemplateCreatedWebhookRequestJob.perform_later(cloned_template)
SendTemplateCreatedWebhookRequestJob.perform_async('template_id' => cloned_template.id)
render json: Templates::SerializeForApi.call(cloned_template)
end
+2 -2
View File
@@ -65,13 +65,13 @@ module Api
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
render json: @template.as_json(only: %i[id updated_at])
end
def destroy
if params[:permanently] == 'true' && !Docuseal.multitenant?
if params[:permanently] == 'true'
@template.destroy!
else
@template.update!(archived_at: Time.current)
+3 -1
View File
@@ -36,7 +36,9 @@ class StartFormController < ApplicationController
is_new_record = @submitter.new_record?
if @submitter.save
SendSubmissionCreatedWebhookRequestJob.perform_later(@submitter.submission) if is_new_record
if is_new_record
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => @submitter.submission.id })
end
redirect_to submit_form_path(@submitter.slug)
else
+2 -2
View File
@@ -45,7 +45,7 @@ class SubmissionsController < ApplicationController
end
submissions.each do |submission|
SendSubmissionCreatedWebhookRequestJob.perform_later(submission)
SendSubmissionCreatedWebhookRequestJob.perform_async({ 'submission_id' => submission.id })
end
Submissions.send_signature_requests(submissions)
@@ -56,7 +56,7 @@ class SubmissionsController < ApplicationController
def destroy
@submission.update!(archived_at: Time.current)
SendSubmissionArchivedWebhookRequestJob.perform_later(@submission)
SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id)
redirect_back(fallback_location: template_path(@submission.template), notice: 'Submission has been archived')
end
@@ -13,7 +13,7 @@ class SubmittersSendEmailController < ApplicationController
alert: 'Email has been sent already.')
end
SendSubmitterInvitationEmailJob.perform_later('submitter_id' => @submitter.id)
SendSubmitterInvitationEmailJob.perform_async('submitter_id' => @submitter.id)
@submitter.sent_at ||= Time.current
@submitter.save!
@@ -10,7 +10,7 @@ class TemplateDocumentsController < ApplicationController
old_fields_hash = @template.fields.hash
documents = Templates::CreateAttachments.call(@template, params)
documents = Templates::CreateAttachments.call(@template, params, extract_fields: true)
schema = documents.map do |doc|
{ attachment_uuid: doc.uuid, name: doc.filename.base }
+3 -3
View File
@@ -53,7 +53,7 @@ class TemplatesController < ApplicationController
if params[:account_id].present? && authorized_clone_account_id?(params[:account_id])
@template.account_id = params[:account_id]
@template.folder = @template.account.default_template_folder
@template.folder = @template.account.default_template_folder if @template.account_id != current_account.id
else
@template.account = current_account
end
@@ -61,7 +61,7 @@ class TemplatesController < ApplicationController
if @template.save
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
maybe_redirect_to_template(@template)
else
@@ -72,7 +72,7 @@ class TemplatesController < ApplicationController
def update
@template.update!(template_params)
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
SendTemplateUpdatedWebhookRequestJob.perform_async('template_id' => @template.id)
head :ok
end
@@ -0,0 +1,33 @@
# frozen_string_literal: true
class TemplatesDebugController < ApplicationController
load_and_authorize_resource :template
def show
attachment = @template.documents.first
pdf = HexaPDF::Document.new(io: StringIO.new(attachment.download))
fields = Templates::FindAcroFields.call(pdf, attachment)
attachment.metadata['pdf'] ||= {}
attachment.metadata['pdf']['fields'] = fields
@template.update!(fields: Templates::ProcessDocument.normalize_attachment_fields(@template, [attachment]))
ActiveRecord::Associations::Preloader.new(
records: [@template],
associations: [schema_documents: { preview_images_attachments: :blob }]
).call
@template_data =
@template.as_json.merge(
documents: @template.schema_documents.as_json(
methods: %i[metadata signed_uuid],
include: { preview_images: { methods: %i[url metadata filename] } }
)
).to_json
render 'templates/edit', layout: 'plain'
end
end
@@ -21,7 +21,9 @@ class TemplatesPreferencesController < ApplicationController
params.require(:template).permit(
preferences: %i[bcc_completed request_email_subject request_email_body
documents_copy_email_subject documents_copy_email_body
documents_copy_email_enabled]
documents_copy_email_enabled documents_copy_email_attach_audit
completed_notification_email_subject completed_notification_email_body
completed_notification_email_enabled completed_notification_email_attach_audit]
).tap do |attrs|
attrs[:preferences] = attrs[:preferences].transform_values do |value|
if %w[true false].include?(value)
@@ -12,13 +12,16 @@ class TemplatesUploadsController < ApplicationController
save_template!(@template, url_params)
documents = Templates::CreateAttachments.call(@template, url_params || params)
documents = Templates::CreateAttachments.call(@template, url_params || params, extract_fields: true)
schema = documents.map { |doc| { attachment_uuid: doc.uuid, name: doc.filename.base } }
@template.update!(schema:)
fields = Templates::ProcessDocument.normalize_attachment_fields(@template, documents)
SendTemplateCreatedWebhookRequestJob.perform_later(@template)
schema.each { |item| item['pending_fields'] = true } if fields.present?
@template.update!(schema:, fields:)
SendTemplateCreatedWebhookRequestJob.perform_async('template_id' => @template.id)
redirect_to edit_template_path(@template)
rescue Templates::CreateAttachments::PdfEncrypted
@@ -17,7 +17,7 @@ class WebhookSettingsController < ApplicationController
def update
submitter = current_account.submitters.where.not(completed_at: nil).order(:id).last
SendFormCompletedWebhookRequestJob.perform_later(submitter)
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id })
redirect_back(fallback_location: settings_webhooks_path, notice: 'Webhook request has been sent.')
end
+6 -2
View File
@@ -5,8 +5,12 @@ export default targetable(class extends HTMLElement {
static [target.static] = ['canvas', 'input', 'clear', 'button']
async connectedCallback () {
this.canvas.width = this.canvas.parentNode.parentNode.clientWidth
this.canvas.height = this.canvas.parentNode.parentNode.clientWidth / 3
const scale = 3
this.canvas.width = this.canvas.parentNode.clientWidth * scale
this.canvas.height = this.canvas.parentNode.clientHeight * scale
this.canvas.getContext('2d').scale(scale, scale)
const { default: SignaturePad } = await import('signature_pad')
+7 -1
View File
@@ -340,12 +340,18 @@ export default {
computedStyle () {
const { x, y, w, h } = this.area
return {
const style = {
top: y * 100 + '%',
left: x * 100 + '%',
width: w * 100 + '%',
height: h * 100 + '%'
}
if (this.field.preferences?.font_size) {
style.fontSize = this.field.preferences.font_size + 'pt'
}
return style
}
},
watch: {
+8 -3
View File
@@ -697,6 +697,7 @@ export default {
isFormVisible: this.expand !== false,
showFillAllRequiredFields: false,
currentStep: 0,
enableScrollIntoField: true,
phoneVerifiedValues: {},
orientation: screen?.orientation?.type,
isSubmitting: false,
@@ -992,10 +993,12 @@ export default {
if (!this.isCompleted) {
if (scrollToArea) {
this.scrollIntoField(step[0])
this.$refs.form.querySelector('input[type="date"], input[type="number"], input[type="text"], select')?.focus()
}
this.enableScrollIntoField = false
this.$refs.form.querySelector('input[type="date"], input[type="number"], input[type="text"], select')?.focus()
this.enableScrollIntoField = true
if (clickUpload && !this.values[this.currentField.uuid] && ['file', 'image'].includes(this.currentField.type)) {
this.$refs.form.querySelector('input[type="file"]')?.click()
}
@@ -1028,7 +1031,9 @@ export default {
}
},
scrollIntoField (field) {
return this.$refs.areas.scrollIntoField(field)
if (this.enableScrollIntoField) {
return this.$refs.areas.scrollIntoField(field)
}
},
scrollIntoArea (area) {
return this.$refs.areas.scrollIntoArea(area)
+13
View File
@@ -11,6 +11,7 @@ const en = {
number: 'Number',
image: 'Image',
take_photo: 'Take photo',
number_phone_is_invalid: '{number} phone is invalid',
file: 'File',
select: 'Select',
checkbox: 'Checkbox',
@@ -85,6 +86,7 @@ const es = {
file: 'Archivo',
select: 'Seleccionar',
checkbox: 'Casilla',
number_phone_is_invalid: '{number} teléfono es inválido',
multiple: 'Múltiple',
radio: 'Radio',
cells: 'Celdas',
@@ -160,6 +162,7 @@ const it = {
cells: 'Celle',
stamp: 'Timbro',
payment: 'Pagamento',
number_phone_is_invalid: '{number} telefono non è valido',
phone: 'Telefono',
submit_form: 'Invia Modulo',
sign_now: 'Firma ora',
@@ -230,6 +233,7 @@ const de = {
cells: 'Zellen',
stamp: 'Stempel',
payment: 'Zahlung',
number_phone_is_invalid: '{number} Telefonnummer ist ungültig',
phone: 'Telefon',
submit_form: 'Formular absenden',
sign_now: 'Jetzt unterschreiben',
@@ -300,6 +304,7 @@ const fr = {
cells: 'Cellules',
stamp: 'Tampon',
payment: 'Paiement',
number_phone_is_invalid: '{number} téléphone est invalide',
phone: 'Téléphone',
submit_form: 'Envoyer le Formulaire',
sign_now: 'Signer maintenant',
@@ -370,6 +375,7 @@ const pl = {
cells: 'Komórki',
stamp: 'Pieczątka',
payment: 'Płatność',
number_phone_is_invalid: '{number} telefon jest nieprawidłowy',
phone: 'Telefon',
submit_form: 'Wyślij Formularz',
sign_now: 'Podpisz teraz',
@@ -440,6 +446,7 @@ const uk = {
cells: 'Клітинки',
stamp: 'Штамп',
payment: 'Платіж',
number_phone_is_invalid: '{number} телефон недійсний',
phone: 'Телефон',
submit_form: 'Надіслати Форму',
sign_now: 'Підписати зараз',
@@ -511,6 +518,7 @@ const cs = {
stamp: 'Razítko',
payment: 'Platba',
phone: 'Telefon',
number_phone_is_invalid: '{number} telefon je neplatný',
submit_form: 'Odeslat formulář',
sign_now: 'Podepsat nyní',
type_here_: 'Zadejte zde',
@@ -580,6 +588,7 @@ const pt = {
cells: 'Células',
stamp: 'Carimbo',
payment: 'Pagamento',
number_phone_is_invalid: '{number} telefone é inválido',
phone: 'Telefone',
submit_form: 'Enviar Formulário',
sign_now: 'Assinar agora',
@@ -651,6 +660,7 @@ const he = {
stamp: 'חותמת',
payment: 'תשלום',
phone: 'טלפון',
number_phone_is_invalid: '{number} טלפון אינו חוקי',
submit_form: 'שלח טופס',
sign_now: 'חתום כעת',
type_here_: 'הקלד כאן',
@@ -723,6 +733,7 @@ const nl = {
stamp: 'Stempel',
payment: 'Betaling',
phone: 'Telefoon',
number_phone_is_invalid: '{number} telefoon is ongeldig',
submit_form: 'Formulier verzenden',
sign_now: 'Nu ondertekenen',
type_here_: 'Typ hier...',
@@ -794,6 +805,7 @@ const ar = {
minimize: 'تصغير',
payment: 'الدفع',
phone: 'هاتف',
number_phone_is_invalid: '{number} هاتف غير صالح',
submit_form: 'إرسال النموذج',
sign_now: 'وقع الآن',
type_here_: 'اكتب هنا',
@@ -865,6 +877,7 @@ const ko = {
minimize: '최소화',
payment: '결제',
phone: '전화',
number_phone_is_invalid: '{number} 전화번호가 유효하지 않습니다',
submit_form: '양식 제출',
sign_now: '지금 서명',
type_here_: '여기에 입력...',
+13 -5
View File
@@ -174,6 +174,14 @@ export default {
phone: this.$refs.phone.value
}),
headers: { 'Content-Type': 'application/json' }
}).then(async (resp) => {
if (resp.status === 422) {
const data = await resp.json()
alert(this.t('number_phone_is_invalid').replace('{number}', this.$refs.phone.value))
return Promise.reject(new Error(data.error))
}
})
},
async submit () {
@@ -186,13 +194,13 @@ export default {
return Promise.reject(new Error('phone invalid'))
} else if (!this.isCodeSent) {
this.sendVerificationCode()
return this.sendVerificationCode().then(() => {
this.$emit('update:model-value', this.$refs.phone.value)
this.$emit('update:model-value', this.$refs.phone.value)
this.isCodeSent = true
this.isCodeSent = true
return Promise.reject(new Error('verify with code'))
return Promise.reject(new Error('verify with code'))
})
} else {
return Promise.resolve({})
}
@@ -54,7 +54,7 @@
</a>
</span>
<span
v-if="field.preferences?.format !== 'typed'"
v-if="field.preferences?.format !== 'typed' && field.preferences?.format !== 'drawn'"
class="tooltip"
:data-tip="t('take_photo')"
>
@@ -582,7 +582,11 @@ export default {
return resolve(attachment)
})
}).catch((error) => {
return reject(error)
if (error.message === 'Image too small' && this.field.required === false) {
return resolve({})
} else {
return reject(error)
}
})
})
}
+47 -7
View File
@@ -164,16 +164,16 @@
<span
v-if="field"
class="flex justify-center items-center space-x-1 h-full"
:class="{'w-full h-full': field.type == 'checkbox'}"
:class="{ 'w-full h-full': ['cells', 'checkbox'].includes(field.type) }"
>
<div
v-if="isDefaultValuePresent || isContenteditable"
:class="{ 'w-full h-full': field.type == 'checkbox', 'text-[1.5vw] lg:text-base': !textOverflowChars, 'text-[1.0vw] lg:text-xs': textOverflowChars }"
:class="{ 'w-full h-full': ['cells', 'checkbox'].includes(field.type), 'text-[1.5vw] lg:text-base': !textOverflowChars, 'text-[1.0vw] lg:text-xs': textOverflowChars }"
>
<div
ref="textContainer"
class="flex items-center px-0.5"
:class="{'w-full h-full': field.type == 'checkbox'}"
:class="{ 'w-full h-full': ['cells', 'checkbox'].includes(field.type) }"
>
<IconCheck
v-if="field.type == 'checkbox'"
@@ -184,6 +184,24 @@
v-else-if="field.type === 'number' && !isContenteditable"
class="whitespace-pre-wrap"
>{{ formatNumber(field.default_value, field.preferences?.format) }}</span>
<span
v-else-if="field.default_value === '{{date}}'"
>
{{ t('signing_date') }}
</span>
<div
v-else-if="field.type === 'cells' && field.default_value"
class="w-full flex items-center"
>
<div
v-for="(char, index) in field.default_value"
:key="index"
class="text-center flex-none"
:style="{ width: (area.cell_w / area.w * 100) + '%' }"
>
{{ char }}
</div>
</div>
<span
v-else
ref="defaultValue"
@@ -211,7 +229,7 @@
ref="touchTarget"
class="absolute top-0 bottom-0 right-0 left-0"
:class="isDragged ? 'cursor-grab' : 'cursor-pointer'"
@dblclick="maybeFocusDefaultValue"
@dblclick="maybeToggleDefaultValue"
/>
<span
v-if="field?.type && editable"
@@ -330,7 +348,11 @@ export default {
fieldNames: FieldType.computed.fieldNames,
fieldIcons: FieldType.computed.fieldIcons,
isDefaultValuePresent () {
return this.field?.default_value || this.field?.default_value === 0
if (this.field?.type === 'radio' && this.field?.areas?.length > 1) {
return false
} else {
return this.field?.default_value || this.field?.default_value === 0
}
},
modalContainerEl () {
return this.$el.getRootNode().querySelector('#docuseal_modal_container')
@@ -454,7 +476,7 @@ export default {
closeDropdown () {
document.activeElement.blur()
},
maybeFocusDefaultValue () {
maybeToggleDefaultValue () {
if (['text', 'number'].includes(this.field.type)) {
this.isContenteditable = true
@@ -468,6 +490,16 @@ export default {
)
}
})
} else if (this.field.type === 'checkbox') {
this.field.readonly = !this.field.readonly
this.field.default_value === true ? delete this.field.default_value : this.field.default_value = true
this.save()
} else if (this.field.type === 'date') {
this.field.readonly = !this.field.readonly
this.field.default_value === '{{date}}' ? delete this.field.default_value : this.field.default_value = '{{date}}'
this.save()
}
},
formatNumber (number, format) {
@@ -513,7 +545,15 @@ export default {
this.save()
},
onPaste (e) {
e.target.innerText = (e.clipboardData || window.clipboardData).getData('text/plain')
const text = (e.clipboardData || window.clipboardData).getData('text/plain')
const selection = window.getSelection()
if (selection.rangeCount) {
selection.deleteFromDocument()
selection.getRangeAt(0).insertNode(document.createTextNode(text))
selection.collapseToEnd()
}
},
onResizeCell (e) {
if (e.target.id === 'mask') {
+104 -6
View File
@@ -3,6 +3,31 @@
style="max-width: 1600px"
class="mx-auto pl-3 md:pl-4 h-full"
>
<div
v-if="pendingFieldAttachmentUuids.length"
class="top-1.5 sticky h-0 z-20 max-w-2xl mx-auto"
>
<div class="alert border-base-content/30 py-2 px-2.5">
<IconInfoCircle
class="stroke-info shrink-0 w-6 h-6"
/>
<span>{{ t('uploaded_pdf_contains_form_fields_keep_or_remove_them') }}</span>
<div>
<button
class="btn btn-sm"
@click.prevent="removePendingFields"
>
{{ t('remove') }}
</button>
<button
class="btn btn-sm btn-neutral text-white"
@click.prevent="save"
>
{{ t('keep') }}
</button>
</div>
</div>
</div>
<div
v-if="$slots.buttons || withTitle"
id="title_container"
@@ -296,7 +321,7 @@ import Contenteditable from './contenteditable'
import DocumentPreview from './preview'
import DocumentControls from './controls'
import MobileFields from './mobile_fields'
import { IconUsersPlus, IconDeviceFloppy, IconWritingSign, IconInnerShadowTop } from '@tabler/icons-vue'
import { IconUsersPlus, IconDeviceFloppy, IconWritingSign, IconInnerShadowTop, IconInfoCircle } from '@tabler/icons-vue'
import { v4 } from 'uuid'
import { ref, computed } from 'vue'
import { en as i18nEn } from './i18n'
@@ -307,6 +332,7 @@ export default {
Upload,
Document,
Fields,
IconInfoCircle,
MobileDrawField,
IconWritingSign,
MobileFields,
@@ -512,7 +538,9 @@ export default {
isSaving: false,
selectedSubmitter: null,
showDrawField: false,
pendingFieldAttachmentUuids: [],
drawField: null,
copiedArea: null,
drawFieldType: null,
drawOption: null,
dragField: null
@@ -593,6 +621,12 @@ export default {
document.querySelector('form[action="/auth/stripe_connect"]')?.closest('.dropdown')?.querySelector('label')?.focus()
}
})
this.template.schema.forEach((item) => {
if (item.pending_fields) {
this.pendingFieldAttachmentUuids.push(item.attachment_uuid)
}
})
},
unmounted () {
document.removeEventListener('keyup', this.onKeyUp)
@@ -607,6 +641,13 @@ export default {
t (key) {
return this.i18n[key] || i18nEn[key] || key
},
removePendingFields () {
this.template.fields = this.template.fields.filter((f) => {
return this.template.schema.find((item) => item.attachment_uuid === f.attachment_uuid && item.pending_fields)
})
this.save()
},
addField (type, area = null) {
const field = {
name: '',
@@ -627,7 +668,7 @@ export default {
if (type === 'date') {
field.preferences = {
format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY'
format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY'
}
}
@@ -660,7 +701,7 @@ export default {
if (type === 'date') {
field.preferences = {
format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY'
format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY'
}
}
@@ -747,6 +788,14 @@ export default {
event.preventDefault()
this.undo()
} else if ((event.ctrlKey || event.metaKey) && event.key === 'c' && document.activeElement === document.body) {
event.preventDefault()
this.copiedArea = this.selectedAreaRef?.value
} else if ((event.ctrlKey || event.metaKey) && event.key === 'v' && this.copiedArea && document.activeElement === document.body) {
event.preventDefault()
this.pasteField()
}
},
removeArea (area) {
@@ -760,6 +809,39 @@ export default {
this.save()
},
pasteField () {
const field = this.template.fields.find((f) => f.areas?.includes(this.copiedArea))
const currentArea = this.selectedAreaRef?.value || this.copiedArea
if (field && currentArea) {
const area = {
...JSON.parse(JSON.stringify(this.copiedArea)),
attachment_uuid: currentArea.attachment_uuid,
page: currentArea.page,
x: currentArea.x,
y: currentArea.y + currentArea.h * 1.3
}
if (['radio', 'multiple'].includes(field.type)) {
this.copiedArea.option_uuid ||= field.options[0].uuid
area.option_uuid = v4()
field.options.push({ uuid: area.option_uuid })
field.areas.push(area)
} else {
this.template.fields.push({
...JSON.parse(JSON.stringify(field)),
uuid: v4(),
areas: [area]
})
}
this.selectedAreaRef.value = area
this.save()
}
},
pushUndo () {
const stringData = JSON.stringify(this.template)
@@ -914,7 +996,7 @@ export default {
if (field.type === 'date') {
field.preferences = {
format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY'
format: Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY'
}
}
}
@@ -990,6 +1072,8 @@ export default {
}
this.save()
document.activeElement?.blur()
},
updateFromUpload (data) {
this.template.schema.push(...data.schema)
@@ -1022,6 +1106,18 @@ export default {
}
this.save()
data.documents.forEach((attachment) => {
if (attachment.metadata?.pdf?.fields?.length) {
this.pendingFieldAttachmentUuids.push(attachment.uuid)
attachment.metadata.pdf.fields.forEach((field) => {
field.submitter_uuid = this.selectedSubmitter.uuid
this.template.fields.push(field)
})
}
})
},
updateName (value) {
this.template.name = value
@@ -1136,7 +1232,7 @@ export default {
if (submitterWithoutFields) {
e.preventDefault()
alert(`Please add fields for ${submitterWithoutFields.name} to prepare the document or remove the party.`)
alert(`Please add fields for the ${submitterWithoutFields.name}. Or, remove the ${submitterWithoutFields.name} if not needed.`)
}
}
},
@@ -1158,7 +1254,7 @@ export default {
this.template.submitters.find((submitter) => !this.template.fields.some((f) => f.submitter_uuid === submitter.uuid))
if (submitterWithoutFields) {
alert(`Please add fields for ${submitterWithoutFields.name} to prepare the document or remove the party.`)
alert(`Please add fields for the ${submitterWithoutFields.name}. Or, remove the ${submitterWithoutFields.name} if not needed.`)
} else {
this.isSaving = true
@@ -1188,6 +1284,8 @@ export default {
})
},
save ({ force } = { force: false }) {
this.pendingFieldAttachmentUuids = []
if (this.onChange) {
this.onChange(this.template)
}
@@ -99,7 +99,15 @@ export default {
},
methods: {
onPaste (e) {
e.target.innerText = (e.clipboardData || window.clipboardData).getData('text/plain')
const text = (e.clipboardData || window.clipboardData).getData('text/plain')
const selection = window.getSelection()
if (selection.rangeCount) {
selection.deleteFromDocument()
selection.getRangeAt(0).insertNode(document.createTextNode(text))
selection.collapseToEnd()
}
},
selectContent () {
const el = this.$refs.contenteditable
+1 -1
View File
@@ -339,7 +339,7 @@ export default {
if (this.field.type === 'date') {
this.field.preferences.format ||=
(Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') ? 'MM/DD/YYYY' : 'DD/MM/YYYY')
(Intl.DateTimeFormat().resolvedOptions().locale.endsWith('-US') || new Intl.DateTimeFormat('en-US', { timeZoneName: 'short' }).format(new Date()).match(/\s(?:CST|CDT|PST|PDT|EST|EDT)$/) ? 'MM/DD/YYYY' : 'DD/MM/YYYY')
}
},
methods: {
@@ -52,6 +52,40 @@
{{ t('align') }}
</label>
</div>
<div
v-if="['select', 'radio'].includes(field.type) && !defaultField"
class="py-1.5 px-1 relative"
@click.stop
>
<select
:placeholder="t('default_value')"
dir="auto"
class="select select-bordered select-xs w-full max-w-xs h-7 !outline-0 font-normal bg-transparent"
@change="[field.default_value = $event.target.value, !field.default_value && delete field.default_value, save()]"
>
<option
value=""
:selected="!field.default_value"
>
{{ t('none') }}
</option>
<option
v-for="(option, index) in field.options || []"
:key="option.uuid"
:value="option.value || `${t('option')} ${index + 1}`"
:selected="field.default_value === (option.value || `${t('option')} ${index + 1}`)"
>
{{ option.value || `${t('option')} ${index + 1}` }}
</option>
</select>
<label
:style="{ backgroundColor }"
class="absolute -top-1 left-2.5 px-1 h-4"
style="font-size: 8px"
>
{{ t('default_value') }}
</label>
</div>
<div
v-if="['text', 'number'].includes(field.type) && !defaultField"
class="py-1.5 px-1 relative"
+3
View File
@@ -5,6 +5,8 @@ const en = {
clear: 'Clear',
align: 'Align',
add_all_required_fields_to_continue: 'Add all required fields to continue',
uploaded_pdf_contains_form_fields_keep_or_remove_them: 'Uploaded PDF contains form fields. Keep or remove them?',
keep: 'Keep',
left: 'Left',
validation: 'Validation',
right: 'Right',
@@ -27,6 +29,7 @@ const en = {
are_you_sure: 'Are you sure?',
sign_yourself: 'Sign Yourself',
set_signing_date: 'Set signing date',
signing_date: 'Signing Date',
send: 'Send',
remove: 'Remove',
edit: 'Edit',
@@ -204,7 +204,7 @@ export default {
return document.location.origin + '/auth/stripe_connect/callback'
},
defaultCurrencies () {
return ['USD', 'EUR', 'GBP']
return ['USD', 'EUR', 'GBP', 'CAD', 'AUD']
},
currenciesList () {
return this.currencies.length ? this.currencies : this.defaultCurrencies
@@ -226,6 +226,10 @@ export default {
return 'EUR'
} else if (userTimezone.includes('London') || userTimezone.includes('Belfast')) {
return 'GBP'
} else if (userTimezone.includes('Vancouver') || userTimezone.includes('Toronto') || userTimezone.includes('Halifax') || userTimezone.includes('Edmonton')) {
return 'CAD'
} else if (userTimezone.startsWith('Australia')) {
return 'AUD'
} else {
return 'USD'
}
+1
View File
@@ -1,4 +1,5 @@
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base
retry_on StandardError, wait: 6.seconds, attempts: 5 unless Docuseal.multitenant?
end
+9 -4
View File
@@ -1,7 +1,11 @@
# frozen_string_literal: true
class ProcessSubmitterCompletionJob < ApplicationJob
def perform(submitter)
class ProcessSubmitterCompletionJob
include Sidekiq::Job
def perform(params = {})
submitter = Submitter.find(params['submitter_id'])
is_all_completed = !submitter.submission.submitters.exists?(completed_at: nil)
if !is_all_completed && submitter.submission.submitters_order_preserved?
@@ -18,7 +22,7 @@ class ProcessSubmitterCompletionJob < ApplicationJob
return if Accounts.load_webhook_url(submitter.account).blank?
SendFormCompletedWebhookRequestJob.perform_later(submitter)
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id })
end
def enqueue_completed_emails(submitter)
@@ -26,7 +30,8 @@ class ProcessSubmitterCompletionJob < ApplicationJob
user = submission.created_by_user || submitter.template.author
if submitter.account.users.exists?(id: user.id) && submission.preferences['send_email'] != false
if submitter.account.users.exists?(id: user.id) && submission.preferences['send_email'] != false &&
submitter.template.preferences['completed_notification_email_enabled'] != false
if submission.submitters.map(&:email).exclude?(user.email) &&
user.user_configs.find_by(key: UserConfig::RECEIVE_COMPLETED_EMAIL)&.value != false &&
user.role != 'integration'
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendFormCompletedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendFormCompletedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(submitter, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
submitter = Submitter.find(params['submitter_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(submitter.submission.account)
return if url.blank?
@@ -36,11 +40,11 @@ class SendFormCompletedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormCompletedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(submitter, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendFormCompletedWebhookRequestJob.perform_in((2**attempt).minutes, {
'submitter_id' => submitter.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendFormStartedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendFormStartedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(submitter, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
submitter = Submitter.find(params['submitter_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(submitter.submission.account)
return if url.blank?
@@ -34,11 +38,11 @@ class SendFormStartedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormStartedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(submitter, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendFormStartedWebhookRequestJob.perform_in((2**attempt).minutes, {
'submitter_id' => submitter.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendFormViewedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendFormViewedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(submitter, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
submitter = Submitter.find(params['submitter_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(submitter.submission.account)
return if url.blank?
@@ -34,11 +38,11 @@ class SendFormViewedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
SendFormViewedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(submitter, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendFormViewedWebhookRequestJob.perform_in((2**attempt).minutes, {
'submitter_id' => submitter.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendSubmissionArchivedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendSubmissionArchivedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(submission, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
submission = Submission.find(params['submission_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(submission.account)
return if url.blank?
@@ -32,11 +36,11 @@ class SendSubmissionArchivedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
SendSubmissionArchivedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(submission, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendSubmissionArchivedWebhookRequestJob.perform_in((2**attempt).minutes, {
'submission_id' => submission.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendSubmissionCreatedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendSubmissionCreatedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(submission, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
submission = Submission.find(params['submission_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(submission.account)
return if url.blank?
@@ -32,11 +36,11 @@ class SendSubmissionCreatedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
SendSubmissionCreatedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(submission, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendSubmissionCreatedWebhookRequestJob.perform_in((2**attempt).minutes, {
'submission_id' => submission.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
@@ -1,6 +1,8 @@
# frozen_string_literal: true
class SendSubmitterInvitationEmailJob < ApplicationJob
class SendSubmitterInvitationEmailJob
include Sidekiq::Job
def perform(params = {})
submitter = Submitter.find(params['submitter_id'])
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendTemplateCreatedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendTemplateCreatedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(template, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
template = Template.find(params['template_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(template.account)
return if url.blank?
@@ -32,11 +36,11 @@ class SendTemplateCreatedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
SendTemplateCreatedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(template, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendTemplateCreatedWebhookRequestJob.perform_in((2**attempt).minutes, {
'template_id' => template.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
@@ -1,14 +1,18 @@
# frozen_string_literal: true
class SendTemplateUpdatedWebhookRequestJob < ApplicationJob
queue_as :webhooks
class SendTemplateUpdatedWebhookRequestJob
include Sidekiq::Job
sidekiq_options queue: :webhooks
USER_AGENT = 'DocuSeal.co Webhook'
MAX_ATTEMPTS = 10
def perform(template, params = {})
attempt = params[:attempt].to_i
def perform(params = {})
template = Template.find(params['template_id'])
attempt = params['attempt'].to_i
url = Accounts.load_webhook_url(template.account)
return if url.blank?
@@ -32,11 +36,11 @@ class SendTemplateUpdatedWebhookRequestJob < ApplicationJob
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
(!Docuseal.multitenant? || template.account.account_configs.exists?(key: :plan))
SendTemplateUpdatedWebhookRequestJob.set(wait: (2**attempt).minutes)
.perform_later(template, {
attempt: attempt + 1,
last_status: resp&.status.to_i
})
SendTemplateUpdatedWebhookRequestJob.perform_in((2**attempt).minutes, {
'template_id' => template.id,
'attempt' => attempt + 1,
'last_status' => resp&.status.to_i
})
end
end
end
+21 -9
View File
@@ -48,16 +48,21 @@ class SubmitterMailer < ApplicationMailer
@email_config = AccountConfigs.find_for_account(@current_account, AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY)
add_completed_email_attachments!(
submitter, with_audit_log: @email_config.nil? || @email_config.value['attach_audit_log'] != false
submitter, with_audit_log: (@email_config.nil? || @email_config.value['attach_audit_log'] != false) &&
@submitter.template.preferences['completed_notification_email_attach_audit'] != false
)
@subject = @submitter.template.preferences['completed_notification_email_subject'].presence
@subject ||= @email_config.value['subject'] if @email_config
@body = @submitter.template.preferences['completed_notification_email_body'].presence
@body ||= @email_config.value['body'] if @email_config
subject =
if @email_config
ReplaceEmailVariables.call(@email_config.value['subject'], submitter:)
if @subject.present?
ReplaceEmailVariables.call(@subject, submitter:)
else
submitters = submitter.submission.submitters.order(:completed_at)
.map { |e| e.name || e.email || e.phone }.join(', ')
%(#{submitter.submission.template.name} has been completed by #{submitters})
build_completed_subject(submitter)
end
assign_message_metadata('submitter_completed', @submitter)
@@ -77,7 +82,8 @@ class SubmitterMailer < ApplicationMailer
@email_config = AccountConfigs.find_for_account(@current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY)
@documents = add_completed_email_attachments!(
submitter, with_audit_log: @email_config.nil? || @email_config.value['attach_audit_log'] != false
submitter, with_audit_log: @submitter.template.preferences['documents_copy_email_attach_audit'] != false &&
(@email_config.nil? || @email_config.value['attach_audit_log'] != false)
)
@subject = @submitter.template.preferences['documents_copy_email_subject'].presence
@@ -105,6 +111,12 @@ class SubmitterMailer < ApplicationMailer
private
def build_completed_subject(submitter)
submitters = submitter.submission.submitters.order(:completed_at)
.map { |e| e.name || e.email || e.phone }.join(', ')
%(#{submitter.submission.template.name} has been completed by #{submitters})
end
def add_completed_email_attachments!(submitter, with_audit_log: true)
documents = Submitters.select_attachments_for_download(submitter)
@@ -119,7 +131,7 @@ class SubmitterMailer < ApplicationMailer
total_size = add_attachments_with_size_limit(documents, total_size)
attachments[submitter.submission.audit_trail.filename.to_s] = audit_trail_data if audit_trail_data
attachments[submitter.submission.audit_trail.filename.to_s.tr('"', "'")] = audit_trail_data if audit_trail_data
file_fields = submitter.submission.template_fields.select { |e| e['type'].in?(%w[file payment]) }
@@ -141,7 +153,7 @@ class SubmitterMailer < ApplicationMailer
break if total_size >= MAX_ATTACHMENTS_SIZE
attachments[attachment.filename.to_s] = attachment.download
attachments[attachment.filename.to_s.tr('"', "'")] = attachment.download
end
total_size
+1 -1
View File
@@ -9,6 +9,6 @@ class UserMailer < ApplicationMailer
assign_message_metadata('user_invitation', @user)
mail(to: @user.friendly_name,
subject: 'You are invited to DocuSeal')
subject: "You are invited to #{Docuseal.product_name}")
end
end
+1
View File
@@ -26,6 +26,7 @@
# 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)
#
+5 -4
View File
@@ -22,10 +22,11 @@
#
# Indexes
#
# index_templates_on_account_id (account_id)
# index_templates_on_author_id (author_id)
# index_templates_on_folder_id (folder_id)
# index_templates_on_slug (slug) UNIQUE
# index_templates_on_account_id (account_id)
# index_templates_on_author_id (author_id)
# index_templates_on_external_id (external_id)
# index_templates_on_folder_id (folder_id)
# index_templates_on_slug (slug) UNIQUE
#
# Foreign Keys
#
+6
View File
@@ -81,6 +81,12 @@ class User < ApplicationRecord
true
end
def sidekiq?
return true if Rails.env.development?
role == 'admin'
end
def self.sign_in_after_reset_password
if PasswordsController::Current.user.present?
!PasswordsController::Current.user.otp_required_for_login
+9
View File
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" class="<%= local_assigns[:class] %>" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path d="M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35" />
<path d="M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946" />
<path d="M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348" />
<path d="M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45" />
<path d="M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946" />
<path d="M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42" />
</svg>

After

Width:  |  Height:  |  Size: 822 B

@@ -4,7 +4,7 @@
<%= f.label :value, class: 'label' do %>
<span class="flex items-center space-x-1">
<span>
Completed documents BCC address
Completed documents notification BCC address
</span>
<span class="tooltip" data-tip="Send email copy with completed documents to a specified BCC address.">
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
@@ -2,7 +2,7 @@
<input type="checkbox">
<div class="collapse-title text-xl font-medium">
<div>
Form Completed Email
Completed Notification Email
</div>
</div>
<div class="collapse-content">
@@ -4,8 +4,8 @@
<p class="text-4xl font-bold mb-4">Email Templates</p>
<div class="space-y-4">
<%= render 'signature_request_email_form' %>
<%= render 'submitter_completed_email_form' %>
<%= render 'documents_copy_email_form' %>
<%= render 'submitter_completed_email_form' %>
</div>
<p class="text-4xl font-bold mb-4 mt-8">Company Logo</p>
<%= render 'logo_form' %>
+8 -5
View File
@@ -86,6 +86,7 @@
<%= link_to 'SSO', settings_sso_index_path, class: 'text-base hover:bg-base-300' %>
</li>
<% end %>
<%= render 'shared/settings_nav_extra2' %>
<% if (can?(:manage, EncryptedConfig) && current_user == true_user) || (current_user != true_user && current_account.testing?) %>
<li>
<%= form_for '', url: testing_account_path, method: current_account.testing? ? :delete : :get, html: { class: 'flex w-full' } do |f| %>
@@ -117,11 +118,13 @@
<%= svg_icon('brand_discord', class: 'w-8 h-8') %>
</a>
</div>
<div class="tooltip" data-tip="Twitter">
<a href="<%= Docuseal::TWITTER_URL %>" target="_blank" class="btn btn-circle btn-primary btn-md">
<%= svg_icon('brand_twitter', class: 'w-8 h-8') %>
</a>
</div>
<%= content_for(:gpt_link) || capture do %>
<div class="tooltip" data-tip="AI Assistant">
<a href="<%= Docuseal::CHATGPT_URL %>" target="_blank" class="btn btn-circle btn-primary btn-md">
<%= svg_icon('brand_openai', class: 'w-8 h-8') %>
</a>
</div>
<% end %>
</div>
<a href="mailto:<%= Docuseal::SUPPORT_EMAIL %>" target="_blank" class="w-full block mt-4 underline text-center">
<%= Docuseal::SUPPORT_EMAIL %>
Whitespace-only changes.
+1 -1
View File
@@ -1,7 +1,7 @@
<turbo-frame id="drawer">
<turbo-modal class="modal modal-open items-start !animate-none justify-end overflow-y-auto !justify-normal md:!justify-end" data-close-after-submit="<%= local_assigns.key?(:close_after_submit) ? local_assigns[:close_after_submit] : true %>">
<div class="absolute top-0 bottom-0 right-0 left-0" data-action="click:turbo-modal#close"></div>
<div class="bg-base-100 min-h-screen max-h-screen relative w-full relative overflow-y-auto">
<div class="bg-base-100 min-h-screen max-h-screen relative w-full relative">
<% if local_assigns[:title] %>
<div class="flex justify-between bg-base-100 py-2 px-4 items-center border-b pb-2 font-medium">
<span>
+1 -1
View File
@@ -1,5 +1,5 @@
<% align = field.dig('preferences', 'align') %>
<field-value dir="auto" class="flex absolute text-[1.5vw] lg:text-base <%= align == 'right' ? 'justify-end' : (align == 'center' ? 'justify-center' : '') %>" style="width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%">
<field-value dir="auto" class="flex absolute text-[1.5vw] lg:text-base <%= align == 'right' ? 'justify-end' : (align == 'center' ? 'justify-center' : '') %>" style="width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%; <%= "font-size: #{field['preferences']['font_size']}pt" if field.dig('preferences', 'font_size') %>">
<% if field['type'].in?(['signature', 'image', 'initials', 'stamp']) %>
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" loading="lazy">
<% elsif field['type'].in?(['file', 'payment']) %>
@@ -1,5 +1,5 @@
<% if @email_config %>
<%= render 'custom_content', content: @email_config.value['body'], submitter: @submitter %>
<% if @body.present? %>
<%= render 'custom_content', content: @body, submitter: @submitter %>
<% else %>
<p>Hi there,</p>
<p>"<%= @submitter.submission.template.name %>" form has been completed by <%= @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ') %>.</p>
+56 -2
View File
@@ -24,7 +24,7 @@
<%= ff.label :bcc_completed, class: 'label' do %>
<span class="flex items-center space-x-1 justify-between w-full">
<span>
Completed documents BCC address
Completed documents notification BCC address
</span>
</span>
<% end %>
@@ -82,7 +82,8 @@
<div class="collapse-content">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' } do |f| %>
<toggle-on-submit data-element-id="email_saved_alert2"></toggle-on-submit>
<%= f.fields_for :preferences, Struct.new(:documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled).new(*(@template.preferences.values_at('documents_copy_email_subject', 'documents_copy_email_body').compact_blank.presence || AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY).value.values_at('subject', 'body')), @template.preferences['documents_copy_email_enabled']) do |ff| %>
<% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY).value %>
<%= f.fields_for :preferences, Struct.new(:documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled, :documents_copy_email_attach_audit).new(@template.preferences['documents_copy_email_subject'].presence || configs['subject'], @template.preferences['documents_copy_email_body'].presence || configs['body'], @template.preferences['documents_copy_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['documents_copy_email_attach_audit'] != false) do |ff| %>
<div class="form-control">
<%= ff.label :documents_copy_email_subject, 'Email subject', class: 'label' %>
<%= ff.text_field :documents_copy_email_subject, required: true, class: 'base-input', dir: 'auto' %>
@@ -98,6 +99,12 @@
<%= ff.text_area :documents_copy_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
</autoresize-textarea>
</div>
<div class="flex items-center justify-between pt-2.5 px-1 mb-2">
<span>
Attach Audit Log PDF to the email
</span>
<%= ff.check_box :documents_copy_email_attach_audit, { checked: ff.object.documents_copy_email_attach_audit != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['attach_audit_log'] == false }, 'true', 'false' %>
</div>
<div class="flex items-center justify-between py-2.5 px-1 mb-2">
<span>
Send emails automatically on completion
@@ -114,6 +121,53 @@
<% end %>
</div>
</div>
<div class="collapse collapse-arrow join-item border border-base-300">
<input type="checkbox" name="accordion">
<div class="collapse-title text-xl font-medium">
Completed notification email
</div>
<div class="collapse-content">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' } do |f| %>
<toggle-on-submit data-element-id="email_saved_alert3"></toggle-on-submit>
<% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY).value %>
<%= f.fields_for :preferences, Struct.new(:completed_notification_email_subject, :completed_notification_email_body, :completed_notification_email_enabled, :completed_notification_email_attach_audit).new(@template.preferences['completed_notification_email_subject'].presence || configs['subject'], @template.preferences['completed_notification_email_body'].presence || configs['body'], @template.preferences['completed_notification_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['completed_notification_email_attach_audit'] != false) do |ff| %>
<div class="form-control">
<%= ff.label :completed_notification_email_subject, 'Email subject', class: 'label' %>
<%= ff.text_field :completed_notification_email_subject, required: true, class: 'base-input', dir: 'auto' %>
</div>
<div class="form-control">
<div class="flex items-center">
<%= ff.label :completed_notification_email_body, 'Email body', class: 'label' %>
<span class="tooltip tooltip-right" data-tip="Use following placeholders text: <%= AccountConfig::DEFAULT_VALUES.dig(AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY, 'body').scan(/{{.*?}}/).join(', ') %>">
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
</span>
</div>
<autoresize-textarea>
<%= ff.text_area :completed_notification_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
</autoresize-textarea>
</div>
<div class="flex items-center justify-between pt-2.5 px-1 mb-2">
<span>
Attach Audit Log PDF to the email
</span>
<%= ff.check_box :completed_notification_email_attach_audit, { checked: ff.object.completed_notification_email_attach_audit != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['attach_audit_log'] == false }, 'true', 'false' %>
</div>
<div class="flex items-center justify-between py-2.5 px-1 mb-2">
<span>
Send emails automatically on completion
</span>
<%= ff.check_box :completed_notification_email_enabled, { checked: ff.object.completed_notification_email_enabled != false, class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'true', 'false' %>
</div>
<% end %>
<div class="form-control pt-2">
<%= f.button button_title(title: 'Save', disabled_with: 'Saving'), class: 'base-button' %>
<div class="flex justify-center">
<span id="email_saved_alert3" class="text-sm invisible font-normal mt-0.5">Changes have been saved</span>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
<% if show_api %>
+1 -1
View File
@@ -16,7 +16,7 @@
<%= form_for @user_config, url: user_initials_path, method: :put, data: { turbo_frame: :_top }, html: { autocomplete: :off, enctype: 'multipart/form-data' } do |f| %>
<signature-form class="relative block">
<a class="absolute top-1 right-1 link text-sm" data-target="signature-form.clear" href="#">Clear</a>
<canvas data-target="signature-form.canvas" class="bg-white border border-base-300 rounded"></canvas>
<canvas data-target="signature-form.canvas" class="bg-white border border-base-300 w-full rounded"></canvas>
<input name="file" class="hidden" data-target="signature-form.input" type="file" accept="image/png,image/jpeg,image/jpg">
<div class="form-control mt-4">
<%= f.button button_title(title: 'Save', disabled_with: 'Saving'), class: 'base-button', data: { target: 'signature-form.button' } %>
+1 -1
View File
@@ -16,7 +16,7 @@
<%= form_for @user_config, url: user_signature_path, method: :put, data: { turbo_frame: :_top }, html: { autocomplete: :off, enctype: 'multipart/form-data' } do |f| %>
<signature-form class="relative block">
<a class="absolute top-1 right-1 link text-sm" data-target="signature-form.clear" href="#">Clear</a>
<canvas data-target="signature-form.canvas" class="bg-white border border-base-300 rounded"></canvas>
<canvas data-target="signature-form.canvas" class="bg-white border border-base-300 w-full rounded"></canvas>
<input name="file" class="hidden" data-target="signature-form.input" type="file" accept="image/png,image/jpeg,image/jpg">
<div class="form-control mt-4">
<%= f.button button_title(title: 'Save', disabled_with: 'Saving'), class: 'base-button', data: { target: 'signature-form.button' } %>
+1 -1
View File
@@ -19,7 +19,7 @@ module DocuSeal
class Application < Rails::Application
config.load_defaults 7.1
config.autoload_lib(ignore: %w[assets tasks])
config.autoload_lib(ignore: %w[assets tasks puma])
config.active_storage.routes_prefix = ''
+1 -35
View File
@@ -2,41 +2,7 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
if ENV['RAILS_ENV'] == 'production' && ENV['SECRET_KEY_BASE'].to_s.empty?
require 'dotenv'
require 'securerandom'
dotenv_path = "#{ENV.fetch('WORKDIR', '.')}/docuseal.env"
unless File.exist?(dotenv_path)
default_env = <<~TEXT
DATABASE_URL= # keep empty to use sqlite or specify postgresql database URL
SECRET_KEY_BASE=#{SecureRandom.hex(64)}
TEXT
File.write(dotenv_path, default_env)
end
database_url = ENV.fetch('DATABASE_URL', nil)
Dotenv.load(dotenv_path)
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].to_s.empty? ? database_url : ENV.fetch('DATABASE_URL', nil)
end
if ENV['DATABASE_URL'].to_s.split('@').last.to_s.split('/').first.to_s.include?('_')
require 'addressable'
url = Addressable::URI.parse(ENV.fetch('DATABASE_URL', ''))
ENV['DATABASE_HOST'] = url.host
ENV['DATABASE_PORT'] = (url.port || 5432).to_s
ENV['DATABASE_USER'] = url.user
ENV['DATABASE_PASSWORD'] = url.password
ENV['DATABASE_NAME'] = url.path.to_s.delete_prefix('/')
ENV.delete('DATABASE_URL')
end
require_relative 'dotenv'
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
+4 -2
View File
@@ -1,7 +1,7 @@
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch('RAILS_MAX_THREADS', 15) %>
pool: <%= ENV.fetch('RAILS_MAX_THREADS', 15).to_i + ENV.fetch('SIDEKIQ_THREADS', 5).to_i %>
development:
<<: *default
@@ -22,12 +22,14 @@ production:
<% elsif ENV['DATABASE_URL'].to_s.empty? %>
adapter: sqlite3
database: <%= ENV['WORKDIR'] || '.' %>/db.sqlite3
pool: <%= ENV.fetch('RAILS_MAX_THREADS', 15).to_i + ENV.fetch('SIDEKIQ_THREADS', 5).to_i %>
timeout: 5000
<% elsif ENV['DATABASE_URL'].match?(/\Apostgres/) %>
<<: *default
url: <%= ENV['DATABASE_URL'] %>
<% elsif ENV['DATABASE_URL'].match?(/\Amysql/) %>
adapter: mysql2
encoding: utf8mb4
pool: <%= ENV.fetch('RAILS_MAX_THREADS', 15) %>
pool: <%= ENV.fetch('RAILS_MAX_THREADS', 15).to_i + ENV.fetch('SIDEKIQ_THREADS', 5).to_i %>
url: <%= ENV['DATABASE_URL'] %>
<% end %>
+46
View File
@@ -0,0 +1,46 @@
# frozen_string_literal: true
if ENV['RAILS_ENV'] == 'production' && ENV['SECRET_KEY_BASE'].to_s.empty?
require 'dotenv'
require 'securerandom'
dotenv_path = "#{ENV.fetch('WORKDIR', '.')}/docuseal.env"
unless File.exist?(dotenv_path)
default_env = <<~TEXT
DATABASE_URL= # keep empty to use sqlite or specify postgresql database URL
SECRET_KEY_BASE=#{SecureRandom.hex(64)}
TEXT
File.write(dotenv_path, default_env)
end
database_url = ENV.fetch('DATABASE_URL', nil)
Dotenv.load(dotenv_path)
ENV['DATABASE_URL'] = ENV['DATABASE_URL'].to_s.empty? ? database_url : ENV.fetch('DATABASE_URL', nil)
end
if ENV['DATABASE_URL'].to_s.split('@').last.to_s.split('/').first.to_s.include?('_')
require 'addressable'
url = Addressable::URI.parse(ENV.fetch('DATABASE_URL', ''))
ENV['DATABASE_HOST'] = url.host
ENV['DATABASE_PORT'] = (url.port || 5432).to_s
ENV['DATABASE_USER'] = url.user
ENV['DATABASE_PASSWORD'] = url.password
ENV['DATABASE_NAME'] = url.path.to_s.delete_prefix('/')
ENV.delete('DATABASE_URL')
end
if ENV['REDIS_URL'].to_s.empty?
require 'digest'
redis_password = Digest::SHA1.hexdigest("redis#{ENV.fetch('SECRET_KEY_BASE', '')}")
ENV['REDIS_URL'] = "redis://default:#{redis_password}@0.0.0.0:6379/0"
ENV['LOCAL_REDIS_URL'] = ENV.fetch('REDIS_URL', nil)
end
+1 -1
View File
@@ -47,7 +47,7 @@ Rails.application.configure do
config.cache_store = :null_store
end
config.active_job.queue_adapter = :sidekiq if defined?(Sidekiq)
config.active_job.queue_adapter = :sidekiq
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :disk
+1 -1
View File
@@ -27,7 +27,7 @@ Rails.application.configure do
config.action_controller.perform_caching = true
config.active_record.sqlite3_production_warning = false
config.active_job.queue_adapter = :sidekiq if defined?(Sidekiq)
config.active_job.queue_adapter = :sidekiq
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
+1 -1
View File
@@ -44,7 +44,7 @@ Rails.application.configure do
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.active_job.queue_adapter = :test
config.active_job.queue_adapter = :sidekiq
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
+4 -6
View File
@@ -1,16 +1,14 @@
# frozen_string_literal: true
if defined?(Sidekiq)
require 'sidekiq/web'
require 'sidekiq/web' if defined?(Puma)
if !ENV['SIDEKIQ_BASIC_AUTH_PASSWORD'].to_s.empty? && defined?(Sidekiq::Web)
Sidekiq::Web.use(Rack::Auth::Basic) do |_, password|
next true if Rails.env.development?
ActiveSupport::SecurityUtils.secure_compare(
Digest::SHA256.hexdigest(password),
Digest::SHA256.hexdigest(ENV.fetch('SIDEKIQ_BASIC_AUTH_PASSWORD'))
)
end
Sidekiq.strict_args!
end
Sidekiq.strict_args!
+10 -3
View File
@@ -5,7 +5,9 @@
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
require_relative 'dotenv'
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 15)
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
@@ -41,5 +43,10 @@ workers ENV.fetch('WEB_CONCURRENCY', 0)
#
# preload_app!
# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
if ENV['MULTITENANT'] != 'true' || ENV['DEMO'] == 'true'
require_relative '../lib/puma/plugin/redis_server'
require_relative '../lib/puma/plugin/sidekiq_embed'
plugin :sidekiq_embed
plugin :redis_server
end
+7 -1
View File
@@ -2,7 +2,12 @@
Rails.application.routes.draw do
mount LetterOpenerWeb::Engine, at: '/letter_opener' if Rails.env.development?
mount Sidekiq::Web => '/sidekiq' if defined?(Sidekiq)
if !Docuseal.multitenant? && defined?(Sidekiq::Web)
authenticated :user, ->(u) { u.sidekiq? } do
mount Sidekiq::Web => '/jobs'
end
end
root 'dashboard#index'
@@ -71,6 +76,7 @@ Rails.application.routes.draw do
resources :template_sharings_testing, only: %i[create]
resources :templates, only: %i[index], controller: 'templates_dashboard'
resources :templates, only: %i[new create edit update show destroy] do
resource :debug, only: %i[show], controller: 'templates_debug' if Rails.env.development?
resources :documents, only: %i[create], controller: 'template_documents'
resources :restore, only: %i[create], controller: 'templates_restore'
resources :archived, only: %i[index], controller: 'templates_archived_submissions'
+1
View File
@@ -7,3 +7,4 @@ queues:
production:
:concurrency: 15
:max_retries: 5
@@ -0,0 +1,8 @@
# frozen_string_literal: true
class AddIndexOnExternalId < ActiveRecord::Migration[7.1]
def change
add_index :submitters, :external_id
add_index :templates, :external_id
end
end
+3 -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_06_04_070648) do
ActiveRecord::Schema[7.1].define(version: 2024_06_24_102526) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -200,6 +200,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_04_070648) do
t.text "preferences", null: false
t.text "metadata", null: false
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
t.index ["submission_id"], name: "index_submitters_on_submission_id"
end
@@ -242,6 +243,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_04_070648) do
t.text "preferences", null: false
t.index ["account_id"], name: "index_templates_on_account_id"
t.index ["author_id"], name: "index_templates_on_author_id"
t.index ["external_id"], name: "index_templates_on_external_id"
t.index ["folder_id"], name: "index_templates_on_folder_id"
t.index ["slug"], name: "index_templates_on_slug", unique: true
end
+11 -6
View File
@@ -5,13 +5,18 @@ module Abilities
module_function
def collection(user, ability: nil)
shared_ids =
Template.joins(:template_sharings)
.where(template_sharings: { ability:,
account_id: [user.account_id, TemplateSharing::ALL_ID] }.compact)
.select(:id)
template_ids = Template.where(account_id: user.account_id).select(:id)
Template.where(account_id: user.account_id).or(Template.where(id: shared_ids))
shared_ids =
TemplateSharing.where({ ability:,
account_id: [user.account_id, TemplateSharing::ALL_ID] }.compact)
.select(:template_id)
join_query = Template.arel_table
.join(Arel::Nodes::TableAlias.new(template_ids.arel.union(shared_ids.arel), 'union_ids'))
.on(Template.arel_table[:id].eq(Arel::Table.new(:union_ids)[:id]))
Template.joins(join_query.join_sources.first)
end
def entity(template, user:, ability: nil)
+1
View File
@@ -11,6 +11,7 @@ module Docuseal
DISCORD_URL = 'https://discord.gg/qygYCDGck9'
TWITTER_URL = 'https://twitter.com/docusealco'
TWITTER_HANDLE = '@docusealco'
CHATGPT_URL = 'https://chatgpt.com/g/g-9hg8AAw0r-docuseal'
SUPPORT_EMAIL = 'support@docuseal.co'
HOST = ENV.fetch('HOST', 'localhost')
CONSOLE_URL = if Rails.env.development?
+70
View File
@@ -0,0 +1,70 @@
# frozen_string_literal: true
require 'puma/plugin'
# rubocop:disable Metrics
Puma::Plugin.create do
def start(launcher)
return if ENV['LOCAL_REDIS_URL'].to_s.empty?
@puma_pid = $PROCESS_ID
launcher.events.on_booted do
@redis_server_pid = fork_redis
end
in_background { monitor_redis }
at_exit do
stop_redis_server if Process.pid == @puma_pid
end
launcher.events.on_stopped { stop_redis_server }
launcher.events.on_restart { stop_redis_server }
end
private
def monitor_redis
loop do
if redis_dead?
Process.kill(:INT, @puma_pid)
break
end
sleep 5
end
end
def redis_dead?
return false unless @redis_server_pid
Process.waitpid(@redis_server_pid, Process::WNOHANG)
false
rescue Errno::ECHILD, Errno::ESRCH
true
end
def fork_redis
fork do
Process.setsid
Dir.chdir(ENV.fetch('WORKDIR', nil)) unless ENV['WORKDIR'].to_s.empty?
exec('redis-server', '--requirepass', Digest::SHA1.hexdigest("redis#{ENV.fetch('SECRET_KEY_BASE', '')}"),
out: '/dev/null')
end
end
def stop_redis_server
if @redis_server_pid
Process.kill(:INT, @redis_server_pid)
Process.wait(@redis_server_pid)
end
rescue Errno::ECHILD, Errno::ESRCH
nil
end
end
# rubocop:enable Metrics
+74
View File
@@ -0,0 +1,74 @@
# frozen_string_literal: true
require 'puma/plugin'
# rubocop:disable Metrics
Puma::Plugin.create do
def config(cfg)
return if cfg.instance_variable_get(:@options)[:workers] <= 0
cfg.on_worker_boot { start_sidekiq! }
cfg.on_worker_shutdown { @sidekiq&.stop }
cfg.on_refork { @sidekiq&.stop }
end
def start(launcher)
launcher.events.on_booted do
next if Puma.stats_hash[:workers].to_i != 0
start_sidekiq!
end
launcher.events.on_stopped { Thread.new { @sidekiq&.stop }.join }
launcher.events.on_restart { Thread.new { @sidekiq&.stop }.join }
end
def fire_event(config, event)
arr = config[:lifecycle_events][event]
arr.each(&:call)
arr.clear
end
def start_sidekiq!
Thread.new do
wait_for_redis!
configs = Sidekiq.configure_embed do |config|
config.logger.level = Logger::INFO
sidekiq_config = YAML.load_file('config/sidekiq.yml')
config.queues = sidekiq_config['queues']
config.concurrency = ENV.fetch('SIDEKIQ_THREADS', 5).to_i
config.merge!(sidekiq_config)
config[:max_retries] = 13
ActiveSupport.run_load_hooks(:sidekiq_config, config)
end.instance_variable_get(:@config)
@sidekiq = Sidekiq::Launcher.new(configs, embedded: true)
@sidekiq.run
fire_event(configs, :startup)
end
end
def wait_for_redis!
attempt = 0
loop do
attempt += 1
sleep (attempt - 1) / 10.0
RedisClient.new(url: ENV.fetch('REDIS_URL', nil)).call('GET', '1')
break
rescue RedisClient::CannotConnectError
raise('Unable to connect to redis') if attempt > 10
end
end
end
# rubocop:enable Metrics
-6
View File
@@ -20,12 +20,6 @@ module SubmissionEvents
module_function
def build_tracking_param_legacy(submitter, event_type = 'click_email')
Base64.urlsafe_encode64(
[submitter.slug, event_type].join(':')
).first(TRACKING_PARAM_LENGTH)
end
def build_tracking_param(submitter, event_type = 'click_email')
Base64.urlsafe_encode64(
Digest::SHA1.digest([submitter.slug, event_type, Rails.application.secret_key_base].join(':'))
@@ -120,7 +120,11 @@ module Submissions
width = page.box.width
height = page.box.height
font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * FONT_SIZE).to_i
preferences_font_size = field.dig('preferences', 'font_size').then { |num| num.present? ? num.to_i : nil }
font_size = preferences_font_size
font_size ||= (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * FONT_SIZE).to_i
value = submitter.values[field['uuid']]
@@ -265,7 +269,7 @@ module Submissions
lines = layouter.fit([text], area['w'] * width, height).lines
box_height = lines.sum(&:height)
if box_height > (area['h'] * height) + 1
if preferences_font_size.blank? && box_height > (area['h'] * height) + 1
text = HexaPDF::Layout::TextFragment.create(value,
font: pdf.fonts.add(FONT_NAME),
font_size: (font_size / 1.4).to_i)
@@ -275,7 +279,7 @@ module Submissions
box_height = lines.sum(&:height)
end
if box_height > (area['h'] * height) + 1
if preferences_font_size.blank? && box_height > (area['h'] * height) + 1
text = HexaPDF::Layout::TextFragment.create(value,
font: pdf.fonts.add(FONT_NAME),
font_size: (font_size / 1.9).to_i)
+1 -1
View File
@@ -73,7 +73,7 @@ module Submitters
next if submitter.email.blank?
next if submitter.preferences['send_email'] == false
SendSubmitterInvitationEmailJob.perform_later('submitter_id' => submitter.id)
SendSubmitterInvitationEmailJob.perform_async('submitter_id' => submitter.id)
end
end
end
+2 -2
View File
@@ -14,14 +14,14 @@ module Submitters
unless submitter.submission_events.exists?(event_type: 'start_form')
SubmissionEvents.create_with_tracking_data(submitter, 'start_form', request)
SendFormStartedWebhookRequestJob.perform_later(submitter)
SendFormStartedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id })
end
update_submitter!(submitter, params, request)
submitter.submission.save!
ProcessSubmitterCompletionJob.perform_later(submitter) if submitter.completed_at?
ProcessSubmitterCompletionJob.perform_async({ 'submitter_id' => submitter.id }) if submitter.completed_at?
submitter
end
+4 -4
View File
@@ -9,17 +9,17 @@ module Templates
module_function
def call(template, params)
def call(template, params, extract_fields: false)
Array.wrap(params[:files].presence || params[:file]).map do |file|
if file.content_type.exclude?('image') && file.content_type != PDF_CONTENT_TYPE
next handle_file_types(template, file, params)
end
handle_pdf_or_image(template, file, file.read, params)
handle_pdf_or_image(template, file, file.read, params, extract_fields:)
end
end
def handle_pdf_or_image(template, file, document_data = nil, params = {})
def handle_pdf_or_image(template, file, document_data = nil, params = {}, extract_fields: false)
document_data ||= file.read
if file.content_type == PDF_CONTENT_TYPE
@@ -44,7 +44,7 @@ module Templates
document = template.documents.create!(blob:)
Templates::ProcessDocument.call(document, document_data)
Templates::ProcessDocument.call(document, document_data, extract_fields:)
end
def maybe_decrypt_pdf_or_raise(data, params)
+234
View File
@@ -0,0 +1,234 @@
# frozen_string_literal: true
module Templates
module FindAcroFields
PDF_CONTENT_TYPE = 'application/pdf'
FIELD_NAME_REGEXP = /\A(?=.*\p{L})[\p{L}\d\s]+\z/
module_function
# rubocop:disable Metrics
def call(pdf, attachment)
return [] unless pdf.acro_form
fields, annots_index = build_fields_with_pages(pdf)
fields.filter_map do |field|
areas = Array.wrap(field[:Kids] || field).filter_map do |child_field|
page = annots_index[child_field.hash]
media_box = page[:MediaBox]
crop_box = page[:CropBox] || media_box
media_box_start = [media_box[0], media_box[1]]
crop_shift = [crop_box[0] - media_box[0], crop_box[1] - media_box[1]]
x0, y0, x1, y1 = child_field[:Rect]
x0, y0 = correct_coordinates(x0, y0, crop_shift, media_box_start)
x1, y1 = correct_coordinates(x1, y1, crop_shift, media_box_start)
page_width = media_box[2] - media_box[0]
page_height = media_box[3] - media_box[1]
x = x0
y = y0
w = x1 - x0
h = y1 - y0
transformed_y = page_height - y - h
attrs = {
page: page.index,
x: x / page_width,
y: transformed_y / page_height,
w: w / page_width,
h: h / page_height,
attachment_uuid: attachment.uuid
}
next if attrs[:w].zero? || attrs[:h].zero?
if child_field[:MaxLen] && child_field.concrete_field_type == :comb_text_field
attrs[:cell_w] = w / page_width / child_field[:MaxLen].to_f
end
attrs
end
next if areas.blank?
field_properties = build_field_properties(field)
next if field_properties.blank?
next if field_properties[:default_value].present?
if field_properties[:type].in?(%w[radio multiple])
if areas.size != field_properties[:options].size
field_properties[:options] = build_options(Array.new(areas.size, ''))
end
areas.each_with_index do |area, index|
area[:option_uuid] = field_properties[:options][index][:uuid]
end
end
{
uuid: SecureRandom.uuid,
required: false,
preferences: {},
areas:,
**field_properties
}
end
rescue StandardError => e
raise if Rails.env.local?
Rollbar.error(e) if defined?(Rollbar)
[]
end
def correct_coordinates(x_coord, y_coord, shift, media_box_start)
corrected_x = x_coord + shift[0] - media_box_start[0]
corrected_y = y_coord + shift[1] - media_box_start[1]
[corrected_x, corrected_y]
end
def build_field_properties(field)
field_name = field.full_field_name if field.full_field_name.to_s.match?(FIELD_NAME_REGEXP)
field_name = field_name&.encode('utf-8', invalid: :replace, undef: :replace, replace: '')
if field.field_type == :Btn && field.concrete_field_type == :radio_button && field[:Opt].present?
selected_option_index = (field.allowed_values || []).find_index(field.field_value)
selected_option = field[:Opt][selected_option_index] if selected_option_index
{
name: field_name.to_s,
type: 'radio',
description: field[:TU],
options: build_options(field[:Opt], 'radio'),
default_value: selected_option
}
elsif field.field_type == :Btn && field.concrete_field_type == :check_box &&
field[:Kids].present? && field[:Kids].size > 1 && field.allowed_values.size > 1
selected_option = (field.allowed_values || []).find { |v| v == field.field_value }
return {} if field.allowed_values.include?(:BBox)
{
name: field_name.to_s,
type: 'radio',
description: field[:TU],
options: build_options(field.allowed_values, 'radio'),
default_value: selected_option
}
elsif field.field_type == :Btn && field.concrete_field_type == :check_box
{
name: field_name.to_s,
type: 'checkbox',
description: field[:TU],
default_value: field.field_value.present?
}
elsif field.field_type == :Ch &&
%i[combo_box editable_combo_box].include?(field.concrete_field_type) && field[:Opt].present?
{
name: field_name.to_s,
type: 'select',
description: field[:TU],
options: build_options(field[:Opt]),
default_value: field.field_value
}
elsif field.field_type == :Ch && field.concrete_field_type == :multi_select && field[:Opt].present?
{
name: field_name.to_s,
type: 'multiple',
description: field[:TU],
options: build_options(field[:Opt], 'multiple'),
default_value: field.field_value
}
elsif field.field_type == :Tx && field.concrete_field_type == :comb_text_field
{
name: field_name.to_s,
type: 'cells',
description: field[:TU],
default_value: field.field_value
}
elsif field.field_type == :Tx
{
name: field_name.to_s,
type: 'text',
description: field[:TU],
default_value: field.field_value
}
elsif field.field_type == :Sig
{
name: field_name.to_s,
type: 'signature',
description: field[:TU]
}
else
{}
end.compact
end
def build_options(values, type = nil)
is_skip_single_value = type.in?(%w[radio multiple]) && values.uniq.size == 1
values.map do |option|
is_option_number = option.is_a?(Symbol) && option.to_s.match?(/\A\d+\z/)
option = option.encode('utf-8', invalid: :replace, undef: :replace, replace: '') if option.is_a?(String)
{
uuid: SecureRandom.uuid,
value: is_option_number || is_skip_single_value ? '' : option
}
end
end
def build_fields_with_pages(pdf)
fields_index = {}
annots_index = {}
pdf.pages.each do |page|
page.each_annotation do |annot|
annots_index[annot.hash] = page
if !annot.key?(:Parent) && annot.key?(:FT)
fields_index[annot.hash] ||= HexaPDF::Type::AcroForm::Field.wrap(pdf, annot)
elsif annot.key?(:Parent)
field = annot[:Parent]
field = field[:Parent] while field[:Parent]
fields_index[field.hash] ||= HexaPDF::Type::AcroForm::Field.wrap(pdf, field)
end
end
end
[process_fields_array(pdf, fields_index.values), annots_index]
end
def process_fields_array(pdf, array, acc = [])
array.each_with_index do |field, index|
next if field.nil?
unless field.respond_to?(:type) && field.type == :XXAcroFormField
array[index] = field = HexaPDF::Type::AcroForm::Field.wrap(pdf, field)
end
if field.terminal_field?
acc << field
else
process_fields_array(pdf, field[:Kids], acc)
end
end
acc
end
# rubocop:enable Metrics
end
end
+25 -5
View File
@@ -10,14 +10,22 @@ module Templates
Q = 35
MAX_WIDTH = 1400
MAX_NUMBER_OF_PAGES_PROCESSED = 15
MAX_FLATTEN_FILE_SIZE = 15.megabytes
MAX_FLATTEN_FILE_SIZE = 20.megabytes
GENERATE_PREVIEW_SIZE_LIMIT = 50.megabytes
module_function
def call(attachment, data)
def call(attachment, data, extract_fields: false)
if attachment.content_type == PDF_CONTENT_TYPE
generate_pdf_preview_images(attachment, data)
if extract_fields && data.size < MAX_FLATTEN_FILE_SIZE
pdf = HexaPDF::Document.new(io: StringIO.new(data))
fields = Templates::FindAcroFields.call(pdf, attachment)
end
generate_pdf_preview_images(attachment, data, pdf)
attachment.metadata['pdf']['fields'] = fields if fields
elsif attachment.image?
generate_preview_image(attachment, data)
end
@@ -43,10 +51,10 @@ module Templates
)
end
def generate_pdf_preview_images(attachment, data)
def generate_pdf_preview_images(attachment, data, pdf = nil)
ActiveStorage::Attachment.where(name: ATTACHMENT_NAME, record: attachment).destroy_all
pdf = HexaPDF::Document.new(io: StringIO.new(data))
pdf ||= HexaPDF::Document.new(io: StringIO.new(data))
number_of_pages = pdf.pages.size
data = maybe_flatten_form(data, pdf)
@@ -97,6 +105,18 @@ module Templates
data
end
def normalize_attachment_fields(template, attachments = template.documents)
attachments.flat_map do |a|
pdf_fields = a.metadata['pdf'].delete('fields').to_a if a.metadata['pdf'].present?
next [] if pdf_fields.blank?
pdf_fields.each { |f| f['submitter_uuid'] = template.submitters.first['uuid'] }
pdf_fields
end
end
def generate_pdf_preview_from_file(attachment, file_path, page_number)
io = StringIO.new
+11
View File
@@ -9,6 +9,9 @@ require 'rspec/rails'
require 'capybara/cuprite'
require 'capybara/rspec'
require 'webmock/rspec'
require 'sidekiq/testing'
Sidekiq::Testing.fake!
WebMock.disable_net_connect!(allow_localhost: true)
@@ -56,4 +59,12 @@ RSpec.configure do |config|
driven_by :headless_cuprite
end
end
config.before do
Sidekiq::Worker.clear_all
end
config.before do |example|
Sidekiq::Testing.inline! if example.metadata[:sidekiq] == :inline
end
end
+1 -1
View File
@@ -14,7 +14,7 @@ RSpec.describe 'Personalization' do
it 'shows the personalization page' do
expect(page).to have_content('Email Templates')
expect(page).to have_content('Signature Request Email')
expect(page).to have_content('Form Completed Email')
expect(page).to have_content('Completed Notification Email')
expect(page).to have_content('Documents Copy Email')
expect(page).to have_content('Company Logo')
expect(page).to have_content('Unlock with DocuSeal Pro')
+1 -1
View File
@@ -81,7 +81,7 @@ RSpec.describe 'Submit Form' do
expect do
click_on 'submit'
end.to change(enqueued_jobs, :size).by(2)
end.to change(enqueued_jobs, :size).by(1)
end
end
end