Compare commits

..
2 Commits
Author SHA1 Message Date
Pete Matsyburka e64f187f85 fix font url 2024-08-12 13:55:36 +03:00
Pete Matsyburka 416685334a adjust retries 2024-08-12 13:54:13 +03:00
112 changed files with 423 additions and 2168 deletions

No files matched your search

+3 -5
View File
@@ -11,7 +11,7 @@ jobs:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.4
ruby-version: 3.3.3
- name: Cache gems
uses: actions/cache@v1
with:
@@ -35,7 +35,7 @@ jobs:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.4
ruby-version: 3.3.3
- name: Cache gems
uses: actions/cache@v1
with:
@@ -100,15 +100,13 @@ jobs:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.4
ruby-version: 3.3.3
- name: Set up Node
uses: actions/setup-node@v1
with:
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:
-3
View File
@@ -34,7 +34,6 @@ Metrics/MethodLength:
Max: 30
Exclude:
- 'db/migrate/**'
- 'spec/**/*'
Metrics/CyclomaticComplexity:
Max: 15
@@ -47,8 +46,6 @@ Layout/LineLength:
Metrics/AbcSize:
Max: 45
Exclude:
- spec/**/*
Metrics/ModuleLength:
Max: 500
+3 -3
View File
@@ -1,4 +1,4 @@
FROM ruby:3.3.4-alpine as fonts
FROM ruby:3.3.3-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.4-alpine as webpack
FROM ruby:3.3.3-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.4-alpine as app
FROM ruby:3.3.3-alpine as app
ENV RAILS_ENV=production
ENV BUNDLE_WITHOUT="development:test"
+1 -2
View File
@@ -2,7 +2,7 @@
source 'https://rubygems.org'
ruby '3.3.4'
ruby '3.3.3'
gem 'arabic-letter-connector', require: 'arabic-letter-connector/logic'
gem 'aws-sdk-s3', require: false
@@ -23,7 +23,6 @@ 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 -5
View File
@@ -324,10 +324,9 @@ GEM
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-smtp (0.5.0)
net-protocol
nio4r (2.7.1)
nokogiri (1.16.7)
@@ -435,7 +434,7 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
retriable (3.1.2)
rexml (3.3.6)
rexml (3.3.3)
strscan
rotp (6.3.0)
rqrcode (2.2.0)
@@ -592,7 +591,6 @@ DEPENDENCIES
letter_opener_web
lograge
mysql2
net-smtp (= 0.4.0)
oj
pagy
pg
@@ -625,7 +623,7 @@ DEPENDENCIES
webmock
RUBY VERSION
ruby 3.3.4p94
ruby 3.3.3p89
BUNDLED WITH
2.5.3
@@ -15,7 +15,6 @@ 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,8 +11,7 @@ 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,
combined_document_attachment: :blob }],
submitters.preload(template: :folder, submission: [:submitters, { audit_trail_attachment: :blob }],
documents_attachments: :blob, attachments_attachments: :blob),
field: :completed_at
)
@@ -1,52 +0,0 @@
# 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,14 +19,10 @@ module Api
submissions = paginate(submissions.preload(:created_by_user, :submitters,
template: :folder,
combined_document_attachment: :blob,
audit_trail_attachment: :blob))
render json: {
data: submissions.map do |s|
Submissions::SerializeForApi.call(s, s.submitters, params,
with_events: false, with_documents: false, with_values: false)
end,
data: submissions.as_json(Submissions::SerializeForApi::SERIALIZE_PARAMS),
pagination: {
count: submissions.size,
next: submissions.last&.id,
@@ -80,7 +76,7 @@ module Api
end
render json: build_create_json(submissions)
rescue Submitters::NormalizeValues::BaseError, DownloadUtils::UnableToDownload => e
rescue Submitters::NormalizeValues::BaseError => e
Rollbar.warning(e) if defined?(Rollbar)
render json: { error: e.message }, status: :unprocessable_entity
@@ -77,10 +77,6 @@ module Api
with_urls: true,
with_events: false,
params:)
rescue Submitters::NormalizeValues::BaseError, DownloadUtils::UnableToDownload => e
Rollbar.warning(e) if defined?(Rollbar)
render json: { error: e.message }, status: :unprocessable_entity
end
def submitter_params
+1 -2
View File
@@ -95,9 +95,8 @@ module Api
def template_params
permitted_params = [
:name,
:external_id,
{
submitters: [%i[name uuid is_requester linked_to_uuid email]],
submitters: [%i[name uuid]],
fields: [[:uuid, :submitter_uuid, :name, :type,
:required, :readonly, :default_value,
:title, :description,
+13 -27
View File
@@ -11,28 +11,30 @@ class StartFormController < ApplicationController
def show
@submitter = @template.submissions.new(account_id: @template.account_id)
.submitters.new(uuid: filter_undefined_submitters(@template).first['uuid'])
.submitters.new(uuid: @template.submitters.first['uuid'])
end
def update
return redirect_to start_form_path(@template.slug) if @template.archived_at?
@submitter = find_or_initialize_submitter(@template, submitter_params)
@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)
if @submitter.completed_at?
redirect_to start_form_completed_path(@template.slug, email: submitter_params[:email])
else
if filter_undefined_submitters(@template).size > 2 && @submitter.new_record?
if @template.submitters.to_a.size > 1 && @submitter.new_record?
@error_message = 'Not found'
return render :show
end
if (is_new_record = @submitter.new_record?)
assign_submission_attributes(@submitter, @template)
assign_submission_attributes(@submitter, @template) if @submitter.new_record?
Submissions::AssignDefinedSubmitters.call(@submitter.submission)
end
is_new_record = @submitter.new_record?
if @submitter.save
if is_new_record
@@ -54,21 +56,14 @@ 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 =
(Submitter.where(submission: template.submissions).find_by(slug: params[:resubmit]) if params[:resubmit].present?)
if params[:resubmit].present?
Submitter.where(submission: @template.submissions).find_by(slug: params[:resubmit])
end
submitter.assign_attributes(
uuid: filter_undefined_submitters(template).first['uuid'],
uuid: template.submitters.first['uuid'],
ip: request.remote_ip,
ua: request.user_agent,
values: resubmit_submitter&.preferences&.fetch('default_values', nil) || {},
@@ -85,20 +80,11 @@ class StartFormController < ApplicationController
submitter.submission ||= Submission.new(template:,
account_id: template.account_id,
template_submitters: template.submitters,
submitters: [submitter],
source: :link)
submitter.account_id = submitter.submission.account_id
submitter
end
def filter_undefined_submitters(template)
template.submitters.select do |item|
item['linked_to_uuid'].blank? && item['is_requester'].blank? && item['email'].blank?
end
end
def submitter_params
params.require(:submitter).permit(:email, :phone, :name).tap do |attrs|
attrs[:email] = Submissions.normalize_email(attrs[:email])
@@ -33,7 +33,7 @@ class SubmissionsDownloadController < ApplicationController
return head :not_found
end
if params[:combined] == 'true'
if params[:combined]
url = build_combined_url(submitter)
if url
@@ -15,7 +15,6 @@ 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)
@@ -57,8 +56,6 @@ 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
@@ -1,29 +0,0 @@
# 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
@@ -1,37 +0,0 @@
# 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
@@ -7,10 +7,8 @@ class SubmitFormValuesController < ApplicationController
def index
submitter = Submitter.find_by!(slug: params[:submit_form_slug])
return render json: {} if submitter.completed_at? || submitter.declined_at?
return render json: {} if submitter.submission.template.archived_at? ||
submitter.submission.archived_at? ||
submitter.submission.expired?
return render json: {} if submitter.completed_at?
return render json: {} if submitter.submission.template.archived_at? || submitter.submission.archived_at?
value = submitter.values[params['field_uuid']]
attachment = submitter.attachments.where(created_at: params[:after]..).find_by(uuid: value) if value.present?
+2 -2
View File
@@ -103,7 +103,7 @@ class TemplatesController < ApplicationController
params.require(:template).permit(
:name,
{ schema: [%i[attachment_uuid name]],
submitters: [%i[name uuid is_requester linked_to_uuid email]],
submitters: [%i[name uuid]],
fields: [[:uuid, :submitter_uuid, :name, :type,
:required, :readonly, :default_value,
:title, :description,
@@ -123,7 +123,7 @@ class TemplatesController < ApplicationController
if template.account == current_account
redirect_to(edit_template_path(@template))
else
redirect_back(fallback_location: root_path, notice: 'Template has been cloned')
redirect_back(fallback_location: root_path, notice: 'Template has been clonned')
end
end
@@ -1,49 +0,0 @@
# frozen_string_literal: true
class TemplatesRecipientsController < ApplicationController
load_and_authorize_resource :template
def create
authorize!(:update, @template)
@template.submitters =
submitters_params.map { |s| s.reject { |_, v| v.is_a?(String) && v.blank? } }
@template.save!
render json: { submitters: @template.submitters }
end
private
def submitters_params
params.require(:template).permit(
submitters: [%i[name uuid is_requester linked_to_uuid email option]]
).fetch(:submitters, {}).values.filter_map do |s|
next if s[:uuid].blank?
if s[:is_requester] == '1'
s[:is_requester] = true
else
s.delete(:is_requester)
end
option = s.delete(:option)
if option.present?
case option
when 'is_requester'
s[:is_requester] = true
when 'not_set'
s.delete(:is_requester)
s.delete(:email)
s.delete(:linked_to_uuid)
when /\Alinked_to_(.*)\z/
s[:linked_to_uuid] = ::Regexp.last_match(-1)
end
end
s
end
end
end
@@ -52,7 +52,7 @@ class TemplatesUploadsController < ApplicationController
def create_file_params_from_url
tempfile = Tempfile.new
tempfile.binmode
tempfile.write(DownloadUtils.call(params[:url]).body)
tempfile.write(conn.get(Addressable::URI.parse(params[:url]).display_uri.to_s).body)
tempfile.rewind
file = ActionDispatch::Http::UploadedFile.new(
@@ -65,4 +65,10 @@ class TemplatesUploadsController < ApplicationController
{ files: [file] }
end
def conn
Faraday.new do |faraday|
faraday.response :follow_redirects
end
end
end
@@ -5,7 +5,6 @@ class WebhookPreferencesController < ApplicationController
form.viewed
form.started
form.completed
form.declined
template.created
template.updated
submission.created
+1 -21
View File
@@ -25,9 +25,6 @@ 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 ToggleAttribute from './elements/toggle_attribute'
import LinkedInput from './elements/linked_input'
import * as TurboInstantClick from './lib/turbo_instant_click'
@@ -90,14 +87,9 @@ safeRegisterElement('emails-textarea', EmailsTextarea)
safeRegisterElement('toggle-cookies', ToggleCookies)
safeRegisterElement('toggle-on-submit', ToggleOnSubmit)
safeRegisterElement('password-input', PasswordInput)
safeRegisterElement('search-input', SearchInput)
safeRegisterElement('toggle-attribute', ToggleAttribute)
safeRegisterElement('linked-input', LinkedInput)
safeRegisterElement('template-builder', class extends HTMLElement {
connectedCallback () {
document.addEventListener('turbo:submit-end', this.onSubmit)
this.appElem = document.createElement('div')
this.appElem.classList.add('md:h-screen')
@@ -113,29 +105,17 @@ safeRegisterElement('template-builder', class extends HTMLElement {
withPayment: this.dataset.withPayment === 'true',
isPaymentConnected: this.dataset.isPaymentConnected === 'true',
withFormula: this.dataset.withFormula === 'true',
withSendButton: this.dataset.withSendButton !== 'false',
withSignYourselfButton: this.dataset.withSignYourselfButton !== 'false',
withConditions: this.dataset.withConditions === 'true',
currencies: (this.dataset.currencies || '').split(',').filter(Boolean),
acceptFileTypes: this.dataset.acceptFileTypes
})
this.component = this.app.mount(this.appElem)
this.app.mount(this.appElem)
this.appendChild(this.appElem)
}
onSubmit = (e) => {
if (e.detail.success && e.detail?.formSubmission?.formElement?.id === 'submitters_form') {
e.detail.fetchResponse.response.json().then((data) => {
this.component.template.submitters = data.submitters
})
}
}
disconnectedCallback () {
document.removeEventListener('turbo:submit-end', this.onSubmit)
this.app?.unmount()
this.appElem?.remove()
}
-31
View File
@@ -1,31 +0,0 @@
export default class extends HTMLElement {
connectedCallback () {
if (this.target) {
this.input.value = this.target.value
this.target.addEventListener('input', (e) => {
this.input.value = e.target.value
})
this.target.addEventListener('linked-input.update', (e) => {
this.input.value = e.target.value
})
}
}
get input () {
return this.querySelector('input')
}
get target () {
if (this.dataset.targetId) {
const listItem = this.closest('[data-targets="dynamic-list.items"]')
if (listItem) {
return listItem.querySelector(`#${this.dataset.targetId}`)
} else {
return document.getElementById(this.dataset.targetId)
}
}
}
}
-25
View File
@@ -1,25 +0,0 @@
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)
}
}
@@ -24,7 +24,6 @@ export default class extends HTMLElement {
if (input && item[field]) {
input.value = item[field]
input.dispatchEvent(new CustomEvent('linked-input.update', { bubbles: true }))
}
if (textarea && item[field]) {
@@ -1,28 +0,0 @@
export default class extends HTMLElement {
connectedCallback () {
this.input.addEventListener('change', (event) => {
if (this.dataset.attribute) {
this.target[this.dataset.attribute] = event.target.checked
}
if (this.dataset.className) {
this.target.classList.toggle(this.dataset.className, event.target.value !== this.dataset.value)
if (this.dataset.className === 'hidden' && this.target.tagName === 'INPUT') {
this.target.disabled = event.target.value !== this.dataset.value
}
}
if (this.dataset.attribute === 'disabled') {
this.target.value = ''
}
})
}
get input () {
return this.querySelector('input[type="checkbox"]') || this.querySelector('select')
}
get target () {
return document.getElementById(this.dataset.targetId)
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ export default actionable(class extends HTMLElement {
}
onSubmit = (e) => {
if (e.detail.success && e.detail?.formSubmission?.formElement?.dataset?.closeOnSubmit !== 'false') {
if (e.detail.success) {
this.close()
}
}
+2 -8
View File
@@ -18,15 +18,9 @@ if (token) {
transform (payload) {
payload.body.telemetry = []
if (payload.request.query_string) {
payload.request.query_string = ''
}
const string = JSON.stringify(payload)
if (payload.request.url) {
payload.request.url = payload.request.url.replace(/(\/[sdep]\/)(\w{5})[^/]+/, '$1$2')
}
return payload
return JSON.parse(string.replace(/(\/[des]\/)\w{6}/g, (_, m) => m))
},
payload: {
client: {
+1 -2
View File
@@ -226,8 +226,7 @@ export default {
},
submitter: {
type: Object,
required: false,
default: () => ({})
required: true
},
withSignatureId: {
type: Boolean,
+2 -7
View File
@@ -21,14 +21,14 @@
:values="values"
:field="field"
:area="area"
:submittable="submittable"
:submittable="true"
:field-index="fieldIndex"
:scroll-padding="scrollPadding"
:submitter="submitter"
:with-field-placeholder="withFieldPlaceholder"
:with-signature-id="withSignatureId"
:is-active="currentStep === step"
:with-label="withLabel && !withFieldPlaceholder && step.length < 2"
:with-label="withLabel && !withFieldPlaceholder"
:is-value-set="step.some((f) => f.uuid in values)"
:attachments-index="attachmentsIndex"
@click="$emit('focus-step', stepIndex)"
@@ -58,11 +58,6 @@ export default {
required: false,
default: false
},
submittable: {
type: Boolean,
required: false,
default: true
},
submitter: {
type: Object,
required: true
@@ -181,10 +181,6 @@ export default {
spread: 140
})
}
if (window.decline_button) {
window.decline_button.setAttribute('disabled', 'true')
}
},
methods: {
sendCopyToEmail () {
+3 -12
View File
@@ -13,12 +13,6 @@
:scroll-padding="scrollPadding"
@focus-step="[saveStep(), currentField.type !== 'checkbox' ? isFormVisible = true : '', goToStep($event, false, true)]"
/>
<FieldAreas
:steps="readonlyConditionalFields.map((e) => [e])"
:values="readonlyConditionalFields.reduce((acc, f) => { acc[f.uuid] = f.default_value; return acc }, {})"
:submitter="submitter"
:submittable="false"
/>
<FormulaFieldAreas
v-if="formulaFields.length"
:fields="formulaFields"
@@ -808,9 +802,6 @@ export default {
currentField () {
return this.currentStepFields[0]
},
readonlyConditionalFields () {
return this.fields.filter((f) => f.readonly && f.conditions?.length && this.checkFieldConditions(f))
},
stepFields () {
return this.fields.filter((f) => !f.readonly).reduce((acc, f) => {
const prevStep = acc[acc.length - 1]
@@ -934,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) && field && !this.checkFieldConditions(field)) {
if (['not_empty', 'checked', 'equal', 'contains'].includes(c.action) && !this.checkFieldConditions(field)) {
return false
}
@@ -942,12 +933,12 @@ export default {
return acc && isEmpty(this.values[c.field_uuid])
} else if (['not_empty', 'checked'].includes(c.action)) {
return acc && !isEmpty(this.values[c.field_uuid])
} else if (['equal', 'contains'].includes(c.action) && field) {
} else if (['equal', 'contains'].includes(c.action)) {
const option = field.options.find((o) => o.uuid === c.value)
const values = [this.values[c.field_uuid]].flat()
return acc && values.includes(this.optionValue(option, field.options.indexOf(option)))
} else if (['not_equal', 'does_not_contain'].includes(c.action) && field) {
} else if (['not_equal', 'does_not_contain'].includes(c.action)) {
const option = field.options.find((o) => o.uuid === c.value)
const values = [this.values[c.field_uuid]].flat()
@@ -50,26 +50,6 @@
</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="#"
@@ -117,7 +97,7 @@
<img
v-if="modelValue || computedPreviousValue"
:src="attachmentsIndex[modelValue || computedPreviousValue].url"
class="mx-auto bg-white border border-base-300 rounded max-h-44"
class="mx-auto bg-white border border-base-300 rounded max-h-72"
>
<canvas
v-show="!modelValue && !computedPreviousValue"
@@ -140,18 +120,16 @@
<script>
import { cropCanvasAndExportToPNG } from './crop_canvas'
import { IconReload, IconTextSize, IconUpload, IconSignature, IconArrowsDiagonalMinimize2 } from '@tabler/icons-vue'
import { IconReload, IconTextSize, 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,
@@ -200,8 +178,7 @@ export default {
return {
isInitialsStarted: !!this.previousValue,
isUsePreviousValue: true,
isDrawInitials: false,
uploadImageInputKey: Math.random().toString()
isDrawInitials: false
}
},
computed: {
@@ -252,15 +229,6 @@ 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,11 +569,8 @@ export default {
this.remove()
this.isSignatureStarted = true
this.drawOnCanvas(event.target.files[0], this.$refs.canvas)
const file = event.target.files[0]
this.uploadImageInputKey = Math.random().toString()
},
drawOnCanvas (file, canvas) {
if (file && file.type.match('image.*')) {
const reader = new FileReader()
@@ -583,6 +580,7 @@ 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
@@ -617,6 +615,8 @@ export default {
}
reader.readAsDataURL(file)
this.uploadImageInputKey = Math.random().toString()
}
},
maybeSetSignedUuid (signedUuid) {
+1 -28
View File
@@ -58,7 +58,6 @@
/>
<template v-else>
<a
v-if="withSignYourselfButton"
:href="template.submitters.length > 1 ? `/templates/${template.id}/submissions/new?selfsign=true` : `/d/${template.slug}`"
class="btn btn-primary btn-ghost text-base hidden md:flex"
:target="template.submitters.length > 1 ? '' : '_blank'"
@@ -74,7 +73,6 @@
</span>
</a>
<a
v-if="withSendButton"
:href="`/templates/${template.id}/submissions/new?with_link=true`"
data-turbo-frame="modal"
class="white-button md:!px-6"
@@ -134,17 +132,6 @@
<span class="whitespace-nowrap">Save and Preview</span>
</a>
</li>
<li>
<a
:href="`/templates/${template.id}/preferences`"
data-turbo-frame="modal"
class="flex space-x-2"
@click="closeDropdown"
>
<IconAdjustments class="w-6 h-6 flex-shrink-0" />
<span class="whitespace-nowrap">Preferences</span>
</a>
</li>
</ul>
</div>
</span>
@@ -415,7 +402,7 @@ import Contenteditable from './contenteditable'
import DocumentPreview from './preview'
import DocumentControls from './controls'
import MobileFields from './mobile_fields'
import { IconPlus, IconUsersPlus, IconDeviceFloppy, IconChevronDown, IconEye, IconWritingSign, IconInnerShadowTop, IconInfoCircle, IconAdjustments } from '@tabler/icons-vue'
import { IconPlus, IconUsersPlus, IconDeviceFloppy, IconChevronDown, IconEye, IconWritingSign, IconInnerShadowTop, IconInfoCircle } from '@tabler/icons-vue'
import { v4 } from 'uuid'
import { ref, computed } from 'vue'
import { en as i18nEn } from './i18n'
@@ -439,7 +426,6 @@ export default {
Contenteditable,
IconUsersPlus,
IconChevronDown,
IconAdjustments,
IconEye,
IconDeviceFloppy
},
@@ -493,16 +479,6 @@ export default {
required: false,
default: true
},
withSendButton: {
type: Boolean,
required: false,
default: true
},
withSignYourselfButton: {
type: Boolean,
required: false,
default: true
},
inputMode: {
type: Boolean,
required: false,
@@ -782,9 +758,6 @@ export default {
this.documentRefs = []
},
methods: {
closeDropdown () {
document.activeElement.blur()
},
t (key) {
return this.i18n[key] || i18nEn[key] || key
},
@@ -52,7 +52,7 @@
</template>
<template v-else>
<template
v-for="(icon, type) in fieldIconsSorted"
v-for="(icon, type) in fieldIcons"
:key="type"
>
<li v-if="(fieldTypes.length === 0 || fieldTypes.includes(type)) && (withPhone || type != 'phone') && (withPayment || type != 'payment')">
+7 -24
View File
@@ -15,19 +15,15 @@ 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, is_all_completed:)
enqueue_completed_webhooks(submitter)
end
def enqueue_completed_webhooks(submitter, is_all_completed: false)
def enqueue_completed_webhooks(submitter)
webhook_config = Accounts.load_webhook_config(submitter.account)
if webhook_config
@@ -35,26 +31,13 @@ class ProcessSubmitterCompletionJob
'encrypted_config_id' => webhook_config.id })
end
webhook_urls = submitter.account.webhook_urls
webhook_urls = webhook_urls.where(
webhook_ids = submitter.account.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"%')
)
)
).pluck(:id)
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
webhook_ids.each do |webhook_id|
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id,
'webhook_url_id' => webhook_id })
end
end
@@ -1,51 +0,0 @@
# 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
@@ -1,47 +0,0 @@
# 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
+1 -19
View File
@@ -78,24 +78,6 @@ 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
@@ -157,7 +139,7 @@ class SubmitterMailer < ApplicationMailer
total_size = 0
audit_trail_data = nil
if with_audit_log && submitter.submission.audit_trail.present? && documents.first&.name != 'combined_document'
if with_audit_log && submitter.submission.audit_trail.present?
audit_trail_data = submitter.submission.audit_trail.download
total_size = audit_trail_data.size
+1 -1
View File
@@ -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, dependent: :destroy
has_many :submitters, through: :submissions
has_many :account_linked_accounts, dependent: :destroy
has_many :email_events, dependent: :destroy
has_many :webhook_urls, dependent: :destroy
-1
View File
@@ -40,7 +40,6 @@ 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 => {
+1 -7
View File
@@ -22,7 +22,7 @@
#
# Indexes
#
# index_submissions_on_account_id_and_id (account_id,id)
# index_submissions_on_account_id (account_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,10 +86,4 @@ class Submission < ApplicationRecord
ActiveStorage::Blob.proxy_url(audit_trail.blob)
end
alias audit_log_url audit_trail_url
def combined_document_url
return if combined_document.blank?
ActiveStorage::Blob.proxy_url(combined_document.blob)
end
end
-1
View File
@@ -48,7 +48,6 @@ 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
+7 -20
View File
@@ -6,7 +6,6 @@
#
# id :bigint not null, primary key
# completed_at :datetime
# declined_at :datetime
# email :string
# ip :string
# metadata :text not null
@@ -21,17 +20,15 @@
# 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_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)
# 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
#
@@ -39,8 +36,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: -> { {} }
@@ -60,9 +57,7 @@ class Submitter < ApplicationRecord
scope :completed, -> { where.not(completed_at: nil) }
def status
if declined_at?
'declined'
elsif completed_at?
if completed_at?
'completed'
elsif opened_at?
'opened'
@@ -85,15 +80,7 @@ class Submitter < ApplicationRecord
end
end
def first_name
name.split(/\s+/, 2).first
end
def last_name
name.split(/\s+/, 2).last
end
def status_event_at
declined_at || completed_at || opened_at || sent_at || created_at
completed_at || opened_at || sent_at || created_at
end
end
+1 -13
View File
@@ -22,7 +22,7 @@
</div>
<% end %>
<% encrypted_config = @encrypted_config || EncryptedConfig.find_or_initialize_by(account: current_account, key: EncryptedConfig::APP_URL_KEY) %>
<% if !Docuseal.multitenant? && can?(:manage, encrypted_config) && !current_account.testing? && ENV['APP_URL'].blank? %>
<% if !Docuseal.multitenant? && can?(:manage, encrypted_config) && !current_account.testing? %>
<%= fields_for encrypted_config do |ff| %>
<div class="form-control">
<%= ff.label :value, 'App URL', class: 'label' %>
@@ -123,18 +123,6 @@
</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 -1
View File
@@ -1,4 +1,4 @@
<form action="<%= root_path %>" method="get" class="bg-base-200 px-1.5 rounded-xl py-1 whitespace-nowrap">
<form action="<%= root_path %>" method="get" class="bg-base-200 px-1.5 rounded-xl py-1">
<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') %>
+11 -3
View File
@@ -13,13 +13,20 @@
}
.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 h2 {
.error-page h3 {
font-weight: 600;
font-size: 1.75em;
color: #291434;
@@ -49,8 +56,9 @@
<body class="error-page">
<div class="dialog">
<div>
<h1>404</h1>
<h2>Sorry, we couldn't find this page.</h2>
<h1>DocuSeal</h1>
<h2>404</h2>
<h3>Sorry, we couldn't find this page.</h3>
</div>
<a rel="noopener noreferrer" href="/" class="btn">Back to homepage</a>
</div>
+11 -3
View File
@@ -13,13 +13,20 @@
}
.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 h2 {
.error-page h3 {
font-weight: 600;
font-size: 1.75em;
color: #291434;
@@ -49,8 +56,9 @@
<body class="error-page">
<div class="dialog">
<div>
<h1>422</h1>
<h2>You're not allowed to access this page</h2>
<h1>DocuSeal</h1>
<h2>422</h2>
<h3>You're not allowed to access this page</h3>
</div>
<a rel="noopener noreferrer" href="/" class="btn">Back to homepage</a>
</div>
+11 -3
View File
@@ -13,13 +13,20 @@
}
.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 h2 {
.error-page h3 {
font-weight: 600;
font-size: 1.75em;
color: #291434;
@@ -49,8 +56,9 @@
<body class="error-page">
<div class="dialog">
<div>
<h1>500</h1>
<h2>We're sorry, but something went wrong</h2>
<h1>DocuSeal</h1>
<h2>500</h2>
<h3>We're sorry, but something went wrong</h3>
</div>
<a rel="noopener noreferrer" href="/" class="btn">Back to homepage</a>
</div>
+1 -1
View File
@@ -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, maximum-scale=1.0, user-scalable=no">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<% if ENV['ROLLBAR_CLIENT_TOKEN'] %>
-19
View File
@@ -1,19 +0,0 @@
<% uuid = SecureRandom.uuid %>
<label id="<%= local_assigns[:button_id] %>" for="<%= uuid %>" class="<%= local_assigns[:btn_class] %>"><%= local_assigns[:btn_text] %></label>
<input type="checkbox" id="<%= uuid %>" class="modal-toggle">
<div id="<%= local_assigns[:id] %>" class="modal items-start !animate-none overflow-y-auto">
<div class="modal-box pt-4 pb-6 px-6 mt-20 max-h-none">
<% if local_assigns[:title] %>
<div class="flex justify-between items-center border-b pb-2 mb-2 font-medium">
<span>
<%= local_assigns[:title] %>
</span>
<label for="<%= uuid %>" class="text-xl">&times;</label>
</div>
<% end %>
<div>
<%= yield %>
</div>
</div>
<label class="modal-backdrop" for="<%= uuid %>">Close</label>
</div>
+2 -4
View File
@@ -1,4 +1,4 @@
<form action="<%= url_for %>" method="get" class="items-center flex">
<form action="<%= url_for %>" method="get" class="items-center hidden md:flex">
<% if params[:status].present? %>
<input name="status" value="<%= params[:status] %>" class="hidden">
<% end %>
@@ -9,9 +9,7 @@
</a>
</div>
<% end %>
<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>
<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] %>">
<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') %>
@@ -18,20 +18,14 @@
<% end %>
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
<submitters-autocomplete data-field="name">
<linked-input data-target-id="<%= "detailed_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<%= tag.input type: 'text', name: 'submission[1][submitters][][name]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Name', required: index.zero?, value: (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '', dir: 'auto', id: "detailed_name_#{item['uuid']}" %>
</linked-input>
<%= tag.input type: 'text', name: 'submission[1][submitters][][name]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Name', required: index.zero?, value: params[:selfsign] && index.zero? ? current_user.full_name : '', dir: 'auto' %>
</submitters-autocomplete>
<div class="grid <%= 'md:grid-cols-2 gap-1' if template.submitters.size == 1 %>">
<submitters-autocomplete data-field="email">
<linked-input data-target-id="<%= "detailed_email_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<input type="email" multiple name="submission[1][submitters][][email]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Email (optional)" value="<%= item['email'].presence || ((params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.email : '') %>" id="detailed_email_<%= item['uuid'] %>">
</linked-input>
<input type="email" multiple name="submission[1][submitters][][email]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Email (optional)" value="<%= params[:selfsign] && index.zero? ? current_user.email : '' %>">
</submitters-autocomplete>
<submitters-autocomplete data-field="phone">
<linked-input data-target-id="<%= "detailed_phone_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<input type="tel" pattern="^\+[0-9\s\-]+$" oninvalid="this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''" oninput="this.setCustomValidity('')" name="submission[1][submitters][][phone]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Phone (optional)" id="detailed_phone_<%= item['uuid'] %>">
</linked-input>
<input type="tel" pattern="^\+[0-9\s\-]+$" oninvalid="this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''" oninput="this.setCustomValidity('')" name="submission[1][submitters][][phone]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Phone (optional)">
</submitters-autocomplete>
</div>
</submitter-item>
+1 -3
View File
@@ -27,9 +27,7 @@
</label>
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
<submitters-autocomplete data-field="email">
<linked-input data-target-id="<%= "email_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<%= tag.input type: 'email', multiple: true, name: 'submission[1][submitters][][email]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Email', required: index.zero?, value: item['email'].presence || ((params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.email : ''), id: "email_#{item['uuid']}" %>
</linked-input>
<%= tag.input type: 'email', multiple: true, name: 'submission[1][submitters][][email]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Email', required: index.zero?, value: params[:selfsign] && index.zero? ? current_user.email : '' %>
</submitters-autocomplete>
</submitter-item>
<% end %>
+3 -9
View File
@@ -19,24 +19,18 @@
<% end %>
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
<submitters-autocomplete data-field="phone">
<linked-input data-target-id="<%= "phone_phone_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<%= tag.input type: 'tel', pattern: '^\+[0-9\s\-]+$', oninvalid: "this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''", oninput: "this.setCustomValidity('')", name: 'submission[1][submitters][][phone]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Phone', required: index.zero?, id: "phone_phone_#{item['uuid']}" %>
</linked-input>
<%= tag.input type: 'tel', pattern: '^\+[0-9\s\-]+$', oninvalid: "this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''", oninput: "this.setCustomValidity('')", name: 'submission[1][submitters][][phone]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Phone', required: index.zero? %>
</submitters-autocomplete>
<% if template.submitters.size > 1 %>
<submitters-autocomplete data-field="name">
<linked-input data-target-id="<%= "phone_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Name (optional)" value="<%= (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '' %>" dir="auto" id="phone_name_<%= item['uuid'] %>">
</linked-input>
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Name (optional)" value="<%= params[:selfsign] && index.zero? ? current_user.full_name : '' %>" dir="auto">
</submitters-autocomplete>
<% end %>
</div>
<% if template.submitters.size == 1 %>
<div class="form-control flex">
<submitters-autocomplete data-field="name">
<linked-input data-target-id="<%= "phone_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="input input-sm input-bordered w-full" placeholder="Name (optional)" value="<%= (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '' %>" dir="auto" id="phone_name_<%= item['uuid'] %>">
</linked-input>
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="input input-sm input-bordered w-full" placeholder="Name (optional)" value="<%= params[:selfsign] && index.zero? ? current_user.full_name : '' %>" dir="auto">
</submitters-autocomplete>
</div>
<% end %>
+9 -21
View File
@@ -1,7 +1,7 @@
<% if params[:controller] == 'submissions_preview' %>
<%= render 'submissions/preview_tags' %>
<% end %>
<% 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 }] } %>
<% with_signature_id = @submission.account.account_configs.exists?(key: AccountConfig::WITH_SIGNATURE_ID, value: true) %>
<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], combined: is_combined_enabled }.compact) %>" class="base-button <%= '!rounded-r-none !pr-2' if is_all_completed && !is_combined_enabled %>">
<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 %>">
<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 && !is_combined_enabled %>
<% if is_all_completed %>
<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? && !@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' %>
<% 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' %>
<% end %>
</div>
</div>
@@ -143,30 +143,18 @@
<div class="flex items-center space-x-1 mt-1">
<%= svg_icon('writing', class: 'w-5 h-5') %>
<span>
<% 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 %>
<%= submitter&.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : 'Not completed yet' %>
</span>
</div>
<% if submitter&.declined_at? %>
<div class="flex items-center space-x-1 mt-1">
<span>
Reason:
<%= simple_format(h(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? %>
<% if signed_in? && submitter && submitter.email && !submitter.completed_at && !@submission.archived_at? && can?(:update, submitter) && Accounts.can_send_emails?(current_account) && !@submission.expired? %>
<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? && !submitter.declined_at? %>
<% if signed_in? && submitter && submitter.phone && !submitter.completed_at && !@submission.archived_at? && can?(:update, submitter) && !@submission.expired? %>
<%= render 'submissions/send_sms_button', submitter: %>
<% end %>
<% if signed_in? && submitter && !submitter.completed_at? && !@submission.archived_at? && can?(:create, submitter) && !@submission.expired? && !submitter.declined_at? %>
<% if signed_in? && submitter && !submitter.completed_at? && !@submission.archived_at? && can?(:create, submitter) && !@submission.expired? %>
<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,9 +5,7 @@
<% end %>
</div>
<div class="flex justify-between mb-4 items-center">
<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>
<h1 class="text-4xl font-bold">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
<% 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-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h1>
<h1 class="text-3xl sm:text-4xl font-bold">Submissions</h1>
</div>
<div class="flex space-x-2">
<% if params[:q].present? || @pagy.pages > 1 %>
@@ -1,11 +0,0 @@
<%= form_for '', url: submit_form_decline_index_path(submitter.slug), method: :post do |f| %>
<div class="mt-4 text-center">
<%= t(:notify_the_sender_with_the_reason_you_declined) %>
</div>
<div class="form-control mt-2">
<%= f.text_area :reason, required: true, class: 'base-input w-full py-2 h-40', dir: 'auto', placeholder: t('provide_a_reason'), style: 'height: 200px', rows: '10' %>
</div>
<toggle-submit dir="auto" class="form-control mt-4">
<%= f.button button_title(title: t(:decline)), class: 'base-button' %>
</toggle-submit>
<% end %>
-21
View File
@@ -1,21 +0,0 @@
<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 %>
+2 -27
View File
@@ -8,30 +8,7 @@
<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] || 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 %>
<%= local_assigns[:banner_html] || render('submit_form/banner') %>
<% (@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'] } || {} %>
@@ -51,8 +28,6 @@
<% next if !field['readonly'] && field['submitter_uuid'] == @submitter.uuid %>
<% next if field['redacted'] && field['submitter_uuid'] != @submitter.uuid %>
<% next if value == '{{date}}' && field['submitter_uuid'] != @submitter.uuid %>
<% next if field['conditions'].present? && values[field['uuid']].blank? && field['submitter_uuid'] != @submitter.uuid %>
<% next if field['conditions'].present? && field['submitter_uuid'] == @submitter.uuid %>
<% next if field.dig('preferences', 'formula').present? && field['submitter_uuid'] == @submitter.uuid %>
<%= render 'submissions/value', area:, field:, attachments_index: @attachments_index, value:, locale: @submitter.account.locale, timezone: @submitter.account.timezone, submitter: submitters_index[field['submitter_uuid']], with_signature_id: @form_configs[:with_signature_id] %>
<% end %>
@@ -67,7 +42,7 @@
<div class="fixed bottom-0 w-full h-0 z-20">
<div class="mx-auto" style="max-width: 1000px">
<div class="relative md:mx-32">
<%= render 'submit_form/submission_form', attachments_index: @attachments_index, submitter: @submitter, signature_attachment: @signature_attachment, configs: @form_configs, dry_run: local_assigns[:dry_run], expand: local_assigns[:expand], scroll_padding: local_assigns.fetch(:scroll_padding, '-110px') %>
<%= render 'submit_form/submission_form', attachments_index: @attachments_index, submitter: @submitter, signature_attachment: @signature_attachment, configs: @form_configs, dry_run: local_assigns[:dry_run], expand: local_assigns[:expand], scroll_padding: local_assigns[:scroll_padding] %>
</div>
</div>
</div>
@@ -1,4 +0,0 @@
<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(h(@submitter.submission_events.find_by(event_type: :decline_form).data['reason'])) %>
<p><%= link_to t('view'), submission_url(@submitter.submission) %></p>
+1 -1
View File
@@ -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 md:flex <%= 'hidden' if params[:q].present? %>">
<h1 class="text-4xl font-bold flex items-center space-x-2">
<%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %>
<span class="peer">
<%= @template_folder.name %>
+5 -10
View File
@@ -1,4 +1,4 @@
<% status_badges = { 'awaiting' => 'badge-info', 'sent' => 'badge-info', 'completed' => 'badge-success', 'opened' => 'badge-warning', 'declined' => 'badge-error' } %>
<% status_badges = { 'awaiting' => 'badge-info', 'sent' => 'badge-info', 'completed' => 'badge-success', 'opened' => 'badge-warning' } %>
<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.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
<%= template.name %>
<%= 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 max-w-[50%] md:max-w-full">
<div class="flex-shrink-0 sm:mt-2">
<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? && !submitter.declined_at? %>
<% elsif !submission.archived_at? && !template.archived_at? && !submission.expired? %>
<% 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? && !submitter.declined_at? %>
<% elsif !template.archived_at? && !submission.archived_at? && !is_submission_completed && !submission.expired? %>
<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,11 +195,6 @@
<%= 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 -1
View File
@@ -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.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
<%= template.name %>
</div>
<div class="pb-6 pt-1 space-y-1">
<p class="flex items-center space-x-1 text-xs text-base-content/60">
+4 -12
View File
@@ -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-3xl md:text-4xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
<h1 class="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>
@@ -70,7 +70,7 @@
<span>Edit</span>
</span>
<% end %>
<% elsif can?(:read, template) && !template.archived_at? %>
<% elsif can?(:read, template) %>
<%= link_to template_preview_path(template), class: 'btn btn-outline btn-sm flex-1' do %>
<span class="flex items-center justify-center space-x-2">
<%= svg_icon('file_text', class: 'w-6 h-6') %>
@@ -79,16 +79,8 @@
<% end %>
<% end %>
<% end %>
<% if template.archived_at? %>
<% if can?(:create, template) %>
<%= button_to button_title(title: 'Restore', disabled_with: 'Restoring', icon: svg_icon('rotate', class: 'w-6 h-6')), template_restore_index_path(template), class: 'btn btn-outline btn-sm flex-1' %>
<% end %>
<%= link_to template_preview_path(template), class: 'btn btn-outline btn-sm flex-1' do %>
<span class="flex items-center justify-center space-x-2">
<%= svg_icon('file_text', class: 'w-6 h-6') %>
<span>Preview</span>
</span>
<% end %>
<% if template.archived_at? && can?(:create, template) %>
<%= button_to button_title(title: 'Restore', disabled_with: 'Restoring', icon: svg_icon('rotate', class: 'w-6 h-6')), template_restore_index_path(template), class: 'btn btn-outline btn-sm flex-1' %>
<% end %>
</div>
</div>
+1 -1
View File
@@ -1 +1 @@
<template-builder class="grid" data-template="<%= @template_data %>" data-with-sign-yourself-button="<%= !@template.archived_at? %>" data-with-send-button="<%= !@template.archived_at? && can?(:create, @template.submissions.new(account: current_account)) %>" data-locale="<%= current_account.locale %>"></template-builder>
<template-builder class="grid" data-template="<%= @template_data %>" data-locale="<%= current_account.locale %>"></template-builder>
+2 -4
View File
@@ -3,12 +3,10 @@
<% 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">
<div>
<h2 class="text-3xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h2>
</div>
<p class="text-3xl font-bold">Submissions</p>
<div class="flex justify-end space-x-2">
<% if params[:q].present? || params[:status].present? || @pagy.pages > 1 %>
<%= render 'shared/search_input', title_selector: 'h2' %>
<%= render 'shared/search_input' %>
<% 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') %>
+1 -3
View File
@@ -5,9 +5,7 @@
<% end %>
</div>
<div class="flex justify-between mb-4 items-center">
<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>
<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>
<% 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">
<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' %>
<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 %>
<%= 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>
+1 -1
View File
@@ -7,7 +7,7 @@
<%= render 'dashboard/toggle_view', selected: 'templates' %>
</div>
<% end %>
<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>
<h1 class="text-3xl sm:text-4xl font-bold"><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? %>
+6 -50
View File
@@ -1,8 +1,6 @@
<%= render 'shared/turbo_modal_large', title: 'Preferences' do %>
<%= render 'shared/turbo_modal_large', title: 'Preferences', close_after_submit: false do %>
<% show_api = Docuseal.multitenant? || current_account.testing? || !current_account.linked_account_account %>
<% show_recipients = @template.submitters.to_a.length > 1 %>
<% options = [%w[General general]] %>
<% options << %w[Recipients recipients] if show_recipients %>
<% options << ['API and Embedding', 'api'] if show_api %>
<% if options.size > 1 %>
<toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center mt-3 block">
@@ -10,7 +8,7 @@
<% options.each_with_index do |(label, value), index| %>
<span>
<%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %>
<label for="option_<%= value %>" class="<%= '!rounded-s-full' if index.zero? %> btn btn-focus btn-sm join-item peer-checked:btn-active normal-case <%= 'px-8 md:px-0' if value.in?(%w[general recipients]) %> <%= options.size > 2 ? 'md:w-44' : 'md:w-48' %>">
<label for="option_<%= value %>" class="<%= '!rounded-s-full' if index.zero? %> btn btn-focus btn-sm join-item md:w-48 peer-checked:btn-active normal-case <%= 'px-8 md:px-0' if value == 'general' %>">
<%= label %>
</label>
</span>
@@ -19,7 +17,7 @@
</toggle-visible>
<% end %>
<div id="general" class="px-5 mb-4">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' } do |f| %>
<toggle-on-submit data-element-id="bcc_saved_alert"></toggle-on-submit>
<%= f.fields_for :preferences, Struct.new(:bcc_completed).new(@template.preferences['bcc_completed']) do |ff| %>
<div class="form-control">
@@ -48,7 +46,7 @@
Signature request email
</div>
<div class="collapse-content">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %>
<%= 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_alert1"></toggle-on-submit>
<%= f.fields_for :preferences, Struct.new(:request_email_subject, :request_email_body).new(*(@template.preferences.values_at('request_email_subject', 'request_email_body').compact_blank.presence || AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY).value.values_at('subject', 'body'))) do |ff| %>
<div class="form-control">
@@ -82,7 +80,7 @@
Documents copy email
</div>
<div class="collapse-content">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %>
<%= 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>
<% 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| %>
@@ -129,7 +127,7 @@
Completed notification email
</div>
<div class="collapse-content">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %>
<%= 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, :completed_notification_email_attach_documents).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, configs['attach_documents'] != false && @template.preferences['completed_notification_email_attach_documents'] != false) do |ff| %>
@@ -178,48 +176,6 @@
</div>
</div>
</div>
<% if show_recipients %>
<div id="recipients" class="hidden mt-2 mb-4 px-5">
<%= form_for @template, url: template_recipients_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1', id: :submitters_form } do |f| %>
<div class="space-y-3 divide-y">
<% @template.submitters.each_with_index do |submitter, index| %>
<div class="pt-3">
<%= f.fields_for :submitters, item = Struct.new(:name, :uuid, :is_requester, :email, :linked_to_uuid, :option).new(*submitter.values_at('name', 'uuid', 'is_requester', 'email', 'linked_to_uuid')), index: do |ff| %>
<% item.option = item.is_requester.present? ? 'is_requester' : (item.email.present? ? 'email' : (item.linked_to_uuid.present? ? "linked_to_#{item.linked_to_uuid}" : '')) %>
<%= ff.hidden_field :uuid %>
<div class="form-control">
<%= ff.text_field :name, class: 'w-full outline-none border-transparent focus:border-transparent focus:ring-0 bg-base-100 px-1 peer mb-2', autocomplete: 'off', placeholder: "#{index + 1}#{(index + 1).ordinal} Party", required: true %>
<% if @template.submitters.size == 2 %>
<%= ff.email_field :email, class: 'base-input', autocomplete: 'off', placeholder: 'Default Email', disabled: ff.object.is_requester, id: field_uuid = SecureRandom.uuid %>
<% else %>
<toggle-attribute data-target-id="<%= email_field_uuid = SecureRandom.uuid %>" data-class-name="hidden" data-value="email">
<%= ff.select :option, [['Not specified', 'not_set'], ['Submission requester', 'is_requester'], ['Specified email', 'email'], *(@template.submitters - [submitter]).map { |e| ["Same as #{e['name']}", "linked_to_#{e['uuid']}"] }], {}, class: 'base-select mb-3' %>
</toggle-attribute>
<%= ff.email_field :email, class: "base-input #{'hidden' if item.option != 'email'}", autocomplete: 'off', placeholder: 'Default Email', id: email_field_uuid %>
<% end %>
</div>
<% if @template.submitters.size == 2 %>
<div class="mt-3">
<label class="flex items-center space-x-2 cursor-pointer">
<toggle-attribute data-target-id="<%= field_uuid %>" class="flex" data-attribute="disabled">
<%= ff.check_box :is_requester, class: 'base-checkbox' %>
</toggle-attribute>
<span class="select-none">
Submission requester
</span>
</label>
</div>
<% end %>
<% end %>
</div>
<% end %>
</div>
<div class="form-control mt-6 pb-2">
<%= f.button button_title(title: 'Save', disabled_with: 'Updating'), class: 'base-button' %>
</div>
<% end %>
</div>
<% end %>
<% if show_api %>
<div id="api" class="hidden mt-2 mb-4 px-5">
<div>
+1 -1
View File
@@ -1 +1 @@
<template-builder class="grid" data-editable="false" data-with-sign-yourself-button="<%= !@template.archived_at? %>" data-with-send-button="<%= !@template.archived_at? && can?(:create, @template.submissions.new(account: current_account)) %>" data-template="<%= @template_data %>"></template-builder>
<template-builder class="grid" data-editable="false" data-template="<%= @template_data %>"></template-builder>
+32 -25
View File
@@ -126,32 +126,39 @@ Rails.application.configure do
config.lograge.enabled = true
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
if ENV['MULTITENANT'] == 'true'
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],
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)
}
{
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
end
end
+5 -146
View File
@@ -18,8 +18,6 @@ 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}'
@@ -41,15 +39,6 @@ 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
@@ -76,17 +65,6 @@ 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>'
@@ -131,17 +109,6 @@ 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}'
@@ -185,17 +152,6 @@ 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
@@ -239,23 +195,13 @@ 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
@@ -292,23 +238,13 @@ 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
@@ -345,18 +281,7 @@ de: &de
enter_email_to_continue: E-Mail eingeben, um fortzufahren
pl:
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
email: Email
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>'
@@ -398,18 +323,7 @@ pl:
enter_email_to_continue: Wprowadź e-mail, aby kontynuować
uk:
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
email: Email
digitally_signed_by: Цифровий підпис від
verification_code_code: 'Код підтвердження: %{code}'
role: Роль
@@ -451,18 +365,7 @@ uk:
enter_email_to_continue: Введіть електронну пошту, щоб продовжити
cs:
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
email: Email
digitally_signed_by: Digitálně podepsáno uživatelem
verification_code_code: 'Ověřovací kód: %{code}'
role: Role
@@ -504,17 +407,6 @@ 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: תפקיד
@@ -557,17 +449,6 @@ 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
@@ -611,17 +492,6 @@ 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: الدور
@@ -665,17 +535,6 @@ 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: 역할
-4
View File
@@ -49,7 +49,6 @@ 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
@@ -97,7 +96,6 @@ Rails.application.routes.draw do
resource :form, only: %i[show], controller: 'templates_form_preview'
resource :code_modal, only: %i[show], controller: 'templates_code_modal'
resource :preferences, only: %i[show create], controller: 'templates_preferences'
resources :recipients, only: %i[create], controller: 'templates_recipients'
resources :submissions_export, only: %i[index new]
end
resources :preview_document_page, only: %i[show], path: '/preview/:signed_uuid'
@@ -126,8 +124,6 @@ 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
@@ -1,9 +0,0 @@
# 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
@@ -1,32 +0,0 @@
# 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
@@ -1,8 +0,0 @@
# 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
@@ -1,11 +0,0 @@
# 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
@@ -1,7 +0,0 @@
# frozen_string_literal: true
class AddDeclinedAtToSubmitters < ActiveRecord::Migration[7.1]
def change
add_column :submitters, :declined_at, :datetime
end
end
+3 -6
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_08_20_180922) do
ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) 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_20_180922) 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: "idx_on_record_type_record_id_name_blob_id_0be5805727"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
t.index ["uuid"], name: "index_active_storage_attachments_on_uuid"
end
@@ -219,7 +219,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_20_180922) do
t.text "preferences", null: false
t.bigint "account_id", null: false
t.datetime "expire_at"
t.index ["account_id", "id"], name: "index_submissions_on_account_id_and_id"
t.index ["account_id"], name: "index_submissions_on_account_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,9 +243,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_20_180922) 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
View File
@@ -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, account_id: user.account_id
can :manage, Submitter, submission: { 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
+2 -2
View File
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module ActionMailerConfigsInterceptor
OPEN_TIMEOUT = ENV.fetch('SMTP_OPEN_TIMEOUT', '15').to_i
READ_TIMEOUT = ENV.fetch('SMTP_READ_TIMEOUT', '25').to_i
OPEN_TIMEOUT = 15
READ_TIMEOUT = 25
module_function
+2 -2
View File
@@ -6,7 +6,7 @@ module Docuseal
NEWSLETTER_URL = "#{PRODUCT_URL}/newsletters".freeze
ENQUIRIES_URL = "#{PRODUCT_URL}/enquiries".freeze
PRODUCT_NAME = 'DocuSeal'
DEFAULT_APP_URL = ENV.fetch('APP_URL', 'http://localhost:3000')
DEFAULT_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 if ENV['APP_URL'].blank?
value = EncryptedConfig.find_by(key: EncryptedConfig::APP_URL_KEY)&.value
value ||= DEFAULT_APP_URL
url = Addressable::URI.parse(value)
{ host: url.host, port: url.port, protocol: url.scheme }
-33
View File
@@ -1,33 +0,0 @@
# frozen_string_literal: true
module DownloadUtils
LOCALHOSTS = %w[0.0.0.0 127.0.0.1 localhost].freeze
UnableToDownload = Class.new(StandardError)
module_function
def call(url)
uri = Addressable::URI.parse(url)
if Docuseal.multitenant?
raise UnableToDownload, "Error loading: #{uri.display_uri}. Only HTTPS is allowed." if uri.scheme != 'https'
if uri.host.in?(LOCALHOSTS)
raise UnableToDownload, "Error loading: #{uri.display_uri}. Can't download from localhost."
end
end
resp = conn.get(uri.display_uri.to_s)
raise UnableToDownload, "Error loading: #{uri.display_uri}" if resp.status >= 400
resp
end
def conn
Faraday.new do |faraday|
faraday.response :follow_redirects
end
end
end
-4
View File
@@ -6,11 +6,9 @@ module ReplaceEmailVariables
SUBMITTER_LINK = /\{+submitter\.link\}+/i
ACCOUNT_NAME = /\{+account\.name\}+/i
SENDER_NAME = /\{+sender\.name\}+/i
SENDER_FIRST_NAME = /\{+sender\.first_name\}+/i
SENDER_EMAIL = /\{+sender\.email\}+/i
SUBMITTER_EMAIL = /\{+submitter\.email\}+/i
SUBMITTER_NAME = /\{+submitter\.name\}+/i
SUBMITTER_FIRST_NAME = /\{+submitter\.first_name\}+/i
SUBMITTER_ID = /\{+submitter\.id\}+/i
SUBMITTER_SLUG = /\{+submitter\.slug\}+/i
SUBMISSION_LINK = /\{+submission\.link\}+/i
@@ -30,7 +28,6 @@ module ReplaceEmailVariables
text = replace(text, SUBMISSION_ID, html_escape:) { submitter.submission.id }
text = replace(text, SUBMITTER_EMAIL, html_escape:) { submitter.email }
text = replace(text, SUBMITTER_NAME, html_escape:) { submitter.name || submitter.email || submitter.phone }
text = replace(text, SUBMITTER_FIRST_NAME, html_escape:) { submitter.first_name }
text = replace(text, SUBMITTER_LINK, html_escape:) { build_submitter_link(submitter, tracking_event_type) }
text = replace(text, SUBMISSION_LINK, html_escape:) do
submitter.submission ? build_submission_link(submitter.submission) : ''
@@ -40,7 +37,6 @@ module ReplaceEmailVariables
text = replace(text, DOCUMENTS_LINK, html_escape:) { build_documents_links_text(submitter, sig) }
text = replace(text, ACCOUNT_NAME, html_escape:) { submitter.submission.account.name }
text = replace(text, SENDER_NAME, html_escape:) { submitter.submission.created_by_user&.full_name }
text = replace(text, SENDER_FIRST_NAME, html_escape:) { submitter.submission.created_by_user&.first_name }
replace(text, SENDER_EMAIL, html_escape:) { submitter.submission.created_by_user&.email.to_s.sub(/\+\w+@/, '@') }
end
+3 -2
View File
@@ -67,7 +67,6 @@ 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)
@@ -114,7 +113,9 @@ module Submissions
fixed_email = EmailTypo.call(email.delete_prefix('<'))
Rails.logger.info("Fixed email #{email.split('@').last}") if fixed_email != email.downcase.delete_prefix('<').strip
if defined?(Rollbar) && fixed_email != email.downcase.delete_prefix('<').strip
Rollbar.warning("Fixed email #{email}")
end
fixed_email
end
@@ -1,52 +0,0 @@
# frozen_string_literal: true
module Submissions
module AssignDefinedSubmitters
module_function
def call(submission)
submission.submitters_order = 'preserved'
assign_defined_submitters(submission)
assign_linked_submitters(submission)
if submission.submitters.size == 1 && submission.template.submitters.size == 2
submission.submitters.new(
account_id: submission.account_id,
uuid: submission.template.submitters.second['uuid'],
email: submission.template.author.email
)
end
submission
end
def assign_defined_submitters(submission)
submission.template.submitters.to_a.select do |item|
next if item['email'].blank? && item['is_requester'].blank?
submission.submitters.new(
account_id: submission.account_id,
uuid: item['uuid'],
email: item['is_requester'] ? submission.template.author.email : item['email']
)
end
end
def assign_linked_submitters(submission)
submission.template.submitters.to_a.select do |item|
next if item['linked_to_uuid'].blank?
email = submission.submitters.find { |s| s.uuid == item['linked_to_uuid'] }&.email
next unless email
submission.submitters.new(
account_id: submission.account_id,
uuid: item['uuid'],
email:
)
end
end
end
end
+4 -8
View File
@@ -155,14 +155,16 @@ module Submissions
submitter_preferences = Submitters.normalize_preferences(submission.account, user, attrs)
values = attrs[:values] || {}
phone_field_uuid = find_phone_field(submission, values)&.dig('uuid')
phone_field_uuid =
(submission.template_fields || submission.template.fields).find do |f|
values[f['uuid']].present? && f['type'] == 'phone'
end&.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),
@@ -181,12 +183,6 @@ 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)
-37
View File
@@ -21,8 +21,6 @@ module Submissions
'GBP' => '£'
}.freeze
TESTING_FOOTER = GenerateResultAttachments::TESTING_FOOTER
RTL_REGEXP = TextUtils::RTL_REGEXP
MAX_IMAGE_HEIGHT = 100
@@ -107,41 +105,6 @@ 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
font = composer.document.fonts.add(FONT_NAME)
text =
if submission.account.testing?
if with_signature_id
"#{TESTING_FOOTER} | ID: #{document_id}"
else
TESTING_FOOTER
end
else
"Document ID: #{document_id}"
end
text = HexaPDF::Layout::TextFragment.create(
text, font:, font_size: FONT_SIZE, underlays: [
lambda do |canv, box|
canv.fill_color('white').rectangle(-1, 0, box.width + 2, box.height).fill
end
]
)
HexaPDF::Layout::TextLayouter.new(font:, font_size: FONT_SIZE)
.fit([text], 1000, 1000)
.draw(canvas, 1, FONT_SIZE * 1.37)
end
end
style.frame = style.create_frame(canvas.context, 50)
end
+8 -32
View File
@@ -58,15 +58,13 @@ module Submissions
submitter.submission.template_schema.map do |item|
pdf = pdfs_index[item['attachment_uuid']]
if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
pdf = normalize_image_pdf(pdf)
attachment = build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
uuid: item['attachment_uuid'],
name: item['name'])
image_pdfs << pdf
end
image_pdfs << pdf if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
uuid: item['attachment_uuid'],
name: item['name'])
attachment
end
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
@@ -76,8 +74,6 @@ 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,
@@ -110,8 +106,6 @@ module Submissions
pdfs_index.each_value do |pdf|
next if pdf.trailer.info[:DocumentID].present?
font = pdf.fonts.add(FONT_NAME)
document_id = Digest::MD5.hexdigest(submitter.submission.slug).upcase
pdf.trailer.info[:DocumentID] = document_id
@@ -119,6 +113,8 @@ module Submissions
font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * 9).to_i
cnv = page.canvas(type: :overlay)
cnv.font(FONT_NAME, size: font_size)
text =
if submitter.account.testing?
if with_signature_id
@@ -130,17 +126,7 @@ module Submissions
"Document ID: #{document_id}"
end
text = HexaPDF::Layout::TextFragment.create(
text, font:, font_size:, underlays: [
lambda do |canv, box|
canv.fill_color('white').rectangle(-1, 0, box.width + 2, box.height).fill
end
]
)
HexaPDF::Layout::TextLayouter.new(font:, font_size:)
.fit([text], page.box.width, page.box.height)
.draw(cnv, 1, font_size * 1.37)
cnv.text(text, at: [2, 4])
end
end
end
@@ -532,8 +518,6 @@ module Submissions
begin
pdf.acro_form.create_appearances(force: true) if pdf.acro_form && pdf.acro_form[:NeedAppearances]
pdf.acro_form&.flatten
rescue HexaPDF::MissingGlyphError
nil
rescue StandardError => e
Rollbar.error(e) if defined?(Rollbar)
end
@@ -606,14 +590,6 @@ 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 -6
View File
@@ -48,15 +48,13 @@ module Submissions
submitters.each do |submitter|
submitter.values.each_value do |value|
Array.wrap(value).each do |v|
attachment = attachments_index[v]
attachment = attachments_index[value]
next unless attachment
next unless attachment
attachment.record = submitter
attachment.record = submitter
attachment.save!
end
attachment.save!
end
end
end
+21 -36
View File
@@ -4,9 +4,12 @@ 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 combined_document_url],
methods: %i[audit_log_url],
include: {
submitters: { only: %i[id] },
submitters: { only: %i[id slug uuid name email phone
completed_at opened_at sent_at
created_at updated_at external_id metadata],
methods: %i[status application_key] },
template: { only: %i[id name external_id created_at updated_at],
methods: %i[folder_name] },
created_by_user: { only: %i[id email first_name last_name] }
@@ -15,35 +18,30 @@ module Submissions
module_function
def call(submission, submitters = nil, params = {}, with_events: true, with_documents: true, with_values: true)
def call(submission, submitters = nil, params = {})
submitters ||= submission.submitters.preload(documents_attachments: :blob, attachments_attachments: :blob)
serialized_submitters = submitters.map do |submitter|
Submitters::SerializeForApi.call(submitter, with_documents:, with_events: false, with_values:, params:)
end
serialized_submitters = submitters.map { |submitter| Submitters::SerializeForApi.call(submitter, params:) }
json = submission.as_json(SERIALIZE_PARAMS)
json['created_by_user'] ||= nil
if with_events
json['submission_events'] = Submitters::SerializeForApi.serialize_events(submission.submission_events)
end
json['combined_document_url'] ||= maybe_build_combined_url(submitters, submission, params)
json = submission.as_json(
SERIALIZE_PARAMS.deep_merge(
include: { submission_events: { only: %i[id submitter_id event_type event_timestamp] } }
)
)
if submitters.all?(&:completed_at?)
last_submitter = submitters.max_by(&:completed_at)
if with_documents
json[:documents] = serialized_submitters.find { |e| e['id'] == last_submitter.id }['documents']
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] = [] if with_documents
json[:status] = build_status(submission, submitters)
json[:documents] = []
json[:status] = submission.expired? ? 'expired' : 'pending'
json[:completed_at] = nil
end
@@ -52,26 +50,13 @@ module Submissions
json
end
def build_status(submission, submitters)
if submitters.any?(&:declined_at?)
'declined'
else
submission.expired? ? 'expired' : 'pending'
end
end
def maybe_build_combined_url(submitters, submission, params)
return unless submitters.all?(&:completed_at?)
def build_combined_url(submitter, submission)
return unless submitter.completed_at?
attachment = submission.combined_document_attachment
attachment ||= Submissions::GenerateCombinedAttachment.call(submitter)
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
ActiveStorage::Blob.proxy_url(attachment.blob)
end
end
end
-6
View File
@@ -21,12 +21,6 @@ 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
+14 -5
View File
@@ -4,13 +4,12 @@ module Submitters
module NormalizeValues
CHECKSUM_CACHE_STORE = ActiveSupport::Cache::MemoryStore.new
BASE64_PREFIX_REGEXP = %r{\Adata:image/\w+;base64,}
BaseError = Class.new(StandardError)
UnknownFieldName = Class.new(BaseError)
InvalidDefaultValue = Class.new(BaseError)
UnknownSubmitterName = Class.new(BaseError)
UnableToDownload = Class.new(BaseError)
TRUE_VALUES = ['1', 'true', true, 'TRUE', 'True', 'yes', 'YES', 'Yes'].freeze
FALSE_VALUES = ['0', 'false', false, 'FALSE', 'False', 'no', 'NO', 'No'].freeze
@@ -135,8 +134,7 @@ module Submitters
find_or_create_blob_from_url(account, value)
elsif type.in?(%w[signature initials]) && value.length < 60
find_or_create_blob_from_text(account, value, type)
elsif (data = Base64.decode64(value.sub(BASE64_PREFIX_REGEXP, ''))) &&
Marcel::MimeType.for(data).exclude?('octet-stream')
elsif (data = Base64.decode64(value)) && Marcel::MimeType.for(data).include?('image')
find_or_create_blob_from_base64(account, data, type)
else
raise InvalidDefaultValue, "Invalid value, url, base64 or text < 60 chars is expected: #{value.first(200)}..."
@@ -184,7 +182,12 @@ module Submitters
return blob if blob
data = DownloadUtils.call(url).body
uri = Addressable::URI.parse(url)
resp = conn.get(uri.display_uri.to_s)
raise UnableToDownload, "Error loading: #{uri.display_uri}" if resp.status >= 400
data = resp.body
checksum = Digest::MD5.base64digest(data)
@@ -209,5 +212,11 @@ module Submitters
nil
end
def conn
Faraday.new do |faraday|
faraday.response :follow_redirects
end
end
end
end
+5 -12
View File
@@ -3,20 +3,19 @@
module Submitters
module SerializeForApi
SERIALIZE_PARAMS = {
only: %i[id slug uuid name email phone completed_at declined_at external_id
only: %i[id slug uuid name email phone completed_at external_id
submission_id metadata opened_at sent_at created_at updated_at],
methods: %i[status application_key]
}.freeze
module_function
def call(submitter, with_template: false, with_events: false, with_documents: true, with_urls: false,
with_values: true, params: {})
def call(submitter, with_template: false, with_events: false, with_documents: true, with_urls: false, params: {})
ActiveRecord::Associations::Preloader.new(
records: [submitter],
associations: if with_documents
[documents_attachments: :blob, attachments_attachments: :blob]
elsif with_values
else
[attachments_attachments: :blob]
end
).call
@@ -27,10 +26,9 @@ module Submitters
additional_attrs['fields'] = SerializeForWebhook.build_fields_array(submitter)
end
additional_attrs['values'] = SerializeForWebhook.build_values_array(submitter) if with_values
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 ||
@@ -43,14 +41,9 @@ 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
+3 -15
View File
@@ -5,7 +5,7 @@ module Submitters
SERIALIZE_PARAMS = {
methods: %i[status application_key],
only: %i[id submission_id email phone name ua ip sent_at opened_at
completed_at declined_at created_at updated_at external_id metadata]
completed_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, :combined_document_url, :created_at),
status: build_submission_status(submitter.submission),
**submitter.submission.slice(:id, :audit_log_url, :created_at),
status: submitter.submission.submitters.all?(&:completed_at?) ? 'completed' : 'pending',
url: r.submissions_preview_url(submitter.submission.slug, **Docuseal.default_url_options)
})
end
@@ -83,18 +83,6 @@ 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) }
+12 -10
View File
@@ -15,7 +15,7 @@ module Templates
module_function
def call(attachment, data, extract_fields: false, image_quality: nil)
def call(attachment, data, extract_fields: false)
if attachment.content_type == PDF_CONTENT_TYPE
if extract_fields && data.size < MAX_FLATTEN_FILE_SIZE
pdf = HexaPDF::Document.new(io: StringIO.new(data))
@@ -23,23 +23,23 @@ module Templates
fields = Templates::FindAcroFields.call(pdf, attachment)
end
generate_pdf_preview_images(attachment, data, pdf, image_quality:)
generate_pdf_preview_images(attachment, data, pdf)
attachment.metadata['pdf']['fields'] = fields if fields
elsif attachment.image?
generate_preview_image(attachment, data, image_quality:)
generate_preview_image(attachment, data)
end
attachment
end
def generate_preview_image(attachment, data, image_quality: nil)
def generate_preview_image(attachment, data)
ActiveStorage::Attachment.where(name: ATTACHMENT_NAME, record: attachment).destroy_all
image = Vips::Image.new_from_buffer(data, '')
image = image.autorot.resize(MAX_WIDTH / image.width.to_f)
io = StringIO.new(image.write_to_buffer(FORMAT, Q: image_quality || Q, interlace: true))
io = StringIO.new(image.write_to_buffer(FORMAT, Q: Q, interlace: true))
ActiveStorage::Attachment.create!(
blob: ActiveStorage::Blob.create_and_upload!(
@@ -51,7 +51,7 @@ module Templates
)
end
def generate_pdf_preview_images(attachment, data, pdf = nil, image_quality: nil)
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))
@@ -70,7 +70,7 @@ module Templates
page = Vips::Image.new_from_buffer(data, '', dpi: DPI, page: page_number)
page = page.resize(MAX_WIDTH / page.width.to_f)
io = StringIO.new(page.write_to_buffer(FORMAT, Q: image_quality || Q, interlace: true))
io = StringIO.new(page.write_to_buffer(FORMAT, Q: Q, interlace: true))
ApplicationRecord.no_touching do
ActiveStorage::Attachment.create!(
@@ -97,9 +97,11 @@ module Templates
pdf.write(io, incremental: false, validate: false)
io.string
rescue StandardError
rescue StandardError => e
raise if Rails.env.development?
Rollbar.error(e) if defined?(Rollbar)
data
end
@@ -115,11 +117,11 @@ module Templates
end
end
def generate_pdf_preview_from_file(attachment, file_path, page_number, image_quality: nil)
def generate_pdf_preview_from_file(attachment, file_path, page_number)
io = StringIO.new
command = [
'pdftocairo', '-jpeg', '-jpegopt', "progressive=y,quality=#{image_quality || Q},optimize=y",
'pdftocairo', '-jpeg', '-jpegopt', "progressive=y,quality=#{Q},optimize=y",
'-scale-to-x', MAX_WIDTH, '-scale-to-y', '-1',
'-r', DPI, '-f', page_number + 1, '-l', page_number + 1,
'-singlefile', Shellwords.escape(file_path), '-'
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more