mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 22:42:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55d9511c01 | ||
|
|
929d29576d | ||
|
|
6f7128a51c | ||
|
|
fc5c4ff2fc | ||
|
|
a81595db2b | ||
|
|
a5615d500d | ||
|
|
da9266befc | ||
|
|
5b3cffeb73 | ||
|
|
8f7b8a5fdf | ||
|
|
6d93116993 | ||
|
|
a0f4916d3b | ||
|
|
ace897eaf9 | ||
|
|
b8667c5408 | ||
|
|
d87d66632e | ||
|
|
3015c2d156 | ||
|
|
52b9e9ee8e | ||
|
|
5bfad0271c | ||
|
|
58797891c7 | ||
|
|
897750ba1e | ||
|
|
99341e773f | ||
|
|
71319c1548 | ||
|
|
c0a42f6bfc | ||
|
|
d5abb46112 |
No files matched your search
+16
-2
@@ -36,14 +36,28 @@ FROM ruby:3.3.1-alpine3.18 as app
|
|||||||
|
|
||||||
ENV RAILS_ENV=production
|
ENV RAILS_ENV=production
|
||||||
ENV BUNDLE_WITHOUT="development:test"
|
ENV BUNDLE_WITHOUT="development:test"
|
||||||
|
ENV LD_PRELOAD=/lib/libgcompat.so.0
|
||||||
|
ENV OPENSSL_CONF=/app/openssl_legacy.cnf
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache sqlite-dev libpq-dev mariadb-dev vips-dev vips-poppler poppler-utils vips-heif libc6-compat ttf-freefont && mkdir /fonts && rm /usr/share/fonts/freefont/FreeSans.otf
|
RUN apk add --no-cache sqlite-dev libpq-dev mariadb-dev vips-dev vips-poppler poppler-utils vips-heif gcompat ttf-freefont && mkdir /fonts && rm /usr/share/fonts/freefont/FreeSans.otf
|
||||||
|
|
||||||
|
RUN echo $'.include = /etc/ssl/openssl.cnf\n\
|
||||||
|
\n\
|
||||||
|
[provider_sect]\n\
|
||||||
|
default = default_sect\n\
|
||||||
|
legacy = legacy_sect\n\
|
||||||
|
\n\
|
||||||
|
[default_sect]\n\
|
||||||
|
activate = 1\n\
|
||||||
|
\n\
|
||||||
|
[legacy_sect]\n\
|
||||||
|
activate = 1' >> /app/openssl_legacy.cnf
|
||||||
|
|
||||||
COPY ./Gemfile ./Gemfile.lock ./
|
COPY ./Gemfile ./Gemfile.lock ./
|
||||||
|
|
||||||
RUN apk add --no-cache build-base && bundle update --bundler && bundle install && apk del build-base && rm -rf ~/.bundle /usr/local/bundle/cache && ruby -e "puts Dir['/usr/local/bundle/**/{spec,rdoc,resources/shared,resources/collation,resources/locales}']" | xargs rm -rf
|
RUN apk add --no-cache build-base && bundle install && apk del build-base && rm -rf ~/.bundle /usr/local/bundle/cache && ruby -e "puts Dir['/usr/local/bundle/**/{spec,rdoc,resources/shared,resources/collation,resources/locales}']" | xargs rm -rf
|
||||||
|
|
||||||
COPY ./bin ./bin
|
COPY ./bin ./bin
|
||||||
COPY ./app ./app
|
COPY ./app ./app
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ gem 'ruby-vips'
|
|||||||
gem 'rubyXL'
|
gem 'rubyXL'
|
||||||
gem 'shakapacker'
|
gem 'shakapacker'
|
||||||
gem 'sidekiq', require: ENV.key?('REDIS_URL')
|
gem 'sidekiq', require: ENV.key?('REDIS_URL')
|
||||||
gem 'sqlite3', require: false
|
gem 'sqlite3', require: false, force_ruby_platform: true
|
||||||
gem 'strip_attributes'
|
gem 'strip_attributes'
|
||||||
gem 'turbo-rails'
|
gem 'turbo-rails'
|
||||||
gem 'twitter_cldr', require: false
|
gem 'twitter_cldr', require: false
|
||||||
|
|||||||
+5
-3
@@ -333,7 +333,9 @@ GEM
|
|||||||
nokogiri (1.16.4)
|
nokogiri (1.16.4)
|
||||||
mini_portile2 (~> 2.8.2)
|
mini_portile2 (~> 2.8.2)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.16.4-arm64-darwin)
|
nokogiri (1.16.4-aarch64-linux)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.16.4-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
oj (3.16.3)
|
oj (3.16.3)
|
||||||
bigdecimal (>= 3.0)
|
bigdecimal (>= 3.0)
|
||||||
@@ -529,7 +531,6 @@ GEM
|
|||||||
smart_properties (1.17.0)
|
smart_properties (1.17.0)
|
||||||
sqlite3 (1.7.3)
|
sqlite3 (1.7.3)
|
||||||
mini_portile2 (~> 2.8.0)
|
mini_portile2 (~> 2.8.0)
|
||||||
sqlite3 (1.7.3-arm64-darwin)
|
|
||||||
stringio (3.1.0)
|
stringio (3.1.0)
|
||||||
strip_attributes (1.13.0)
|
strip_attributes (1.13.0)
|
||||||
activemodel (>= 3.0, < 8.0)
|
activemodel (>= 3.0, < 8.0)
|
||||||
@@ -573,8 +574,9 @@ GEM
|
|||||||
zeitwerk (2.6.13)
|
zeitwerk (2.6.13)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
arm64-darwin-22
|
aarch64-linux
|
||||||
ruby
|
ruby
|
||||||
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
annotate
|
annotate
|
||||||
|
|||||||
@@ -3,3 +3,12 @@
|
|||||||
If you come across any security concern or vulnarability, please report the information via email to security@docuseal.co instead of opening a GitHub issue. We will promptly respond and will collaborate with you to validate the issue, and resolve it ASAP.
|
If you come across any security concern or vulnarability, please report the information via email to security@docuseal.co instead of opening a GitHub issue. We will promptly respond and will collaborate with you to validate the issue, and resolve it ASAP.
|
||||||
|
|
||||||
**We have a bug bounty program to reward security researchers.**
|
**We have a bug bounty program to reward security researchers.**
|
||||||
|
|
||||||
|
Out of scope vulnerabilities:
|
||||||
|
|
||||||
|
- CSRF
|
||||||
|
- DNSSEC, CAA, CSP headers
|
||||||
|
- DNS or email security related
|
||||||
|
- Rate Limiting
|
||||||
|
|
||||||
|
Note: We reserve the right to classify any reported vulnerability as out of scope for the bug bounty program.
|
||||||
@@ -104,20 +104,41 @@ module Api
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assign_submitter_attrs(submitter, attrs)
|
def assign_submitter_attrs(submitter, attrs)
|
||||||
submitter.email = Submissions.normalize_email(attrs[:email]) if attrs.key?(:email)
|
values = attrs[:values]&.to_unsafe_h || {}
|
||||||
submitter.phone = attrs[:phone].to_s.gsub(/[^0-9+]/, '') if attrs.key?(:phone)
|
|
||||||
submitter.values = submitter.values.merge(attrs[:values].to_unsafe_h) if attrs[:values].present?
|
|
||||||
submitter.completed_at = attrs[:completed] ? Time.current : submitter.completed_at
|
|
||||||
submitter.external_id = attrs[:application_key] if attrs.key?(:application_key)
|
|
||||||
submitter.external_id = attrs[:external_id] if attrs.key?(:external_id)
|
|
||||||
submitter.metadata = attrs[:metadata] if attrs.key?(:metadata)
|
|
||||||
|
|
||||||
assign_submission_fields(submitter.submission)
|
assign_submission_fields(submitter.submission)
|
||||||
|
|
||||||
|
phone_field_uuid = submitter.submission.template_fields.find do |f|
|
||||||
|
values[f['uuid']].present? && f['type'] == 'phone'
|
||||||
|
end&.dig('uuid')
|
||||||
|
|
||||||
|
submitter.email = Submissions.normalize_email(attrs[:email]) if attrs.key?(:email)
|
||||||
|
|
||||||
|
if attrs.key?(:phone)
|
||||||
|
submitter.phone = attrs[:phone].to_s.gsub(/[^0-9+]/, '')
|
||||||
|
elsif values[phone_field_uuid].present?
|
||||||
|
submitter.phone = values[phone_field_uuid].to_s.gsub(/[^0-9+]/, '')
|
||||||
|
end
|
||||||
|
|
||||||
|
values = values.except(phone_field_uuid)
|
||||||
|
|
||||||
|
submitter.values = submitter.values.merge(values) if values.present?
|
||||||
|
submitter.completed_at = attrs[:completed] ? Time.current : submitter.completed_at
|
||||||
|
submitter.metadata = attrs[:metadata] if attrs.key?(:metadata)
|
||||||
|
|
||||||
|
assign_external_id(submitter, attrs)
|
||||||
assign_preferences(submitter, attrs)
|
assign_preferences(submitter, attrs)
|
||||||
|
|
||||||
submitter
|
submitter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assign_external_id(submitter, attrs)
|
||||||
|
submitter.external_id = attrs[:application_key] if attrs.key?(:application_key)
|
||||||
|
submitter.external_id = attrs[:external_id] if attrs.key?(:external_id)
|
||||||
|
|
||||||
|
submitter
|
||||||
|
end
|
||||||
|
|
||||||
def assign_submission_fields(submission)
|
def assign_submission_fields(submission)
|
||||||
submission.template_fields ||= submission.template.fields
|
submission.template_fields ||= submission.template.fields
|
||||||
submission.template_schema ||= submission.template.schema
|
submission.template_schema ||= submission.template.schema
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ module Api
|
|||||||
|
|
||||||
Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
|
Templates::CloneAttachments.call(template: cloned_template, original_template: @template)
|
||||||
|
|
||||||
|
SendTemplateCreatedWebhookRequestJob.perform_later(cloned_template)
|
||||||
|
|
||||||
render json: Templates::SerializeForApi.call(cloned_template)
|
render json: Templates::SerializeForApi.call(cloned_template)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ module Api
|
|||||||
|
|
||||||
@template.update!(template_params)
|
@template.update!(template_params)
|
||||||
|
|
||||||
|
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
|
||||||
|
|
||||||
render json: @template.as_json(only: %i[id updated_at])
|
render json: @template.as_json(only: %i[id updated_at])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ class EsignSettingsController < ApplicationController
|
|||||||
save_new_cert!(@encrypted_config, @cert_record)
|
save_new_cert!(@encrypted_config, @cert_record)
|
||||||
|
|
||||||
redirect_to settings_esign_path, notice: 'Certificate has been successfully added!'
|
redirect_to settings_esign_path, notice: 'Certificate has been successfully added!'
|
||||||
rescue OpenSSL::PKCS12::PKCS12Error
|
rescue OpenSSL::PKCS12::PKCS12Error => e
|
||||||
@cert_record.errors.add(:password, "is invalid. Make sure you're uploading a valid .p12 file")
|
@cert_record.errors.add(:password, e.message)
|
||||||
|
|
||||||
render turbo_stream: turbo_stream.replace(:modal, template: 'esign_settings/new'), status: :unprocessable_entity
|
render turbo_stream: turbo_stream.replace(:modal, template: 'esign_settings/new'), status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class TemplatesController < ApplicationController
|
|||||||
if @template.save
|
if @template.save
|
||||||
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
|
Templates::CloneAttachments.call(template: @template, original_template: @base_template) if @base_template
|
||||||
|
|
||||||
|
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
|
||||||
|
|
||||||
maybe_redirect_to_template(@template)
|
maybe_redirect_to_template(@template)
|
||||||
else
|
else
|
||||||
render turbo_stream: turbo_stream.replace(:modal, template: 'templates/new'), status: :unprocessable_entity
|
render turbo_stream: turbo_stream.replace(:modal, template: 'templates/new'), status: :unprocessable_entity
|
||||||
@@ -70,6 +72,8 @@ class TemplatesController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@template.update!(template_params)
|
@template.update!(template_params)
|
||||||
|
|
||||||
|
SendTemplateUpdatedWebhookRequestJob.perform_later(@template)
|
||||||
|
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class TemplatesUploadsController < ApplicationController
|
|||||||
|
|
||||||
@template.update!(schema:)
|
@template.update!(schema:)
|
||||||
|
|
||||||
|
SendTemplateCreatedWebhookRequestJob.perform_later(@template)
|
||||||
|
|
||||||
redirect_to edit_template_path(@template)
|
redirect_to edit_template_path(@template)
|
||||||
rescue Templates::CreateAttachments::PdfEncrypted
|
rescue Templates::CreateAttachments::PdfEncrypted
|
||||||
render turbo_stream: turbo_stream.append(params[:form_id], html: helpers.tag.prompt_password)
|
render turbo_stream: turbo_stream.append(params[:form_id], html: helpers.tag.prompt_password)
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ class VerifyPdfSignatureController < ApplicationController
|
|||||||
trusted_certs = [default_pkcs.certificate,
|
trusted_certs = [default_pkcs.certificate,
|
||||||
*default_pkcs.ca_certs,
|
*default_pkcs.ca_certs,
|
||||||
*custom_certs.map(&:certificate),
|
*custom_certs.map(&:certificate),
|
||||||
*custom_certs.flat_map(&:ca_certs).compact]
|
*custom_certs.flat_map(&:ca_certs).compact,
|
||||||
|
*Docuseal.trusted_certs]
|
||||||
|
|
||||||
render turbo_stream: turbo_stream.replace('result', partial: 'result',
|
render turbo_stream: turbo_stream.replace('result', partial: 'result',
|
||||||
locals: { pdfs:, files: params[:files], trusted_certs: })
|
locals: { pdfs:, files: params[:files], trusted_certs: })
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ class WebhookPreferencesController < ApplicationController
|
|||||||
form.viewed
|
form.viewed
|
||||||
form.started
|
form.started
|
||||||
form.completed
|
form.completed
|
||||||
|
template.created
|
||||||
|
template.updated
|
||||||
submission.archived
|
submission.archived
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ window.customElements.define('submission-form', class extends HTMLElement {
|
|||||||
isDemo: this.dataset.isDemo === 'true',
|
isDemo: this.dataset.isDemo === 'true',
|
||||||
attribution: this.dataset.attribution !== 'false',
|
attribution: this.dataset.attribution !== 'false',
|
||||||
withConfetti: this.dataset.withConfetti !== 'false',
|
withConfetti: this.dataset.withConfetti !== 'false',
|
||||||
|
withDisclosure: this.dataset.withDisclosure === 'true',
|
||||||
withTypedSignature: this.dataset.withTypedSignature !== 'false',
|
withTypedSignature: this.dataset.withTypedSignature !== 'false',
|
||||||
authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content,
|
authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content,
|
||||||
values: reactive(JSON.parse(this.dataset.values)),
|
values: reactive(JSON.parse(this.dataset.values)),
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
class="field-area flex absolute lg:text-base -outline-offset-1"
|
class="field-area flex absolute lg:text-base -outline-offset-1"
|
||||||
dir="auto"
|
dir="auto"
|
||||||
:style="computedStyle"
|
:style="computedStyle"
|
||||||
:class="{ 'text-[1.5vw] lg:text-base': !textOverflowChars, 'text-[1.0vw] lg:text-xs': textOverflowChars, 'cursor-default': !submittable, 'border border-red-100 bg-red-100 cursor-pointer': submittable, 'border border-red-100': !isActive && submittable, 'bg-opacity-80': !isActive && !isValueSet && submittable, 'outline-red-500 outline-dashed outline-2 z-10': isActive && submittable, 'bg-opacity-40': (isActive || isValueSet) && submittable }"
|
:class="{ 'text-[1.5vw] lg:text-base': !textOverflowChars, 'text-[1.0vw] lg:text-xs': textOverflowChars, 'cursor-default': !submittable, 'border border-red-100 bg-red-100 cursor-pointer': submittable, 'border border-red-100': !isActive && submittable, 'bg-opacity-80': !isActive && !isValueSet && submittable, 'field-area-active outline-red-500 outline-dashed outline-2 z-10': isActive && submittable, 'bg-opacity-40': (isActive || isValueSet) && submittable }"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="!isActive && !isValueSet && field.type !== 'checkbox' && submittable && !area.option_uuid"
|
v-if="!isActive && !isValueSet && field.type !== 'checkbox' && submittable && !area.option_uuid"
|
||||||
@@ -165,6 +165,9 @@
|
|||||||
<span v-else-if="field.type === 'date'">
|
<span v-else-if="field.type === 'date'">
|
||||||
{{ formattedDate }}
|
{{ formattedDate }}
|
||||||
</span>
|
</span>
|
||||||
|
<span v-else-if="field.type === 'number'">
|
||||||
|
{{ formatNumber(modelValue, field.preferences?.format) }}
|
||||||
|
</span>
|
||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
class="whitespace-pre-wrap"
|
class="whitespace-pre-wrap"
|
||||||
@@ -373,6 +376,17 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
formatNumber (number, format) {
|
||||||
|
if (format === 'comma') {
|
||||||
|
return new Intl.NumberFormat('en-US').format(number)
|
||||||
|
} else if (format === 'dot') {
|
||||||
|
return new Intl.NumberFormat('de-DE').format(number)
|
||||||
|
} else if (format === 'space') {
|
||||||
|
return new Intl.NumberFormat('fr-FR').format(number)
|
||||||
|
} else {
|
||||||
|
return number
|
||||||
|
}
|
||||||
|
},
|
||||||
formatDate (date, format) {
|
formatDate (date, format) {
|
||||||
const monthFormats = {
|
const monthFormats = {
|
||||||
M: 'numeric',
|
M: 'numeric',
|
||||||
@@ -388,6 +402,7 @@ export default {
|
|||||||
|
|
||||||
const yearFormats = {
|
const yearFormats = {
|
||||||
YYYY: 'numeric',
|
YYYY: 'numeric',
|
||||||
|
YYY: 'numeric',
|
||||||
YY: '2-digit'
|
YY: '2-digit'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,9 +104,13 @@ export default {
|
|||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
|
|
||||||
return await Promise.all(
|
return await Promise.all(
|
||||||
Array.from(files).map((file) => {
|
Array.from(files).map(async (file) => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
|
|
||||||
|
if (file.type === 'image/bmp') {
|
||||||
|
file = await this.convertBmpToPng(file)
|
||||||
|
}
|
||||||
|
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
formData.append('submitter_slug', this.submitterSlug)
|
formData.append('submitter_slug', this.submitterSlug)
|
||||||
formData.append('name', 'attachments')
|
formData.append('name', 'attachments')
|
||||||
@@ -122,6 +126,32 @@ export default {
|
|||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
convertBmpToPng (bmpFile) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader()
|
||||||
|
|
||||||
|
reader.onload = function (event) {
|
||||||
|
const img = new Image()
|
||||||
|
|
||||||
|
img.onload = function () {
|
||||||
|
const canvas = document.createElement('canvas')
|
||||||
|
const ctx = canvas.getContext('2d')
|
||||||
|
|
||||||
|
canvas.width = img.width
|
||||||
|
canvas.height = img.height
|
||||||
|
ctx.drawImage(img, 0, 0)
|
||||||
|
canvas.toBlob(function (blob) {
|
||||||
|
const newFile = new File([blob], bmpFile.name.replace(/\.\w+$/, '.png'), { type: 'image/png' })
|
||||||
|
resolve(newFile)
|
||||||
|
}, 'image/png')
|
||||||
|
}
|
||||||
|
|
||||||
|
img.src = event.target.result
|
||||||
|
}
|
||||||
|
reader.onerror = reject
|
||||||
|
reader.readAsDataURL(bmpFile)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,6 +324,8 @@
|
|||||||
:previous-value="previousSignatureValueFor(currentField)"
|
:previous-value="previousSignatureValueFor(currentField)"
|
||||||
:with-typed-signature="withTypedSignature"
|
:with-typed-signature="withTypedSignature"
|
||||||
:attachments-index="attachmentsIndex"
|
:attachments-index="attachmentsIndex"
|
||||||
|
:button-text="buttonText"
|
||||||
|
:with-disclosure="withDisclosure"
|
||||||
:submitter-slug="submitterSlug"
|
:submitter-slug="submitterSlug"
|
||||||
:show-field-names="showFieldNames"
|
:show-field-names="showFieldNames"
|
||||||
@attached="attachments.push($event)"
|
@attached="attachments.push($event)"
|
||||||
@@ -382,7 +384,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="currentField.type !== 'payment' || submittedValues[currentField.uuid]"
|
v-if="currentField.type !== 'payment' || submittedValues[currentField.uuid]"
|
||||||
class="mt-6 md:mt-8"
|
:class="withDisclosure && currentField.type === 'signature' ? 'mt-2' : 'mt-6 md:mt-8'"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
id="submit_form_button"
|
id="submit_form_button"
|
||||||
@@ -396,11 +398,8 @@
|
|||||||
v-if="isSubmitting"
|
v-if="isSubmitting"
|
||||||
class="mr-1 animate-spin"
|
class="mr-1 animate-spin"
|
||||||
/>
|
/>
|
||||||
<span v-if="alwaysMinimize || stepFields.length === currentStep + 1">
|
|
||||||
{{ t('submit') }}
|
|
||||||
</span>
|
|
||||||
<span v-else>
|
<span v-else>
|
||||||
{{ t('next') }}
|
{{ buttonText }}
|
||||||
</span><span
|
</span><span
|
||||||
v-if="isSubmitting"
|
v-if="isSubmitting"
|
||||||
class="w-6 flex justify-start mr-1"
|
class="w-6 flex justify-start mr-1"
|
||||||
@@ -554,6 +553,11 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
withDisclosure: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
reuseSignature: {
|
reuseSignature: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -682,11 +686,18 @@ export default {
|
|||||||
isMobile () {
|
isMobile () {
|
||||||
return /android|iphone|ipad/i.test(navigator.userAgent)
|
return /android|iphone|ipad/i.test(navigator.userAgent)
|
||||||
},
|
},
|
||||||
|
buttonText () {
|
||||||
|
if (this.alwaysMinimize || this.stepFields.length === this.currentStep + 1) {
|
||||||
|
return this.t('submit')
|
||||||
|
} else {
|
||||||
|
return this.t('next')
|
||||||
|
}
|
||||||
|
},
|
||||||
alwaysMinimize () {
|
alwaysMinimize () {
|
||||||
return this.minimize || (this.orientation?.includes('landscape') && this.isMobile && parseInt(window.innerHeight) < 550)
|
return this.minimize || (this.orientation?.includes('landscape') && this.isMobile && parseInt(window.innerHeight) < 550)
|
||||||
},
|
},
|
||||||
currentStepFields () {
|
currentStepFields () {
|
||||||
return this.stepFields[this.currentStep]
|
return this.stepFields[this.currentStep] || []
|
||||||
},
|
},
|
||||||
browserLanguage () {
|
browserLanguage () {
|
||||||
return (navigator.language || navigator.userLanguage || 'en').split('-')[0]
|
return (navigator.language || navigator.userLanguage || 'en').split('-')[0]
|
||||||
@@ -763,7 +774,7 @@ export default {
|
|||||||
this.isFormVisible = value
|
this.isFormVisible = value
|
||||||
},
|
},
|
||||||
currentStepFields (value) {
|
currentStepFields (value) {
|
||||||
if (!value) {
|
if (isEmpty(value)) {
|
||||||
this.currentStep -= 1
|
this.currentStep -= 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
const en = {
|
const en = {
|
||||||
text: 'Text',
|
text: 'Text',
|
||||||
|
by_clicking_you_agree_to_the: 'By clicking "{button}", you agree to the',
|
||||||
|
electronic_signature_disclosure: 'Electronic Signature Disclosure',
|
||||||
|
esignature_disclosure: 'eSignature Disclosure',
|
||||||
signature: 'Signature',
|
signature: 'Signature',
|
||||||
initials: 'Initials',
|
initials: 'Initials',
|
||||||
date: 'Date',
|
date: 'Date',
|
||||||
@@ -65,6 +68,9 @@ const en = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const es = {
|
const es = {
|
||||||
|
by_clicking_you_agree_to_the: 'Al hacer clic en "{button}", usted acepta el',
|
||||||
|
electronic_signature_disclosure: 'Divulgación de Firma Electrónica',
|
||||||
|
esignature_disclosure: 'Divulgación de eFirma',
|
||||||
minimize: 'Minimizar',
|
minimize: 'Minimizar',
|
||||||
text: 'Texto',
|
text: 'Texto',
|
||||||
signature: 'Firma',
|
signature: 'Firma',
|
||||||
@@ -130,6 +136,9 @@ const es = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const it = {
|
const it = {
|
||||||
|
by_clicking_you_agree_to_the: 'Cliccando su "{button}", accetti il',
|
||||||
|
electronic_signature_disclosure: 'Divulgazione della Firma Elettronica',
|
||||||
|
esignature_disclosure: 'Divulgazione della eFirma',
|
||||||
minimize: 'Minimizza',
|
minimize: 'Minimizza',
|
||||||
text: 'Testo',
|
text: 'Testo',
|
||||||
signature: 'Firma',
|
signature: 'Firma',
|
||||||
@@ -195,6 +204,9 @@ const it = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const de = {
|
const de = {
|
||||||
|
by_clicking_you_agree_to_the: 'Durch Klicken auf "{button}" stimmen Sie zu, dass Sie die',
|
||||||
|
electronic_signature_disclosure: 'Elektronische Unterschriftenoffenlegung',
|
||||||
|
esignature_disclosure: 'eSignatur Offenlegung',
|
||||||
minimize: 'Minimieren',
|
minimize: 'Minimieren',
|
||||||
text: 'Text',
|
text: 'Text',
|
||||||
signature: 'Unterschrift',
|
signature: 'Unterschrift',
|
||||||
@@ -260,6 +272,9 @@ const de = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fr = {
|
const fr = {
|
||||||
|
by_clicking_you_agree_to_the: 'En cliquant sur "{button}", vous acceptez la',
|
||||||
|
electronic_signature_disclosure: 'Divulgation de Signature Électronique',
|
||||||
|
esignature_disclosure: 'Divulgation de la eSignature',
|
||||||
minimize: 'Réduire',
|
minimize: 'Réduire',
|
||||||
text: 'Texte',
|
text: 'Texte',
|
||||||
signature: 'Signature',
|
signature: 'Signature',
|
||||||
@@ -325,6 +340,9 @@ const fr = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pl = {
|
const pl = {
|
||||||
|
by_clicking_you_agree_to_the: 'Klikając na "{button}", zgadzasz się na',
|
||||||
|
electronic_signature_disclosure: 'Ujawnienie Elektronicznej Sygnatury',
|
||||||
|
esignature_disclosure: 'Ujawnienie ePodpisu',
|
||||||
minimize: 'Zminimalizuj',
|
minimize: 'Zminimalizuj',
|
||||||
text: 'Tekst',
|
text: 'Tekst',
|
||||||
signature: 'Podpis',
|
signature: 'Podpis',
|
||||||
@@ -390,6 +408,9 @@ const pl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uk = {
|
const uk = {
|
||||||
|
by_clicking_you_agree_to_the: 'Натиснувши на "{button}", ви погоджуєтеся з',
|
||||||
|
electronic_signature_disclosure: 'Розголошення Електронного Підпису',
|
||||||
|
esignature_disclosure: 'Розголошення еПідпису',
|
||||||
minimize: 'Зменшити',
|
minimize: 'Зменшити',
|
||||||
text: 'Текст',
|
text: 'Текст',
|
||||||
signature: 'Підпис',
|
signature: 'Підпис',
|
||||||
@@ -455,6 +476,9 @@ const uk = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cs = {
|
const cs = {
|
||||||
|
by_clicking_you_agree_to_the: 'Kliknutím na "{button}" souhlasíte s',
|
||||||
|
electronic_signature_disclosure: 'Zveřejněním Elektronického Podpisu',
|
||||||
|
esignature_disclosure: 'Zveřejnění ePodpisu',
|
||||||
minimize: 'Minimalizovat',
|
minimize: 'Minimalizovat',
|
||||||
text: 'Text',
|
text: 'Text',
|
||||||
signature: 'Podpis',
|
signature: 'Podpis',
|
||||||
@@ -520,6 +544,9 @@ const cs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pt = {
|
const pt = {
|
||||||
|
by_clicking_you_agree_to_the: 'Ao clicar em "{button}", você concorda com o',
|
||||||
|
electronic_signature_disclosure: 'Divulgação de Assinatura Eletrônica',
|
||||||
|
esignature_disclosure: 'Divulgação da eAssinatura',
|
||||||
minimize: 'Minimizar',
|
minimize: 'Minimizar',
|
||||||
text: 'Texto',
|
text: 'Texto',
|
||||||
signature: 'Assinatura',
|
signature: 'Assinatura',
|
||||||
@@ -585,6 +612,9 @@ const pt = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const he = {
|
const he = {
|
||||||
|
by_clicking_you_agree_to_the: 'על ידי לחיצה על "{button}", אתה מסכים ל',
|
||||||
|
electronic_signature_disclosure: 'חשיפת חתימה אלקטרונית',
|
||||||
|
esignature_disclosure: 'חשיפת ה-eחתימה',
|
||||||
minimize: 'לקטן',
|
minimize: 'לקטן',
|
||||||
text: 'טקסט',
|
text: 'טקסט',
|
||||||
signature: 'חתימה',
|
signature: 'חתימה',
|
||||||
@@ -651,6 +681,9 @@ const he = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nl = {
|
const nl = {
|
||||||
|
by_clicking_you_agree_to_the: 'Door op "{button}" te klikken, gaat u akkoord met de',
|
||||||
|
electronic_signature_disclosure: 'Openbaarmaking van Elektronische Handtekening',
|
||||||
|
esignature_disclosure: 'Openbaarmaking van eHandtekening',
|
||||||
minimize: 'Minimaliseren',
|
minimize: 'Minimaliseren',
|
||||||
text: 'Tekst',
|
text: 'Tekst',
|
||||||
signature: 'Handtekening',
|
signature: 'Handtekening',
|
||||||
@@ -717,6 +750,9 @@ const nl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ar = {
|
const ar = {
|
||||||
|
by_clicking_you_agree_to_the: 'بالنقر فوق "{button}"، أنت توافق على',
|
||||||
|
electronic_signature_disclosure: 'كشف التوقيع الإلكتروني',
|
||||||
|
esignature_disclosure: 'كشف التوقيع الإلكتروني',
|
||||||
text: 'نص',
|
text: 'نص',
|
||||||
signature: 'توقيع',
|
signature: 'توقيع',
|
||||||
initials: 'الاختصارات',
|
initials: 'الاختصارات',
|
||||||
@@ -783,6 +819,9 @@ const ar = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ko = {
|
const ko = {
|
||||||
|
by_clicking_you_agree_to_the: '"{button}"를 클릭함으로써, 다음에 동의하게 됩니다',
|
||||||
|
electronic_signature_disclosure: '전자 서명 공개',
|
||||||
|
esignature_disclosure: '전자 서명 공개',
|
||||||
text: '텍스트',
|
text: '텍스트',
|
||||||
signature: '서명',
|
signature: '서명',
|
||||||
initials: '이니셜',
|
initials: '이니셜',
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div dir="auto">
|
<div
|
||||||
|
dir="auto"
|
||||||
|
class="relative"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex justify-between items-center w-full"
|
class="flex justify-between items-center w-full"
|
||||||
:class="{ 'mb-2': !field.description }"
|
:class="{ 'mb-2': !field.description }"
|
||||||
@@ -136,6 +139,23 @@
|
|||||||
type="text"
|
type="text"
|
||||||
@input="updateWrittenSignature"
|
@input="updateWrittenSignature"
|
||||||
>
|
>
|
||||||
|
<div
|
||||||
|
v-if="withDisclosure"
|
||||||
|
dir="auto"
|
||||||
|
class="text-base-content/60 text-xs text-center w-full mt-1"
|
||||||
|
>
|
||||||
|
{{ t('by_clicking_you_agree_to_the').replace('{button}', buttonText.charAt(0).toUpperCase() + buttonText.slice(1)) }} <a
|
||||||
|
href="https://www.docuseal.co/esign-disclosure"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<span class="inline md:hidden">
|
||||||
|
{{ t('esignature_disclosure') }}
|
||||||
|
</span>
|
||||||
|
<span class="hidden md:inline">
|
||||||
|
{{ t('electronic_signature_disclosure') }}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -176,6 +196,16 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
withDisclosure: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
buttonText: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: 'Submit'
|
||||||
|
},
|
||||||
withTypedSignature: {
|
withTypedSignature: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
@blur="onNameBlur"
|
@blur="onNameBlur"
|
||||||
>{{ optionIndexText }} {{ (defaultField ? (field.title || field.name) : field.name) || defaultName }}</span>
|
>{{ optionIndexText }} {{ (defaultField ? (field.title || field.name) : field.name) || defaultName }}</span>
|
||||||
<div
|
<div
|
||||||
v-if="isNameFocus && !['checkbox', 'phone'].includes(field.type)"
|
v-if="isSettingsFocus || (isNameFocus && !['checkbox', 'phone'].includes(field.type))"
|
||||||
class="flex items-center ml-1.5"
|
class="flex items-center ml-1.5"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -86,6 +86,47 @@
|
|||||||
@click.prevent="field.required = !field.required"
|
@click.prevent="field.required = !field.required"
|
||||||
@mousedown.prevent
|
@mousedown.prevent
|
||||||
>{{ t('required') }}</label>
|
>{{ t('required') }}</label>
|
||||||
|
<span
|
||||||
|
v-if="field.type !== 'payment'"
|
||||||
|
class="dropdown dropdown-end"
|
||||||
|
@mouseenter="renderDropdown = true"
|
||||||
|
@touchstart="renderDropdown = true"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
ref="settingsButton"
|
||||||
|
tabindex="0"
|
||||||
|
:title="t('settings')"
|
||||||
|
class="cursor-pointer flex items-center"
|
||||||
|
style="height: 25px"
|
||||||
|
@focus="isSettingsFocus = true"
|
||||||
|
@blur="maybeBlurSettings"
|
||||||
|
>
|
||||||
|
<IconDotsVertical class="w-5 h-5" />
|
||||||
|
</label>
|
||||||
|
<ul
|
||||||
|
v-if="renderDropdown"
|
||||||
|
ref="settingsDropdown"
|
||||||
|
tabindex="0"
|
||||||
|
class="dropdown-content menu menu-xs px-2 pb-2 pt-1 shadow rounded-box w-52 z-10 rounded-t-none"
|
||||||
|
:style="{ backgroundColor: 'white' }"
|
||||||
|
@dragstart.prevent.stop
|
||||||
|
@click="closeDropdown"
|
||||||
|
@focusout="maybeBlurSettings"
|
||||||
|
>
|
||||||
|
<FieldSettings
|
||||||
|
:field="field"
|
||||||
|
:default-field="defaultField"
|
||||||
|
:editable="editable"
|
||||||
|
:background-color="'white'"
|
||||||
|
:with-required="false"
|
||||||
|
:with-areas="false"
|
||||||
|
@click-formula="isShowFormulaModal = true"
|
||||||
|
@click-description="isShowDescriptionModal = true"
|
||||||
|
@click-condition="isShowConditionsModal = true"
|
||||||
|
@scroll-to="[selectedAreaRef.value = $event, $emit('scroll-to', $event)]"
|
||||||
|
/>
|
||||||
|
</ul>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
v-else-if="editable"
|
v-else-if="editable"
|
||||||
@@ -120,6 +161,10 @@
|
|||||||
class="aspect-square mx-auto"
|
class="aspect-square mx-auto"
|
||||||
:class="{ '!w-auto !h-full': area.w > area.h, '!w-full !h-auto': area.w <= area.h }"
|
:class="{ '!w-auto !h-full': area.w > area.h, '!w-full !h-auto': area.w <= area.h }"
|
||||||
/>
|
/>
|
||||||
|
<span
|
||||||
|
v-else-if="field.type === 'number'"
|
||||||
|
class="whitespace-pre-wrap"
|
||||||
|
>{{ formatNumber(field.default_value, field.preferences?.format) }}</span>
|
||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
class="whitespace-pre-wrap"
|
class="whitespace-pre-wrap"
|
||||||
@@ -145,6 +190,38 @@
|
|||||||
@mousedown.stop="startResize"
|
@mousedown.stop="startResize"
|
||||||
@touchstart="startTouchResize"
|
@touchstart="startTouchResize"
|
||||||
/>
|
/>
|
||||||
|
<Teleport
|
||||||
|
v-if="isShowFormulaModal"
|
||||||
|
:to="modalContainerEl"
|
||||||
|
>
|
||||||
|
<FormulaModal
|
||||||
|
:field="field"
|
||||||
|
:editable="editable && !defaultField"
|
||||||
|
:build-default-name="buildDefaultName"
|
||||||
|
@close="isShowFormulaModal = false"
|
||||||
|
/>
|
||||||
|
</Teleport>
|
||||||
|
<Teleport
|
||||||
|
v-if="isShowConditionsModal"
|
||||||
|
:to="modalContainerEl"
|
||||||
|
>
|
||||||
|
<ConditionsModal
|
||||||
|
:field="field"
|
||||||
|
:build-default-name="buildDefaultName"
|
||||||
|
@close="isShowConditionsModal = false"
|
||||||
|
/>
|
||||||
|
</Teleport>
|
||||||
|
<Teleport
|
||||||
|
v-if="isShowDescriptionModal"
|
||||||
|
:to="modalContainerEl"
|
||||||
|
>
|
||||||
|
<DescriptionModal
|
||||||
|
:field="field"
|
||||||
|
:editable="editable && !defaultField"
|
||||||
|
:build-default-name="buildDefaultName"
|
||||||
|
@close="isShowDescriptionModal = false"
|
||||||
|
/>
|
||||||
|
</Teleport>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -152,7 +229,11 @@
|
|||||||
import FieldSubmitter from './field_submitter'
|
import FieldSubmitter from './field_submitter'
|
||||||
import FieldType from './field_type'
|
import FieldType from './field_type'
|
||||||
import Field from './field'
|
import Field from './field'
|
||||||
import { IconX, IconCheck } from '@tabler/icons-vue'
|
import FieldSettings from './field_settings'
|
||||||
|
import FormulaModal from './formula_modal'
|
||||||
|
import ConditionsModal from './conditions_modal'
|
||||||
|
import DescriptionModal from './description_modal'
|
||||||
|
import { IconX, IconCheck, IconDotsVertical } from '@tabler/icons-vue'
|
||||||
import { v4 } from 'uuid'
|
import { v4 } from 'uuid'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -160,6 +241,11 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
FieldType,
|
FieldType,
|
||||||
IconCheck,
|
IconCheck,
|
||||||
|
FieldSettings,
|
||||||
|
FormulaModal,
|
||||||
|
IconDotsVertical,
|
||||||
|
DescriptionModal,
|
||||||
|
ConditionsModal,
|
||||||
FieldSubmitter,
|
FieldSubmitter,
|
||||||
IconX
|
IconX
|
||||||
},
|
},
|
||||||
@@ -195,11 +281,16 @@ export default {
|
|||||||
default: null
|
default: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['start-resize', 'stop-resize', 'start-drag', 'stop-drag', 'remove'],
|
emits: ['start-resize', 'stop-resize', 'start-drag', 'stop-drag', 'remove', 'scroll-to'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
isShowFormulaModal: false,
|
||||||
|
isShowConditionsModal: false,
|
||||||
|
isSettingsFocus: false,
|
||||||
|
isShowDescriptionModal: false,
|
||||||
isResize: false,
|
isResize: false,
|
||||||
isDragged: false,
|
isDragged: false,
|
||||||
|
renderDropdown: false,
|
||||||
isNameFocus: false,
|
isNameFocus: false,
|
||||||
textOverflowChars: 0,
|
textOverflowChars: 0,
|
||||||
dragFrom: { x: 0, y: 0 }
|
dragFrom: { x: 0, y: 0 }
|
||||||
@@ -208,6 +299,9 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
fieldNames: FieldType.computed.fieldNames,
|
fieldNames: FieldType.computed.fieldNames,
|
||||||
fieldIcons: FieldType.computed.fieldIcons,
|
fieldIcons: FieldType.computed.fieldIcons,
|
||||||
|
modalContainerEl () {
|
||||||
|
return this.$el.getRootNode().querySelector('#docuseal_modal_container')
|
||||||
|
},
|
||||||
defaultName () {
|
defaultName () {
|
||||||
return this.buildDefaultName(this.field, this.template.fields)
|
return this.buildDefaultName(this.field, this.template.fields)
|
||||||
},
|
},
|
||||||
@@ -324,6 +418,25 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildDefaultName: Field.methods.buildDefaultName,
|
buildDefaultName: Field.methods.buildDefaultName,
|
||||||
|
closeDropdown () {
|
||||||
|
document.activeElement.blur()
|
||||||
|
},
|
||||||
|
formatNumber (number, format) {
|
||||||
|
if (format === 'comma') {
|
||||||
|
return new Intl.NumberFormat('en-US').format(number)
|
||||||
|
} else if (format === 'dot') {
|
||||||
|
return new Intl.NumberFormat('de-DE').format(number)
|
||||||
|
} else if (format === 'space') {
|
||||||
|
return new Intl.NumberFormat('fr-FR').format(number)
|
||||||
|
} else {
|
||||||
|
return number
|
||||||
|
}
|
||||||
|
},
|
||||||
|
maybeBlurSettings (e) {
|
||||||
|
if (!e.relatedTarget || !this.$refs.settingsDropdown.contains(e.relatedTarget)) {
|
||||||
|
this.isSettingsFocus = false
|
||||||
|
}
|
||||||
|
},
|
||||||
onNameFocus (e) {
|
onNameFocus (e) {
|
||||||
this.selectedAreaRef.value = this.area
|
this.selectedAreaRef.value = this.area
|
||||||
|
|
||||||
@@ -379,6 +492,10 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onNameBlur (e) {
|
onNameBlur (e) {
|
||||||
|
if (e.relatedTarget === this.$refs.settingsButton) {
|
||||||
|
this.isSettingsFocus = true
|
||||||
|
}
|
||||||
|
|
||||||
const text = this.$refs.name.innerText.trim()
|
const text = this.$refs.name.innerText.trim()
|
||||||
|
|
||||||
this.isNameFocus = false
|
this.isNameFocus = false
|
||||||
|
|||||||
@@ -857,7 +857,7 @@ export default {
|
|||||||
type = this.fieldTypes[0]
|
type = this.fieldTypes[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'checkbox' && !this.drawFieldType) {
|
if (type === 'checkbox' && !this.drawFieldType && (this.template.fields[this.template.fields.length - 1]?.type === 'checkbox' || area.w)) {
|
||||||
const previousField = [...this.template.fields].reverse().find((f) => f.type === type)
|
const previousField = [...this.template.fields].reverse().find((f) => f.type === type)
|
||||||
const previousArea = previousField?.areas?.[previousField.areas.length - 1]
|
const previousArea = previousField?.areas?.[previousField.areas.length - 1]
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,7 @@
|
|||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
>
|
>
|
||||||
<template
|
{{ value }}
|
||||||
v-for="(item, index) in (value || '').split(/(_)/)"
|
|
||||||
:key="index"
|
|
||||||
>{{ item }}<wbr></template>
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="withRequired"
|
v-if="withRequired"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
:image="image"
|
:image="image"
|
||||||
@drop-field="$emit('drop-field', {...$event, attachment_uuid: document.uuid })"
|
@drop-field="$emit('drop-field', {...$event, attachment_uuid: document.uuid })"
|
||||||
@remove-area="$emit('remove-area', $event)"
|
@remove-area="$emit('remove-area', $event)"
|
||||||
|
@scroll-to="scrollToArea"
|
||||||
@draw="$emit('draw', {...$event, attachment_uuid: document.uuid })"
|
@draw="$emit('draw', {...$event, attachment_uuid: document.uuid })"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -125,7 +126,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
scrollToArea (area) {
|
scrollToArea (area) {
|
||||||
this.pageRefs[area.page].areaRefs.find((e) => e.area === area).$el.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
this.$nextTick(() => {
|
||||||
|
this.pageRefs[area.page].areaRefs.find((e) => e.area === area).$el.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setPageRefs (el) {
|
setPageRefs (el) {
|
||||||
if (el) {
|
if (el) {
|
||||||
|
|||||||
@@ -118,280 +118,17 @@
|
|||||||
@dragstart.prevent.stop
|
@dragstart.prevent.stop
|
||||||
@click="closeDropdown"
|
@click="closeDropdown"
|
||||||
>
|
>
|
||||||
<div
|
<FieldSettings
|
||||||
v-if="['number'].includes(field.type)"
|
:field="field"
|
||||||
class="py-1.5 px-1 relative"
|
:default-field="defaultField"
|
||||||
@click.stop
|
:editable="editable"
|
||||||
>
|
:background-color="dropdownBgColor"
|
||||||
<select
|
@click-formula="isShowFormulaModal = true"
|
||||||
class="select select-bordered select-xs w-full max-w-xs h-7 !outline-0 font-normal bg-transparent"
|
@click-description="isShowDescriptionModal = true"
|
||||||
@change="[field.preferences ||= {}, field.preferences.align = $event.target.value, save()]"
|
@click-condition="isShowConditionsModal = true"
|
||||||
>
|
@set-draw="$emit('set-draw', $event)"
|
||||||
<option
|
@scroll-to="$emit('scroll-to', $event)"
|
||||||
v-for="value in ['left', 'right', 'center']"
|
/>
|
||||||
:key="value"
|
|
||||||
:selected="field.preferences?.align ? value === field.preferences.align : value === 'left'"
|
|
||||||
:value="value"
|
|
||||||
>
|
|
||||||
{{ t(value) }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<label
|
|
||||||
:style="{ backgroundColor: dropdownBgColor }"
|
|
||||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
|
||||||
style="font-size: 8px"
|
|
||||||
>
|
|
||||||
{{ t('align') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="['text', 'number'].includes(field.type) && !defaultField"
|
|
||||||
class="py-1.5 px-1 relative"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
v-model="field.default_value"
|
|
||||||
:placeholder="t('default_value')"
|
|
||||||
dir="auto"
|
|
||||||
:type="field.type"
|
|
||||||
class="input input-bordered input-xs w-full max-w-xs h-7 !outline-0 bg-transparent"
|
|
||||||
@blur="save"
|
|
||||||
>
|
|
||||||
<label
|
|
||||||
v-if="field.default_value"
|
|
||||||
:style="{ backgroundColor: dropdownBgColor }"
|
|
||||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
|
||||||
style="font-size: 8px"
|
|
||||||
>
|
|
||||||
{{ t('default_value') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="field.type === 'date'"
|
|
||||||
class="py-1.5 px-1 relative"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<select
|
|
||||||
v-model="field.preferences.format"
|
|
||||||
:placeholder="t('format')"
|
|
||||||
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
|
|
||||||
@change="save"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="format in dateFormats"
|
|
||||||
:key="format"
|
|
||||||
:value="format"
|
|
||||||
>
|
|
||||||
{{ formatDate(new Date(), format) }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<label
|
|
||||||
:style="{ backgroundColor: dropdownBgColor }"
|
|
||||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
|
||||||
style="font-size: 8px"
|
|
||||||
>
|
|
||||||
{{ t('format') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-if="field.type === 'signature'"
|
|
||||||
class="py-1.5 px-1 relative"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<select
|
|
||||||
:placeholder="t('format')"
|
|
||||||
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
|
|
||||||
@change="[field.preferences.format = $event.target.value, save()]"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
value="any"
|
|
||||||
:selected="!field.preferences?.format || field.preferences.format === 'any'"
|
|
||||||
>
|
|
||||||
{{ t('any') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
value="drawn"
|
|
||||||
:selected="field.preferences?.format === 'drawn'"
|
|
||||||
>
|
|
||||||
{{ t('drawn') }}
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
value="typed"
|
|
||||||
:selected="field.preferences?.format === 'typed'"
|
|
||||||
>
|
|
||||||
{{ t('typed') }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<label
|
|
||||||
:style="{ backgroundColor: dropdownBgColor }"
|
|
||||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
|
||||||
style="font-size: 8px"
|
|
||||||
>
|
|
||||||
{{ t('format') }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<li
|
|
||||||
v-if="field.type != 'phone' && field.type != 'stamp'"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<label class="cursor-pointer py-1.5">
|
|
||||||
<input
|
|
||||||
v-model="field.required"
|
|
||||||
type="checkbox"
|
|
||||||
:disabled="!editable || defaultField"
|
|
||||||
class="toggle toggle-xs"
|
|
||||||
@update:model-value="save"
|
|
||||||
>
|
|
||||||
<span class="label-text">{{ t('required') }}</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
v-if="field.type == 'stamp'"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<label class="cursor-pointer py-1.5">
|
|
||||||
<input
|
|
||||||
:checked="field.preferences?.with_logo != false"
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-xs"
|
|
||||||
@change="[field.preferences ||= {}, field.preferences.with_logo = field.preferences.with_logo == false, save()]"
|
|
||||||
>
|
|
||||||
<span class="label-text">{{ t('with_logo') }}</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
v-if="field.type == 'checkbox'"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<label class="cursor-pointer py-1.5">
|
|
||||||
<input
|
|
||||||
v-model="field.default_value"
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-xs"
|
|
||||||
@update:model-value="[field.default_value = $event, field.readonly = $event, save()]"
|
|
||||||
>
|
|
||||||
<span class="label-text">{{ t('checked') }}</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
v-if="field.type == 'date'"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<label class="cursor-pointer py-1.5">
|
|
||||||
<input
|
|
||||||
v-model="field.readonly"
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-xs"
|
|
||||||
@update:model-value="[field.default_value = $event ? '{{date}}' : null, field.readonly = $event, save()]"
|
|
||||||
>
|
|
||||||
<span class="label-text">{{ t('set_signing_date') }}</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
v-if="['text', 'number'].includes(field.type) && !defaultField"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<label class="cursor-pointer py-1.5">
|
|
||||||
<input
|
|
||||||
v-model="field.readonly"
|
|
||||||
type="checkbox"
|
|
||||||
class="toggle toggle-xs"
|
|
||||||
@update:model-value="save"
|
|
||||||
>
|
|
||||||
<span class="label-text">{{ t('read_only') }}</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<hr
|
|
||||||
v-if="field.type != 'stamp'"
|
|
||||||
class="pb-0.5 mt-0.5"
|
|
||||||
>
|
|
||||||
<li
|
|
||||||
v-if="field.type != 'stamp'"
|
|
||||||
>
|
|
||||||
<label
|
|
||||||
class="label-text cursor-pointer text-center w-full flex items-center"
|
|
||||||
@click="isShowDescriptionModal = !isShowDescriptionModal"
|
|
||||||
>
|
|
||||||
<IconInfoCircle
|
|
||||||
width="18"
|
|
||||||
/>
|
|
||||||
<span class="text-sm">
|
|
||||||
{{ t('description') }}
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li
|
|
||||||
v-if="field.type != 'stamp'"
|
|
||||||
>
|
|
||||||
<label
|
|
||||||
class="label-text cursor-pointer text-center w-full flex items-center"
|
|
||||||
@click="isShowConditionsModal = !isShowConditionsModal"
|
|
||||||
>
|
|
||||||
<IconRouteAltLeft
|
|
||||||
width="18"
|
|
||||||
/>
|
|
||||||
<span class="text-sm">
|
|
||||||
{{ t('condition') }}
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<li v-if="field.type == 'number'">
|
|
||||||
<label
|
|
||||||
class="label-text cursor-pointer text-center w-full flex items-center"
|
|
||||||
@click="isShowFormulaModal = true"
|
|
||||||
>
|
|
||||||
<IconMathFunction
|
|
||||||
width="18"
|
|
||||||
/>
|
|
||||||
<span class="text-sm">
|
|
||||||
{{ t('formula') }}
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</li>
|
|
||||||
<hr class="pb-0.5 mt-0.5">
|
|
||||||
<li
|
|
||||||
v-for="(area, index) in sortedAreas"
|
|
||||||
:key="index"
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
class="text-sm py-1 px-2"
|
|
||||||
@click.prevent="$emit('scroll-to', area)"
|
|
||||||
>
|
|
||||||
<IconShape
|
|
||||||
:width="20"
|
|
||||||
:stroke-width="1.6"
|
|
||||||
/>
|
|
||||||
{{ t('page') }}
|
|
||||||
<template v-if="template.schema.length > 1">{{ template.schema.findIndex((item) => item.attachment_uuid === area.attachment_uuid) + 1 }}-</template>{{ area.page + 1 }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li v-if="!field.areas?.length || !['radio', 'multiple'].includes(field.type)">
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
class="text-sm py-1 px-2"
|
|
||||||
@click.prevent="$emit('set-draw', { field })"
|
|
||||||
>
|
|
||||||
<IconNewSection
|
|
||||||
:width="20"
|
|
||||||
:stroke-width="1.6"
|
|
||||||
/>
|
|
||||||
{{ t('draw_new_area') }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li v-if="field.areas?.length === 1 && ['date', 'signature', 'initials', 'text', 'cells'].includes(field.type)">
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
class="text-sm py-1 px-2"
|
|
||||||
@click.prevent="copyToAllPages(field)"
|
|
||||||
>
|
|
||||||
<IconCopy
|
|
||||||
:width="20"
|
|
||||||
:stroke-width="1.6"
|
|
||||||
/>
|
|
||||||
{{ t('copy_to_all_pages') }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
@@ -518,10 +255,11 @@
|
|||||||
import Contenteditable from './contenteditable'
|
import Contenteditable from './contenteditable'
|
||||||
import FieldType from './field_type'
|
import FieldType from './field_type'
|
||||||
import PaymentSettings from './payment_settings'
|
import PaymentSettings from './payment_settings'
|
||||||
|
import FieldSettings from './field_settings'
|
||||||
import FormulaModal from './formula_modal'
|
import FormulaModal from './formula_modal'
|
||||||
import ConditionsModal from './conditions_modal'
|
import ConditionsModal from './conditions_modal'
|
||||||
import DescriptionModal from './description_modal'
|
import DescriptionModal from './description_modal'
|
||||||
import { IconInfoCircle, IconRouteAltLeft, IconMathFunction, IconShape, IconNewSection, IconTrashX, IconCopy, IconSettings } from '@tabler/icons-vue'
|
import { IconRouteAltLeft, IconMathFunction, IconNewSection, IconTrashX, IconSettings } from '@tabler/icons-vue'
|
||||||
import { v4 } from 'uuid'
|
import { v4 } from 'uuid'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -529,17 +267,15 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
Contenteditable,
|
Contenteditable,
|
||||||
IconSettings,
|
IconSettings,
|
||||||
IconShape,
|
FieldSettings,
|
||||||
PaymentSettings,
|
PaymentSettings,
|
||||||
IconNewSection,
|
IconNewSection,
|
||||||
IconInfoCircle,
|
|
||||||
FormulaModal,
|
FormulaModal,
|
||||||
DescriptionModal,
|
DescriptionModal,
|
||||||
ConditionsModal,
|
ConditionsModal,
|
||||||
IconRouteAltLeft,
|
IconRouteAltLeft,
|
||||||
IconTrashX,
|
IconTrashX,
|
||||||
IconMathFunction,
|
IconMathFunction,
|
||||||
IconCopy,
|
|
||||||
FieldType
|
FieldType
|
||||||
},
|
},
|
||||||
inject: ['template', 'save', 'backgroundColor', 'selectedAreaRef', 't'],
|
inject: ['template', 'save', 'backgroundColor', 'selectedAreaRef', 't'],
|
||||||
@@ -590,29 +326,6 @@ export default {
|
|||||||
modalContainerEl () {
|
modalContainerEl () {
|
||||||
return this.$el.getRootNode().querySelector('#docuseal_modal_container')
|
return this.$el.getRootNode().querySelector('#docuseal_modal_container')
|
||||||
},
|
},
|
||||||
dateFormats () {
|
|
||||||
const formats = [
|
|
||||||
'MM/DD/YYYY',
|
|
||||||
'DD/MM/YYYY',
|
|
||||||
'YYYY-MM-DD',
|
|
||||||
'DD-MM-YYYY',
|
|
||||||
'DD.MM.YYYY',
|
|
||||||
'MMM D, YYYY',
|
|
||||||
'MMMM D, YYYY',
|
|
||||||
'D MMM YYYY',
|
|
||||||
'D MMMM YYYY'
|
|
||||||
]
|
|
||||||
|
|
||||||
if (Intl.DateTimeFormat().resolvedOptions().timeZone?.includes('Seoul') || navigator.language?.startsWith('ko')) {
|
|
||||||
formats.push('YYYY년 MM월 DD일')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.field.preferences?.format && !formats.includes(this.field.preferences.format)) {
|
|
||||||
formats.unshift(this.field.preferences.format)
|
|
||||||
}
|
|
||||||
|
|
||||||
return formats
|
|
||||||
},
|
|
||||||
defaultName () {
|
defaultName () {
|
||||||
return this.buildDefaultName(this.field, this.template.fields)
|
return this.buildDefaultName(this.field, this.template.fields)
|
||||||
},
|
},
|
||||||
@@ -647,54 +360,6 @@ export default {
|
|||||||
return `${this.fieldNames[field.type]} ${suffix} ${typeIndex + 1}`
|
return `${this.fieldNames[field.type]} ${suffix} ${typeIndex + 1}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatDate (date, format) {
|
|
||||||
const monthFormats = {
|
|
||||||
M: 'numeric',
|
|
||||||
MM: '2-digit',
|
|
||||||
MMM: 'short',
|
|
||||||
MMMM: 'long'
|
|
||||||
}
|
|
||||||
|
|
||||||
const dayFormats = {
|
|
||||||
D: 'numeric',
|
|
||||||
DD: '2-digit'
|
|
||||||
}
|
|
||||||
|
|
||||||
const yearFormats = {
|
|
||||||
YYYY: 'numeric',
|
|
||||||
YY: '2-digit'
|
|
||||||
}
|
|
||||||
|
|
||||||
const parts = new Intl.DateTimeFormat([], {
|
|
||||||
day: dayFormats[format.match(/D+/)],
|
|
||||||
month: monthFormats[format.match(/M+/)],
|
|
||||||
year: yearFormats[format.match(/Y+/)]
|
|
||||||
}).formatToParts(date)
|
|
||||||
|
|
||||||
return format
|
|
||||||
.replace(/D+/, parts.find((p) => p.type === 'day').value)
|
|
||||||
.replace(/M+/, parts.find((p) => p.type === 'month').value)
|
|
||||||
.replace(/Y+/, parts.find((p) => p.type === 'year').value)
|
|
||||||
},
|
|
||||||
copyToAllPages (field) {
|
|
||||||
const areaString = JSON.stringify(field.areas[0])
|
|
||||||
|
|
||||||
this.template.documents.forEach((attachment) => {
|
|
||||||
const numberOfPages = attachment.metadata?.pdf?.number_of_pages || attachment.preview_images.length
|
|
||||||
|
|
||||||
for (let page = 0; page <= numberOfPages - 1; page++) {
|
|
||||||
if (!field.areas.find((area) => area.attachment_uuid === attachment.uuid && area.page === page)) {
|
|
||||||
field.areas.push({ ...JSON.parse(areaString), attachment_uuid: attachment.uuid, page })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.$emit('scroll-to', this.field.areas[this.field.areas.length - 1])
|
|
||||||
})
|
|
||||||
|
|
||||||
this.save()
|
|
||||||
},
|
|
||||||
onNameFocus (e) {
|
onNameFocus (e) {
|
||||||
this.isNameFocus = true
|
this.isNameFocus = true
|
||||||
|
|
||||||
@@ -770,11 +435,6 @@ export default {
|
|||||||
|
|
||||||
this.isNameFocus = false
|
this.isNameFocus = false
|
||||||
|
|
||||||
this.save()
|
|
||||||
},
|
|
||||||
removeArea (area) {
|
|
||||||
this.field.areas.splice(this.field.areas.indexOf(area), 1)
|
|
||||||
|
|
||||||
this.save()
|
this.save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,462 @@
|
|||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="field.type === 'number'"
|
||||||
|
class="py-1.5 px-1 relative"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
:placeholder="t('format')"
|
||||||
|
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
|
||||||
|
@change="[field.preferences ||= {}, field.preferences.format = $event.target.value, save()]"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="format in numberFormats"
|
||||||
|
:key="format"
|
||||||
|
:value="format"
|
||||||
|
:selected="format === field.preferences?.format || (format === 'none' && !field.preferences?.format)"
|
||||||
|
>
|
||||||
|
{{ formatNumber(123456789.567, format) }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<label
|
||||||
|
:style="{ backgroundColor }"
|
||||||
|
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||||
|
style="font-size: 8px"
|
||||||
|
>
|
||||||
|
{{ t('format') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="['number'].includes(field.type)"
|
||||||
|
class="py-1.5 px-1 relative"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
class="select select-bordered select-xs w-full max-w-xs h-7 !outline-0 font-normal bg-transparent"
|
||||||
|
@change="[field.preferences ||= {}, field.preferences.align = $event.target.value, save()]"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="value in ['left', 'right', 'center']"
|
||||||
|
:key="value"
|
||||||
|
:selected="field.preferences?.align ? value === field.preferences.align : value === 'left'"
|
||||||
|
:value="value"
|
||||||
|
>
|
||||||
|
{{ t(value) }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<label
|
||||||
|
:style="{ backgroundColor }"
|
||||||
|
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||||
|
style="font-size: 8px"
|
||||||
|
>
|
||||||
|
{{ t('align') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="['text', 'number'].includes(field.type) && !defaultField"
|
||||||
|
class="py-1.5 px-1 relative"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="field.default_value"
|
||||||
|
:placeholder="t('default_value')"
|
||||||
|
dir="auto"
|
||||||
|
:type="field.type"
|
||||||
|
class="input input-bordered input-xs w-full max-w-xs h-7 !outline-0 bg-transparent"
|
||||||
|
@blur="save"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
v-if="field.default_value"
|
||||||
|
:style="{ backgroundColor }"
|
||||||
|
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||||
|
style="font-size: 8px"
|
||||||
|
>
|
||||||
|
{{ t('default_value') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="field.type === 'date'"
|
||||||
|
class="py-1.5 px-1 relative"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
v-model="field.preferences.format"
|
||||||
|
:placeholder="t('format')"
|
||||||
|
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
|
||||||
|
@change="save"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="format in dateFormats"
|
||||||
|
:key="format"
|
||||||
|
:value="format"
|
||||||
|
>
|
||||||
|
{{ formatDate(new Date(), format) }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<label
|
||||||
|
:style="{ backgroundColor }"
|
||||||
|
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||||
|
style="font-size: 8px"
|
||||||
|
>
|
||||||
|
{{ t('format') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="field.type === 'signature'"
|
||||||
|
class="py-1.5 px-1 relative"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
:placeholder="t('format')"
|
||||||
|
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
|
||||||
|
@change="[field.preferences.format = $event.target.value, save()]"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
value="any"
|
||||||
|
:selected="!field.preferences?.format || field.preferences.format === 'any'"
|
||||||
|
>
|
||||||
|
{{ t('any') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
value="drawn"
|
||||||
|
:selected="field.preferences?.format === 'drawn'"
|
||||||
|
>
|
||||||
|
{{ t('drawn') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
value="typed"
|
||||||
|
:selected="field.preferences?.format === 'typed'"
|
||||||
|
>
|
||||||
|
{{ t('typed') }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<label
|
||||||
|
:style="{ backgroundColor }"
|
||||||
|
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||||
|
style="font-size: 8px"
|
||||||
|
>
|
||||||
|
{{ t('format') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<li
|
||||||
|
v-if="withRequired && field.type != 'phone' && field.type != 'stamp'"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<label class="cursor-pointer py-1.5">
|
||||||
|
<input
|
||||||
|
v-model="field.required"
|
||||||
|
type="checkbox"
|
||||||
|
:disabled="!editable || defaultField"
|
||||||
|
class="toggle toggle-xs"
|
||||||
|
@update:model-value="save"
|
||||||
|
>
|
||||||
|
<span class="label-text">{{ t('required') }}</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
v-if="field.type == 'stamp'"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<label class="cursor-pointer py-1.5">
|
||||||
|
<input
|
||||||
|
:checked="field.preferences?.with_logo != false"
|
||||||
|
type="checkbox"
|
||||||
|
class="toggle toggle-xs"
|
||||||
|
@change="[field.preferences ||= {}, field.preferences.with_logo = field.preferences.with_logo == false, save()]"
|
||||||
|
>
|
||||||
|
<span class="label-text">{{ t('with_logo') }}</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
v-if="field.type == 'checkbox'"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<label class="cursor-pointer py-1.5">
|
||||||
|
<input
|
||||||
|
v-model="field.default_value"
|
||||||
|
type="checkbox"
|
||||||
|
class="toggle toggle-xs"
|
||||||
|
@update:model-value="[field.default_value = $event, field.readonly = $event, save()]"
|
||||||
|
>
|
||||||
|
<span class="label-text">{{ t('checked') }}</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
v-if="field.type == 'date'"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<label class="cursor-pointer py-1.5">
|
||||||
|
<input
|
||||||
|
v-model="field.readonly"
|
||||||
|
type="checkbox"
|
||||||
|
class="toggle toggle-xs"
|
||||||
|
@update:model-value="[field.default_value = $event ? '{{date}}' : null, field.readonly = $event, save()]"
|
||||||
|
>
|
||||||
|
<span class="label-text">{{ t('set_signing_date') }}</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
v-if="['text', 'number'].includes(field.type) && !defaultField"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<label class="cursor-pointer py-1.5">
|
||||||
|
<input
|
||||||
|
v-model="field.readonly"
|
||||||
|
type="checkbox"
|
||||||
|
class="toggle toggle-xs"
|
||||||
|
@update:model-value="save"
|
||||||
|
>
|
||||||
|
<span class="label-text">{{ t('read_only') }}</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<hr
|
||||||
|
v-if="field.type != 'stamp'"
|
||||||
|
class="pb-0.5 mt-0.5"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
v-if="field.type != 'stamp'"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
class="label-text cursor-pointer text-center w-full flex items-center"
|
||||||
|
@click="$emit('click-description')"
|
||||||
|
>
|
||||||
|
<IconInfoCircle
|
||||||
|
width="18"
|
||||||
|
/>
|
||||||
|
<span class="text-sm">
|
||||||
|
{{ t('description') }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li
|
||||||
|
v-if="field.type != 'stamp'"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
class="label-text cursor-pointer text-center w-full flex items-center"
|
||||||
|
@click="$emit('click-condition')"
|
||||||
|
>
|
||||||
|
<IconRouteAltLeft
|
||||||
|
width="18"
|
||||||
|
/>
|
||||||
|
<span class="text-sm">
|
||||||
|
{{ t('condition') }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li v-if="field.type == 'number'">
|
||||||
|
<label
|
||||||
|
class="label-text cursor-pointer text-center w-full flex items-center"
|
||||||
|
@click="$emit('click-formula')"
|
||||||
|
>
|
||||||
|
<IconMathFunction
|
||||||
|
width="18"
|
||||||
|
/>
|
||||||
|
<span class="text-sm">
|
||||||
|
{{ t('formula') }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<hr class="pb-0.5 mt-0.5">
|
||||||
|
<template v-if="withAreas">
|
||||||
|
<li
|
||||||
|
v-for="(area, index) in sortedAreas"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
class="text-sm py-1 px-2"
|
||||||
|
@click.prevent="$emit('scroll-to', area)"
|
||||||
|
>
|
||||||
|
<IconShape
|
||||||
|
:width="20"
|
||||||
|
:stroke-width="1.6"
|
||||||
|
/>
|
||||||
|
{{ t('page') }}
|
||||||
|
<template v-if="template.schema.length > 1">{{ template.schema.findIndex((item) => item.attachment_uuid === area.attachment_uuid) + 1 }}-</template>{{ area.page + 1 }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li v-if="!field.areas?.length || !['radio', 'multiple'].includes(field.type)">
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
class="text-sm py-1 px-2"
|
||||||
|
@click.prevent="$emit('set-draw', { field })"
|
||||||
|
>
|
||||||
|
<IconNewSection
|
||||||
|
:width="20"
|
||||||
|
:stroke-width="1.6"
|
||||||
|
/>
|
||||||
|
{{ t('draw_new_area') }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
<li v-if="field.areas?.length === 1 && ['date', 'signature', 'initials', 'text', 'cells'].includes(field.type)">
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
class="text-sm py-1 px-2"
|
||||||
|
@click.prevent="copyToAllPages(field)"
|
||||||
|
>
|
||||||
|
<IconCopy
|
||||||
|
:width="20"
|
||||||
|
:stroke-width="1.6"
|
||||||
|
/>
|
||||||
|
{{ t('copy_to_all_pages') }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { IconRouteAltLeft, IconShape, IconMathFunction, IconNewSection, IconInfoCircle, IconCopy } from '@tabler/icons-vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'FieldSettings',
|
||||||
|
components: {
|
||||||
|
IconShape,
|
||||||
|
IconInfoCircle,
|
||||||
|
IconMathFunction,
|
||||||
|
IconRouteAltLeft,
|
||||||
|
IconCopy,
|
||||||
|
IconNewSection
|
||||||
|
},
|
||||||
|
inject: ['template', 'save', 't'],
|
||||||
|
props: {
|
||||||
|
field: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
backgroundColor: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
defaultField: {
|
||||||
|
type: Object,
|
||||||
|
required: false,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
|
withRequired: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
withAreas: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
editable: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ['set-draw', 'scroll-to', 'click-formula', 'click-description', 'click-condition'],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
schemaAttachmentsIndexes () {
|
||||||
|
return (this.template.schema || []).reduce((acc, item, index) => {
|
||||||
|
acc[item.attachment_uuid] = index
|
||||||
|
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
},
|
||||||
|
numberFormats () {
|
||||||
|
return [
|
||||||
|
'none',
|
||||||
|
'comma',
|
||||||
|
'dot',
|
||||||
|
'space'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
dateFormats () {
|
||||||
|
const formats = [
|
||||||
|
'MM/DD/YYYY',
|
||||||
|
'DD/MM/YYYY',
|
||||||
|
'YYYY-MM-DD',
|
||||||
|
'DD-MM-YYYY',
|
||||||
|
'DD.MM.YYYY',
|
||||||
|
'MMM D, YYYY',
|
||||||
|
'MMMM D, YYYY',
|
||||||
|
'D MMM YYYY',
|
||||||
|
'D MMMM YYYY'
|
||||||
|
]
|
||||||
|
|
||||||
|
if (Intl.DateTimeFormat().resolvedOptions().timeZone?.includes('Seoul') || navigator.language?.startsWith('ko')) {
|
||||||
|
formats.push('YYYY년 MM월 DD일')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.field.preferences?.format && !formats.includes(this.field.preferences.format)) {
|
||||||
|
formats.unshift(this.field.preferences.format)
|
||||||
|
}
|
||||||
|
|
||||||
|
return formats
|
||||||
|
},
|
||||||
|
sortedAreas () {
|
||||||
|
return (this.field.areas || []).sort((a, b) => {
|
||||||
|
return this.schemaAttachmentsIndexes[a.attachment_uuid] - this.schemaAttachmentsIndexes[b.attachment_uuid]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
copyToAllPages (field) {
|
||||||
|
const areaString = JSON.stringify(field.areas[0])
|
||||||
|
|
||||||
|
this.template.documents.forEach((attachment) => {
|
||||||
|
const numberOfPages = attachment.metadata?.pdf?.number_of_pages || attachment.preview_images.length
|
||||||
|
|
||||||
|
for (let page = 0; page <= numberOfPages - 1; page++) {
|
||||||
|
if (!field.areas.find((area) => area.attachment_uuid === attachment.uuid && area.page === page)) {
|
||||||
|
field.areas.push({ ...JSON.parse(areaString), attachment_uuid: attachment.uuid, page })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$emit('scroll-to', this.field.areas[this.field.areas.length - 1])
|
||||||
|
|
||||||
|
this.save()
|
||||||
|
},
|
||||||
|
formatNumber (number, format) {
|
||||||
|
if (format === 'comma') {
|
||||||
|
return new Intl.NumberFormat('en-US').format(number)
|
||||||
|
} else if (format === 'dot') {
|
||||||
|
return new Intl.NumberFormat('de-DE').format(number)
|
||||||
|
} else if (format === 'space') {
|
||||||
|
return new Intl.NumberFormat('fr-FR').format(number)
|
||||||
|
} else {
|
||||||
|
return number
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatDate (date, format) {
|
||||||
|
const monthFormats = {
|
||||||
|
M: 'numeric',
|
||||||
|
MM: '2-digit',
|
||||||
|
MMM: 'short',
|
||||||
|
MMMM: 'long'
|
||||||
|
}
|
||||||
|
|
||||||
|
const dayFormats = {
|
||||||
|
D: 'numeric',
|
||||||
|
DD: '2-digit'
|
||||||
|
}
|
||||||
|
|
||||||
|
const yearFormats = {
|
||||||
|
YYYY: 'numeric',
|
||||||
|
YY: '2-digit'
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts = new Intl.DateTimeFormat([], {
|
||||||
|
day: dayFormats[format.match(/D+/)],
|
||||||
|
month: monthFormats[format.match(/M+/)],
|
||||||
|
year: yearFormats[format.match(/Y+/)]
|
||||||
|
}).formatToParts(date)
|
||||||
|
|
||||||
|
return format
|
||||||
|
.replace(/D+/, parts.find((p) => p.type === 'day').value)
|
||||||
|
.replace(/M+/, parts.find((p) => p.type === 'month').value)
|
||||||
|
.replace(/Y+/, parts.find((p) => p.type === 'year').value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
@set-draw="$emit('set-draw', $event)"
|
@set-draw="$emit('set-draw', $event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="submitterDefaultFields.length">
|
<div v-if="submitterDefaultFields.length && editable">
|
||||||
<hr class="mb-2">
|
<hr class="mb-2">
|
||||||
<template v-if="isShowFieldSearch">
|
<template v-if="isShowFieldSearch">
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
@start-drag="isMove = true"
|
@start-drag="isMove = true"
|
||||||
@stop-drag="isMove = false"
|
@stop-drag="isMove = false"
|
||||||
@remove="$emit('remove-area', item.area)"
|
@remove="$emit('remove-area', item.area)"
|
||||||
|
@scroll-to="$emit('scroll-to', $event)"
|
||||||
/>
|
/>
|
||||||
<FieldArea
|
<FieldArea
|
||||||
v-if="newArea"
|
v-if="newArea"
|
||||||
@@ -116,7 +117,7 @@ export default {
|
|||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['draw', 'drop-field', 'remove-area'],
|
emits: ['draw', 'drop-field', 'remove-area', 'scroll-to'],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
areaRefs: [],
|
areaRefs: [],
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ class SendSubmissionArchivedWebhookRequestJob < ApplicationJob
|
|||||||
end
|
end
|
||||||
|
|
||||||
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||||
(!Docuseal.multitenant? || submitter.account.account_configs.exists?(key: :plan))
|
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||||
SendSubmissionArchivedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
SendSubmissionArchivedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||||
.perform_later(submitter, {
|
.perform_later(submission, {
|
||||||
attempt: attempt + 1,
|
attempt: attempt + 1,
|
||||||
last_status: resp&.status.to_i
|
last_status: resp&.status.to_i
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SendTemplateCreatedWebhookRequestJob < ApplicationJob
|
||||||
|
USER_AGENT = 'DocuSeal.co Webhook'
|
||||||
|
|
||||||
|
MAX_ATTEMPTS = 10
|
||||||
|
|
||||||
|
def perform(template, params = {})
|
||||||
|
attempt = params[:attempt].to_i
|
||||||
|
url = Accounts.load_webhook_url(template.account)
|
||||||
|
|
||||||
|
return if url.blank?
|
||||||
|
|
||||||
|
preferences = Accounts.load_webhook_preferences(template.account)
|
||||||
|
|
||||||
|
return if preferences['template.created'].blank?
|
||||||
|
|
||||||
|
resp = begin
|
||||||
|
Faraday.post(url,
|
||||||
|
{
|
||||||
|
event_type: 'template.created',
|
||||||
|
timestamp: Time.current,
|
||||||
|
data: Templates::SerializeForApi.call(template)
|
||||||
|
}.to_json,
|
||||||
|
'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? || template.account.account_configs.exists?(key: :plan))
|
||||||
|
SendTemplateCreatedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||||
|
.perform_later(template, {
|
||||||
|
attempt: attempt + 1,
|
||||||
|
last_status: resp&.status.to_i
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SendTemplateUpdatedWebhookRequestJob < ApplicationJob
|
||||||
|
USER_AGENT = 'DocuSeal.co Webhook'
|
||||||
|
|
||||||
|
MAX_ATTEMPTS = 10
|
||||||
|
|
||||||
|
def perform(template, params = {})
|
||||||
|
attempt = params[:attempt].to_i
|
||||||
|
url = Accounts.load_webhook_url(template.account)
|
||||||
|
|
||||||
|
return if url.blank?
|
||||||
|
|
||||||
|
preferences = Accounts.load_webhook_preferences(template.account)
|
||||||
|
|
||||||
|
return if preferences['template.updated'].blank?
|
||||||
|
|
||||||
|
resp = begin
|
||||||
|
Faraday.post(url,
|
||||||
|
{
|
||||||
|
event_type: 'template.updated',
|
||||||
|
timestamp: Time.current,
|
||||||
|
data: Templates::SerializeForApi.call(template)
|
||||||
|
}.to_json,
|
||||||
|
'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? || template.account.account_configs.exists?(key: :plan))
|
||||||
|
SendTemplateUpdatedWebhookRequestJob.set(wait: (2**attempt).minutes)
|
||||||
|
.perform_later(template, {
|
||||||
|
attempt: attempt + 1,
|
||||||
|
last_status: resp&.status.to_i
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -2,23 +2,24 @@
|
|||||||
<%= f.hidden_field :key %>
|
<%= f.hidden_field :key %>
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<% record = Struct.new(:first_duration, :second_duration, :third_duration).new(*(f.object.value || {}).values_at('first_duration', 'second_duration', 'third_duration')) %>
|
<% record = Struct.new(:first_duration, :second_duration, :third_duration).new(*(f.object.value || {}).values_at('first_duration', 'second_duration', 'third_duration')) %>
|
||||||
|
<% durations = Docuseal.multitenant? ? AccountConfigs::REMINDER_DURATIONS.except('one_hour', 'two_hours').invert : AccountConfigs::REMINDER_DURATIONS.invert %>
|
||||||
<div class="flex flex-col md:flex-row gap-4">
|
<div class="flex flex-col md:flex-row gap-4">
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<%= f.fields_for :value, record do |ff| %>
|
<%= f.fields_for :value, record do |ff| %>
|
||||||
<%= ff.label :first_duration, 'First reminder in', class: 'label' %>
|
<%= ff.label :first_duration, 'First reminder in', class: 'label' %>
|
||||||
<%= ff.select :first_duration, AccountConfigs::REMINDER_DURATIONS.invert, { include_blank: 'None' }, class: 'base-select' %>
|
<%= ff.select :first_duration, durations, { include_blank: 'None' }, class: 'base-select' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<%= f.fields_for :value, record do |ff| %>
|
<%= f.fields_for :value, record do |ff| %>
|
||||||
<%= ff.label :second_duration, 'Second reminder in', class: 'label' %>
|
<%= ff.label :second_duration, 'Second reminder in', class: 'label' %>
|
||||||
<%= ff.select :second_duration, AccountConfigs::REMINDER_DURATIONS.invert, { include_blank: 'None' }, class: 'base-select' %>
|
<%= ff.select :second_duration, durations, { include_blank: 'None' }, class: 'base-select' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<%= f.fields_for :value, record do |ff| %>
|
<%= f.fields_for :value, record do |ff| %>
|
||||||
<%= ff.label :third_duration, 'Third reminder in', class: 'label' %>
|
<%= ff.label :third_duration, 'Third reminder in', class: 'label' %>
|
||||||
<%= ff.select :third_duration, AccountConfigs::REMINDER_DURATIONS.invert, { include_blank: 'None' }, class: 'base-select' %>
|
<%= ff.select :third_duration, durations, { include_blank: 'None' }, class: 'base-select' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
<% value = Time.current.in_time_zone(local_assigns[:timezone]).to_date.to_s if value == '{{date}}' %>
|
<% value = Time.current.in_time_zone(local_assigns[:timezone]).to_date.to_s if value == '{{date}}' %>
|
||||||
<%= TimeUtils.format_date_string(value, field.dig('preferences', 'format'), local_assigns[:locale]) %>
|
<%= TimeUtils.format_date_string(value, field.dig('preferences', 'format'), local_assigns[:locale]) %>
|
||||||
</div>
|
</div>
|
||||||
|
<% elsif field['type'] == 'number' %>
|
||||||
|
<autosize-field></autosize-field>
|
||||||
|
<div class="flex items-center px-0.5 whitespace-nowrap">
|
||||||
|
<%= NumberUtils.format_number(value, field.dig('preferences', 'format')) %>
|
||||||
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<autosize-field></autosize-field>
|
<autosize-field></autosize-field>
|
||||||
<div class="flex items-center px-0.5 whitespace-pre-wrap"><%= Array.wrap(value).join(', ') %></div>
|
<div class="flex items-center px-0.5 whitespace-pre-wrap"><%= Array.wrap(value).join(', ') %></div>
|
||||||
|
|||||||
@@ -1,6 +1,18 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module HexaPDF
|
module HexaPDF
|
||||||
|
module Encryption
|
||||||
|
class SecurityHandler
|
||||||
|
def encrypt_string(str, obj)
|
||||||
|
return str.dup if str.empty? || obj == document.trailer[:Encrypt] || obj.type == :XRef ||
|
||||||
|
(obj.type == :Sig && obj[:Contents].equal?(str))
|
||||||
|
|
||||||
|
key = object_key(obj.oid, obj.gen, string_algorithm)
|
||||||
|
string_algorithm.encrypt(key, str).dup
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
module Type
|
module Type
|
||||||
# fix NoMethodError: undefined method `field_value' for #<HexaPDF::Type::AcroForm::Field
|
# fix NoMethodError: undefined method `field_value' for #<HexaPDF::Type::AcroForm::Field
|
||||||
module AcroForm
|
module AcroForm
|
||||||
@@ -8,6 +20,14 @@ module HexaPDF
|
|||||||
def field_value
|
def field_value
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def terminal_field?
|
||||||
|
kids = self[:Kids]
|
||||||
|
|
||||||
|
# rubocop:disable Rails/Blank
|
||||||
|
kids.nil? || kids.empty? || kids.none? { |kid| kid&.key?(:T) }
|
||||||
|
# rubocop:enable Rails/Blank
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -90,7 +90,11 @@ module Accounts
|
|||||||
def load_signing_pkcs(account)
|
def load_signing_pkcs(account)
|
||||||
cert_data =
|
cert_data =
|
||||||
if Docuseal.multitenant?
|
if Docuseal.multitenant?
|
||||||
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || Docuseal::CERTS
|
data = EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value
|
||||||
|
|
||||||
|
return Docuseal.default_pkcs if data.blank?
|
||||||
|
|
||||||
|
data
|
||||||
else
|
else
|
||||||
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value ||
|
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value ||
|
||||||
EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY).value
|
EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY).value
|
||||||
|
|||||||
@@ -60,6 +60,17 @@ module Docuseal
|
|||||||
ENV['ACTIVE_STORAGE_PUBLIC'] == 'true'
|
ENV['ACTIVE_STORAGE_PUBLIC'] == 'true'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def default_pkcs
|
||||||
|
@default_pkcs ||= GenerateCertificate.load_pkcs(Docuseal::CERTS)
|
||||||
|
end
|
||||||
|
|
||||||
|
def trusted_certs
|
||||||
|
@trusted_certs ||=
|
||||||
|
ENV['TRUSTED_CERTS'].to_s.gsub('\\n', "\n").split("\n\n").map do |base64|
|
||||||
|
OpenSSL::X509::Certificate.new(base64)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def default_url_options
|
def default_url_options
|
||||||
return DEFAULT_URL_OPTIONS if multitenant?
|
return DEFAULT_URL_OPTIONS if multitenant?
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
module GenerateCertificate
|
module GenerateCertificate
|
||||||
SIZE = 2**11
|
SIZE = 2**11
|
||||||
|
|
||||||
|
Pkcs12Struct = Struct.new(:certificate, :ca_certs, keyword_init: true)
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(name = Docuseal.product_name)
|
def call(name = Docuseal.product_name)
|
||||||
@@ -89,10 +91,12 @@ module GenerateCertificate
|
|||||||
|
|
||||||
def load_pkcs(cert_data)
|
def load_pkcs(cert_data)
|
||||||
cert = OpenSSL::X509::Certificate.new(cert_data['cert'])
|
cert = OpenSSL::X509::Certificate.new(cert_data['cert'])
|
||||||
key = OpenSSL::PKey::RSA.new(cert_data['key'])
|
key = OpenSSL::PKey::RSA.new(cert_data['key']) if cert_data['key'].present?
|
||||||
sub_ca = OpenSSL::X509::Certificate.new(cert_data['sub_ca'])
|
sub_ca = OpenSSL::X509::Certificate.new(cert_data['sub_ca'])
|
||||||
root_ca = OpenSSL::X509::Certificate.new(cert_data['root_ca'])
|
root_ca = OpenSSL::X509::Certificate.new(cert_data['root_ca'])
|
||||||
|
|
||||||
|
return Pkcs12Struct.new(certificate: cert, ca_certs: [sub_ca, root_ca]) unless key
|
||||||
|
|
||||||
OpenSSL::PKCS12.create(
|
OpenSSL::PKCS12.create(
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module NumberUtils
|
||||||
|
FORMAT_LOCALES = {
|
||||||
|
'dot' => 'de',
|
||||||
|
'space' => 'fr',
|
||||||
|
'comma' => 'en'
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def format_number(number, format)
|
||||||
|
locale = FORMAT_LOCALES[format]
|
||||||
|
|
||||||
|
if locale
|
||||||
|
ApplicationController.helpers.number_with_delimiter(number, locale:)
|
||||||
|
else
|
||||||
|
number
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -150,15 +150,21 @@ module Submissions
|
|||||||
def build_submitter(submission:, attrs:, uuid:, is_order_sent:, mark_as_sent:, user:, preferences:)
|
def build_submitter(submission:, attrs:, uuid:, is_order_sent:, mark_as_sent:, user:, preferences:)
|
||||||
email = Submissions.normalize_email(attrs[:email])
|
email = Submissions.normalize_email(attrs[:email])
|
||||||
submitter_preferences = Submitters.normalize_preferences(submission.account, user, attrs)
|
submitter_preferences = Submitters.normalize_preferences(submission.account, user, attrs)
|
||||||
|
values = attrs[:values] || {}
|
||||||
|
|
||||||
|
phone_field_uuid =
|
||||||
|
(submission.template_fields || submission.template.fields).find do |f|
|
||||||
|
values[f['uuid']].present? && f['type'] == 'phone'
|
||||||
|
end&.dig('uuid')
|
||||||
|
|
||||||
submission.submitters.new(
|
submission.submitters.new(
|
||||||
email:,
|
email:,
|
||||||
phone: attrs[:phone].to_s.gsub(/[^0-9+]/, ''),
|
phone: (attrs[:phone] || values[phone_field_uuid]).to_s.gsub(/[^0-9+]/, ''),
|
||||||
name: attrs[:name],
|
name: attrs[:name],
|
||||||
external_id: attrs[:external_id].presence || attrs[:application_key],
|
external_id: attrs[:external_id].presence || attrs[:application_key],
|
||||||
completed_at: attrs[:completed].present? ? Time.current : nil,
|
completed_at: attrs[:completed].present? ? Time.current : nil,
|
||||||
sent_at: mark_as_sent && email.present? && is_order_sent ? Time.current : nil,
|
sent_at: mark_as_sent && email.present? && is_order_sent ? Time.current : nil,
|
||||||
values: attrs[:values] || {},
|
values: values.except(phone_field_uuid),
|
||||||
metadata: attrs[:metadata] || {},
|
metadata: attrs[:metadata] || {},
|
||||||
preferences: preferences.merge(submitter_preferences)
|
preferences: preferences.merge(submitter_preferences)
|
||||||
.merge({ default_values: attrs[:values] }.compact_blank)
|
.merge({ default_values: attrs[:values] }.compact_blank)
|
||||||
|
|||||||
@@ -7,15 +7,10 @@ module Submissions
|
|||||||
FONT_PATH = '/fonts/GoNotoKurrent-Regular.ttf'
|
FONT_PATH = '/fonts/GoNotoKurrent-Regular.ttf'
|
||||||
FONT_BOLD_PATH = '/fonts/GoNotoKurrent-Bold.ttf'
|
FONT_BOLD_PATH = '/fonts/GoNotoKurrent-Bold.ttf'
|
||||||
FONT_NAME = if File.exist?(FONT_PATH)
|
FONT_NAME = if File.exist?(FONT_PATH)
|
||||||
FONT_PATH
|
'GoNotoKurrent'
|
||||||
else
|
else
|
||||||
'Helvetica'
|
'Helvetica'
|
||||||
end
|
end
|
||||||
FONT_BOLD_NAME = if File.exist?(FONT_BOLD_PATH)
|
|
||||||
FONT_BOLD_PATH
|
|
||||||
else
|
|
||||||
'Helvetica'
|
|
||||||
end
|
|
||||||
|
|
||||||
SIGN_REASON = 'Signed with DocuSeal.co'
|
SIGN_REASON = 'Signed with DocuSeal.co'
|
||||||
VERIFIED_TEXT = 'Verified'
|
VERIFIED_TEXT = 'Verified'
|
||||||
@@ -48,7 +43,19 @@ module Submissions
|
|||||||
end
|
end
|
||||||
|
|
||||||
composer = HexaPDF::Composer.new(skip_page_creation: true)
|
composer = HexaPDF::Composer.new(skip_page_creation: true)
|
||||||
composer.document.fonts.add(FONT_BOLD_NAME, variant: :bold)
|
composer.document.task(:pdfa) if FONT_NAME == 'GoNotoKurrent'
|
||||||
|
|
||||||
|
composer.document.config['font.map'] = {
|
||||||
|
'Helvetica' => {
|
||||||
|
none: FONT_PATH,
|
||||||
|
bold: FONT_BOLD_PATH
|
||||||
|
},
|
||||||
|
FONT_NAME => {
|
||||||
|
none: FONT_PATH,
|
||||||
|
bold: FONT_BOLD_PATH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
composer.document.config['font.on_missing_glyph'] =
|
composer.document.config['font.on_missing_glyph'] =
|
||||||
Submissions::GenerateResultAttachments.method(:on_missing_glyph).to_proc
|
Submissions::GenerateResultAttachments.method(:on_missing_glyph).to_proc
|
||||||
|
|
||||||
@@ -119,13 +126,13 @@ module Submissions
|
|||||||
),
|
),
|
||||||
composer.document.layout.formatted_text_box(
|
composer.document.layout.formatted_text_box(
|
||||||
[
|
[
|
||||||
{ text: "Original SHA256:\n", font: [FONT_BOLD_NAME, { variant: :bold }] },
|
{ text: "Original SHA256:\n", font: [FONT_NAME, { variant: :bold }] },
|
||||||
original_documents.map { |d| d.metadata['sha256'] || d.checksum }.join("\n"),
|
original_documents.map { |d| d.metadata['sha256'] || d.checksum }.join("\n"),
|
||||||
"\n",
|
"\n",
|
||||||
{ text: "Result SHA256:\n", font: [FONT_BOLD_NAME, { variant: :bold }] },
|
{ text: "Result SHA256:\n", font: [FONT_NAME, { variant: :bold }] },
|
||||||
document.metadata['sha256'] || document.checksum,
|
document.metadata['sha256'] || document.checksum,
|
||||||
"\n",
|
"\n",
|
||||||
{ text: 'Generated at: ', font: [FONT_BOLD_NAME, { variant: :bold }] },
|
{ text: 'Generated at: ', font: [FONT_NAME, { variant: :bold }] },
|
||||||
"#{I18n.l(document.created_at.in_time_zone(account.timezone), format: :long, locale: account.locale)} " \
|
"#{I18n.l(document.created_at.in_time_zone(account.timezone), format: :long, locale: account.locale)} " \
|
||||||
"#{TimeUtils.timezone_abbr(account.timezone, document.created_at)}"
|
"#{TimeUtils.timezone_abbr(account.timezone, document.created_at)}"
|
||||||
], line_spacing: 1.3
|
], line_spacing: 1.3
|
||||||
@@ -162,7 +169,7 @@ module Submissions
|
|||||||
composer.document.layout.formatted_text_box(
|
composer.document.layout.formatted_text_box(
|
||||||
[
|
[
|
||||||
submission.template_submitters.size > 1 && { text: "#{item['name']}\n" },
|
submission.template_submitters.size > 1 && { text: "#{item['name']}\n" },
|
||||||
submitter.email && { text: "#{submitter.email}\n", font: [FONT_BOLD_NAME, { variant: :bold }] },
|
submitter.email && { text: "#{submitter.email}\n", font: [FONT_NAME, { variant: :bold }] },
|
||||||
submitter.name && { text: "#{TextUtils.maybe_rtl_reverse(submitter.name)}\n" },
|
submitter.name && { text: "#{TextUtils.maybe_rtl_reverse(submitter.name)}\n" },
|
||||||
submitter.phone && { text: "#{submitter.phone}\n" }
|
submitter.phone && { text: "#{submitter.phone}\n" }
|
||||||
].compact_blank, line_spacing: 1.3, padding: [0, 20, 0, 0]
|
].compact_blank, line_spacing: 1.3, padding: [0, 20, 0, 0]
|
||||||
@@ -254,6 +261,8 @@ module Submissions
|
|||||||
value = TimeUtils.format_date_string(value, field.dig('preferences', 'format'), account.locale)
|
value = TimeUtils.format_date_string(value, field.dig('preferences', 'format'), account.locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
value = NumberUtils.format_number(value, field.dig('preferences', 'format')) if field['type'] == 'number'
|
||||||
|
|
||||||
value = value.join(', ') if value.is_a?(Array)
|
value = value.join(', ') if value.is_a?(Array)
|
||||||
|
|
||||||
composer.formatted_text_box([{ text: TextUtils.maybe_rtl_reverse(value.to_s.presence || 'n/a') }],
|
composer.formatted_text_box([{ text: TextUtils.maybe_rtl_reverse(value.to_s.presence || 'n/a') }],
|
||||||
@@ -276,7 +285,7 @@ module Submissions
|
|||||||
composer.document.layout.formatted_text_box(
|
composer.document.layout.formatted_text_box(
|
||||||
[
|
[
|
||||||
{ text: SubmissionEvents::EVENT_NAMES[event.event_type.to_sym],
|
{ text: SubmissionEvents::EVENT_NAMES[event.event_type.to_sym],
|
||||||
font: [FONT_BOLD_NAME, { variant: :bold }] },
|
font: [FONT_NAME, { variant: :bold }] },
|
||||||
event.event_type.include?('send_') ? ' to ' : ' by ',
|
event.event_type.include?('send_') ? ' to ' : ' by ',
|
||||||
if event.event_type.include?('sms') || event.event_type.include?('phone')
|
if event.event_type.include?('sms') || event.event_type.include?('phone')
|
||||||
event.data['phone'] || submitter.phone
|
event.data['phone'] || submitter.phone
|
||||||
@@ -296,17 +305,9 @@ module Submissions
|
|||||||
|
|
||||||
sign_params = {
|
sign_params = {
|
||||||
reason: SIGN_REASON,
|
reason: SIGN_REASON,
|
||||||
certificate: pkcs.certificate,
|
**Submissions::GenerateResultAttachments.build_signing_params(pkcs, tsa_url)
|
||||||
doc_mdp_permissions: :no_changes,
|
|
||||||
key: pkcs.key,
|
|
||||||
certificate_chain: pkcs.ca_certs || []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tsa_url
|
|
||||||
sign_params[:timestamp_handler] = Submissions::TimestampHandler.new(tsa_url:)
|
|
||||||
sign_params[:signature_size] = 10_000
|
|
||||||
end
|
|
||||||
|
|
||||||
composer.document.sign(io, **sign_params)
|
composer.document.sign(io, **sign_params)
|
||||||
|
|
||||||
ActiveStorage::Attachment.create!(
|
ActiveStorage::Attachment.create!(
|
||||||
@@ -324,7 +325,7 @@ module Submissions
|
|||||||
column.formatted_text([{ text: 'DocuSeal',
|
column.formatted_text([{ text: 'DocuSeal',
|
||||||
link: Docuseal::PRODUCT_URL }],
|
link: Docuseal::PRODUCT_URL }],
|
||||||
font_size: 20,
|
font_size: 20,
|
||||||
font: [FONT_BOLD_NAME, { variant: :bold }],
|
font: [FONT_NAME, { variant: :bold }],
|
||||||
width: 100,
|
width: 100,
|
||||||
padding: [5, 0, 0, 8],
|
padding: [5, 0, 0, 8],
|
||||||
position: :float, text_align: :left)
|
position: :float, text_align: :left)
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ module Submissions
|
|||||||
value = TimeUtils.format_date_string(value, field.dig('preferences', 'format'), account.locale)
|
value = TimeUtils.format_date_string(value, field.dig('preferences', 'format'), account.locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
value = NumberUtils.format_number(value, field.dig('preferences', 'format')) if field['type'] == 'number'
|
||||||
|
|
||||||
value = TextUtils.maybe_rtl_reverse(Array.wrap(value).join(', '))
|
value = TextUtils.maybe_rtl_reverse(Array.wrap(value).join(', '))
|
||||||
|
|
||||||
text = HexaPDF::Layout::TextFragment.create(value, font: pdf.fonts.add(FONT_NAME),
|
text = HexaPDF::Layout::TextFragment.create(value, font: pdf.fonts.add(FONT_NAME),
|
||||||
@@ -304,16 +306,9 @@ module Submissions
|
|||||||
if sign_reason
|
if sign_reason
|
||||||
sign_params = {
|
sign_params = {
|
||||||
reason: sign_reason,
|
reason: sign_reason,
|
||||||
certificate: pkcs.certificate,
|
**build_signing_params(pkcs, tsa_url)
|
||||||
key: pkcs.key,
|
|
||||||
certificate_chain: pkcs.ca_certs || []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tsa_url
|
|
||||||
sign_params[:timestamp_handler] = Submissions::TimestampHandler.new(tsa_url:)
|
|
||||||
sign_params[:signature_size] = 10_000
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
pdf.sign(io, write_options: { validate: false }, **sign_params)
|
pdf.sign(io, write_options: { validate: false }, **sign_params)
|
||||||
rescue HexaPDF::MalformedPDFError => e
|
rescue HexaPDF::MalformedPDFError => e
|
||||||
@@ -342,6 +337,21 @@ module Submissions
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_signing_params(pkcs, tsa_url)
|
||||||
|
params = {
|
||||||
|
certificate: pkcs.certificate,
|
||||||
|
key: pkcs.key,
|
||||||
|
certificate_chain: pkcs.ca_certs || []
|
||||||
|
}
|
||||||
|
|
||||||
|
if tsa_url
|
||||||
|
params[:timestamp_handler] = Submissions::TimestampHandler.new(tsa_url:)
|
||||||
|
params[:signature_size] = 20_000
|
||||||
|
end
|
||||||
|
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
def images_pdf_uuid(attachments)
|
def images_pdf_uuid(attachments)
|
||||||
Digest::UUID.uuid_v5(Digest::UUID::OID_NAMESPACE, attachments.map(&:uuid).sort.join(':'))
|
Digest::UUID.uuid_v5(Digest::UUID::OID_NAMESPACE, attachments.map(&:uuid).sort.join(':'))
|
||||||
end
|
end
|
||||||
@@ -420,6 +430,7 @@ module Submissions
|
|||||||
|
|
||||||
def build_pdf_from_image(attachment)
|
def build_pdf_from_image(attachment)
|
||||||
pdf = HexaPDF::Document.new
|
pdf = HexaPDF::Document.new
|
||||||
|
|
||||||
page = pdf.pages.add
|
page = pdf.pages.add
|
||||||
|
|
||||||
scale = [A4_SIZE.first / attachment.metadata['width'].to_f,
|
scale = [A4_SIZE.first / attachment.metadata['width'].to_f,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ module TimeUtils
|
|||||||
|
|
||||||
YEAR_FORMATS = {
|
YEAR_FORMATS = {
|
||||||
'YYYY' => '%Y',
|
'YYYY' => '%Y',
|
||||||
|
'YYY' => '%Y',
|
||||||
'YY' => '%y'
|
'YY' => '%y'
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user