mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2508b5fc8a | ||
|
|
4bd1ef0da3 | ||
|
|
4efd748571 | ||
|
|
859892d1fd | ||
|
|
7adeaf93cd | ||
|
|
5dbe155ecb | ||
|
|
667d065bee | ||
|
|
bb613059de | ||
|
|
1b2dec4c2a | ||
|
|
2c2ef97c30 | ||
|
|
6df1d68237 | ||
|
|
20c9faedff | ||
|
|
d931a40ea9 | ||
|
|
1097b98b85 | ||
|
|
2e597fcf43 | ||
|
|
bb2fa6a261 | ||
|
|
1dc8369487 | ||
|
|
e6d60f1985 | ||
|
|
82e3cb8a4d | ||
|
|
aeec0cbf8e | ||
|
|
7a2d1fc6c5 | ||
|
|
68033ab7d2 | ||
|
|
7595c60ea8 | ||
|
|
d9318c04f8 | ||
|
|
2d76198290 | ||
|
|
02a7b6ea55 | ||
|
|
ab57076b8f | ||
|
|
82fba47c98 |
No files matched your search
@@ -11,7 +11,7 @@ jobs:
|
||||
- name: Install Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.2.2
|
||||
ruby-version: 3.3.1
|
||||
- name: Cache gems
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
- name: Install Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.2.2
|
||||
ruby-version: 3.3.1
|
||||
- name: Cache gems
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
@@ -100,7 +100,7 @@ jobs:
|
||||
- name: Install Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.2.2
|
||||
ruby-version: 3.3.1
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ AllCops:
|
||||
- node_modules/**/*
|
||||
- bin/*
|
||||
- vendor/**/*
|
||||
TargetRubyVersion: '3.2'
|
||||
TargetRubyVersion: '3.3'
|
||||
|
||||
Metrics/BlockLength:
|
||||
Exclude:
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
FROM ruby:3.2.2-alpine3.18 as fonts
|
||||
FROM ruby:3.3.1-alpine3.18 as fonts
|
||||
|
||||
WORKDIR /fonts
|
||||
|
||||
@@ -6,7 +6,7 @@ RUN apk --no-cache add fontforge wget && wget https://github.com/satbyy/go-noto-
|
||||
|
||||
RUN fontforge -lang=py -c 'font1 = fontforge.open("FreeSans.ttf"); font2 = fontforge.open("NotoSansSymbols2-Regular.ttf"); font1.mergeFonts(font2); font1.generate("FreeSans.ttf")'
|
||||
|
||||
FROM ruby:3.2.2-alpine3.18 as webpack
|
||||
FROM ruby:3.3.1-alpine3.18 as webpack
|
||||
|
||||
ENV RAILS_ENV=production
|
||||
ENV NODE_ENV=production
|
||||
@@ -32,7 +32,7 @@ COPY ./app/views ./app/views
|
||||
|
||||
RUN echo "gem 'shakapacker'" > Gemfile && ./bin/shakapacker
|
||||
|
||||
FROM ruby:3.2.2-alpine3.18 as app
|
||||
FROM ruby:3.3.1-alpine3.18 as app
|
||||
|
||||
ENV RAILS_ENV=production
|
||||
ENV BUNDLE_WITHOUT="development:test"
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
ruby '3.2.2'
|
||||
ruby '3.3.1'
|
||||
|
||||
gem 'arabic-letter-connector', require: 'arabic-letter-connector/logic'
|
||||
gem 'aws-sdk-s3', require: false
|
||||
gem 'azure-storage-blob', require: false
|
||||
gem 'bootsnap', require: false
|
||||
gem 'cancancan'
|
||||
gem 'csv'
|
||||
gem 'devise'
|
||||
gem 'devise-two-factor'
|
||||
gem 'dotenv', require: false
|
||||
|
||||
+5
-3
@@ -149,6 +149,7 @@ GEM
|
||||
crass (1.0.6)
|
||||
css_parser (1.17.1)
|
||||
addressable
|
||||
csv (3.3.0)
|
||||
cuprite (0.15)
|
||||
capybara (~> 3.0)
|
||||
ferrum (~> 0.14.0)
|
||||
@@ -342,7 +343,7 @@ GEM
|
||||
package_json (0.1.0)
|
||||
pagy (8.1.2)
|
||||
parallel (1.24.0)
|
||||
parser (3.3.0.5)
|
||||
parser (3.3.1.0)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
pdf-reader (2.12.0)
|
||||
@@ -461,7 +462,7 @@ GEM
|
||||
rspec-mocks (~> 3.13)
|
||||
rspec-support (~> 3.13)
|
||||
rspec-support (3.13.1)
|
||||
rubocop (1.63.1)
|
||||
rubocop (1.63.3)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
@@ -585,6 +586,7 @@ DEPENDENCIES
|
||||
bullet
|
||||
cancancan
|
||||
capybara
|
||||
csv
|
||||
cuprite
|
||||
debug
|
||||
devise
|
||||
@@ -636,7 +638,7 @@ DEPENDENCIES
|
||||
webmock
|
||||
|
||||
RUBY VERSION
|
||||
ruby 3.2.2p53
|
||||
ruby 3.3.1p55
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.3
|
||||
@@ -11,7 +11,8 @@ class AccountConfigsController < ApplicationController
|
||||
AccountConfig::ESIGNING_PREFERENCE_KEY,
|
||||
AccountConfig::FORM_WITH_CONFETTI_KEY,
|
||||
AccountConfig::DOWNLOAD_LINKS_AUTH_KEY,
|
||||
AccountConfig::FORCE_SSO_AUTH_KEY
|
||||
AccountConfig::FORCE_SSO_AUTH_KEY,
|
||||
AccountConfig::FLATTEN_RESULT_PDF_KEY
|
||||
].freeze
|
||||
|
||||
InvalidKey = Class.new(StandardError)
|
||||
|
||||
@@ -70,7 +70,7 @@ module Api
|
||||
end
|
||||
|
||||
def create
|
||||
Params::SubmissionCreateValidator.call(params, dry_run: !Docuseal.multitenant?)
|
||||
Params::SubmissionCreateValidator.call(params)
|
||||
|
||||
return render json: { error: 'Template not found' }, status: :unprocessable_entity if @template.nil?
|
||||
|
||||
@@ -93,7 +93,13 @@ module Api
|
||||
end
|
||||
end
|
||||
|
||||
render json: submissions.flat_map(&:submitters)
|
||||
json = submissions.flat_map do |submission|
|
||||
submission.submitters.map do |s|
|
||||
Submitters::SerializeForApi.call(s, with_documents: false, with_urls: true)
|
||||
end
|
||||
end
|
||||
|
||||
render json:
|
||||
rescue Submitters::NormalizeValues::BaseError => e
|
||||
Rollbar.warning(e) if defined?(Rollbar)
|
||||
|
||||
@@ -171,9 +177,9 @@ module Api
|
||||
submitters: [[:send_email, :send_sms, :completed_redirect_url, :uuid, :name, :email, :role,
|
||||
:completed, :phone, :application_key, :external_id, :reply_to, :go_to_last,
|
||||
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
||||
fields: [:name, :uuid, :default_value, :title, :description,
|
||||
fields: [:name, :uuid, :default_value, :value, :title, :description,
|
||||
:readonly, :redacted, :validation_pattern, :invalid_message,
|
||||
{ default_value: [] }] }]]
|
||||
{ default_value: [], value: [] }] }]]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -71,7 +71,9 @@ module Api
|
||||
Submitters.send_signature_requests([@submitter])
|
||||
end
|
||||
|
||||
render json: Submitters::SerializeForApi.call(@submitter, with_template: false, with_events: false)
|
||||
render json: Submitters::SerializeForApi.call(@submitter, with_template: false,
|
||||
with_urls: true,
|
||||
with_events: false)
|
||||
end
|
||||
|
||||
def submitter_params
|
||||
@@ -81,8 +83,9 @@ module Api
|
||||
:send_email, :send_sms, :reply_to, :completed_redirect_url, :uuid, :name, :email, :role,
|
||||
:completed, :phone, :application_key, :external_id, :go_to_last,
|
||||
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
||||
fields: [[:name, :uuid, :default_value, :readonly, :redacted, :validation_pattern, :invalid_message,
|
||||
{ default_value: [] }]] }
|
||||
fields: [[:name, :uuid, :default_value, :value,
|
||||
:readonly, :redacted, :validation_pattern, :invalid_message,
|
||||
{ default_value: [], value: [] }]] }
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -15,6 +15,11 @@ class ErrorsController < ActionController::Base
|
||||
'/api/templates/docx'
|
||||
].freeze
|
||||
|
||||
SAFE_ERROR_MESSAGE_CLASSES = [
|
||||
ActionDispatch::Http::Parameters::ParseError,
|
||||
JSON::ParserError
|
||||
].freeze
|
||||
|
||||
def show
|
||||
if request.original_fullpath.in?(ENTERPRISE_PATHS) && error_status_code == 404
|
||||
return render json: { status: 404, message: ENTERPRISE_FEATURE_MESSAGE }, status: :not_found
|
||||
@@ -24,7 +29,11 @@ class ErrorsController < ActionController::Base
|
||||
f.json do
|
||||
set_cors_headers
|
||||
|
||||
render json: { status: error_status_code }, status: error_status_code
|
||||
exception = request.env['action_dispatch.exception']
|
||||
|
||||
error = exception.message if exception.class.in?(SAFE_ERROR_MESSAGE_CLASSES)
|
||||
|
||||
render json: { status: error_status_code, error: }.compact, status: error_status_code
|
||||
end
|
||||
|
||||
f.html { render error_status_code.to_s, status: error_status_code }
|
||||
|
||||
@@ -18,6 +18,12 @@ class PersonalizationSettingsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
if @account_config.value.is_a?(Hash)
|
||||
@account_config.value = @account_config.value.reject do |_, v|
|
||||
v.blank? && v != false
|
||||
end
|
||||
end
|
||||
|
||||
if @account_config.value != false && @account_config.value.blank?
|
||||
@account_config.destroy!
|
||||
else
|
||||
|
||||
@@ -7,6 +7,8 @@ class SubmittersSendEmailController < ApplicationController
|
||||
if Docuseal.multitenant? && SubmissionEvent.exists?(submitter: @submitter,
|
||||
event_type: 'send_email',
|
||||
created_at: 24.hours.ago..Time.current)
|
||||
Rollbar.warning("Already sent: #{@submitter.id}") if defined?(Rollbar)
|
||||
|
||||
return redirect_back(fallback_location: submission_path(@submitter.submission),
|
||||
alert: 'Email has been sent already.')
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UsersController < ApplicationController
|
||||
load_and_authorize_resource :user, only: %i[index edit new update destroy]
|
||||
load_and_authorize_resource :user, only: %i[index edit update destroy]
|
||||
|
||||
before_action :build_user, only: :create
|
||||
authorize_resource :user, only: :create
|
||||
before_action :build_user, only: %i[new create]
|
||||
authorize_resource :user, only: %i[new create]
|
||||
|
||||
def index
|
||||
@users =
|
||||
@@ -14,7 +14,7 @@ class UsersController < ApplicationController
|
||||
@users.active
|
||||
end
|
||||
|
||||
@pagy, @users = pagy(@users.order(id: :desc))
|
||||
@pagy, @users = pagy(@users.where(account: current_account).order(id: :desc))
|
||||
end
|
||||
|
||||
def new; end
|
||||
@@ -81,6 +81,11 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:email, :first_name, :last_name, :password, :role, :archived_at)
|
||||
if params.key?(:user)
|
||||
params.require(:user).permit(:email, :first_name, :last_name, :password,
|
||||
:role, :archived_at, :account_id)
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex absolute lg:text-base -outline-offset-1"
|
||||
class="field-area flex absolute lg:text-base -outline-offset-1"
|
||||
dir="auto"
|
||||
: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 }"
|
||||
|
||||
@@ -360,6 +360,7 @@
|
||||
:key="currentField.uuid"
|
||||
v-model="values[currentField.uuid]"
|
||||
:field="currentField"
|
||||
:locale="language?.toLowerCase() || browserLanguage"
|
||||
:show-field-names="showFieldNames"
|
||||
:verified-value="phoneVerifiedValues[currentField.uuid]"
|
||||
:default-value="submitter.phone"
|
||||
@@ -471,10 +472,14 @@ import i18n from './i18n'
|
||||
const isEmpty = (obj) => {
|
||||
if (obj == null) return true
|
||||
|
||||
if (Array.isArray(obj) || typeof obj === 'string') {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.length === 0
|
||||
}
|
||||
|
||||
if (typeof obj === 'string') {
|
||||
return obj.trim().length === 0
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
return Object.keys(obj).length === 0
|
||||
}
|
||||
@@ -549,6 +554,11 @@ export default {
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
reuseSignature: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
withConfetti: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
@@ -695,9 +705,13 @@ export default {
|
||||
}, {})
|
||||
},
|
||||
previousInitialsValue () {
|
||||
const initialsField = [...this.fields].reverse().find((field) => field.type === 'initials' && !!this.values[field.uuid])
|
||||
if (this.reuseSignature !== false) {
|
||||
const initialsField = [...this.fields].reverse().find((field) => field.type === 'initials' && !!this.values[field.uuid])
|
||||
|
||||
return this.values[initialsField?.uuid]
|
||||
return this.values[initialsField?.uuid]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
},
|
||||
isAnonymousChecboxes () {
|
||||
return this.currentField.type === 'checkbox' && this.currentStepFields.every((e) => !e.name && !e.required) && this.currentStepFields.length > 4
|
||||
@@ -925,11 +939,15 @@ export default {
|
||||
})
|
||||
},
|
||||
previousSignatureValueFor (field) {
|
||||
const signatureField = [...this.fields].reverse().find((f) =>
|
||||
f.type === 'signature' && field.preferences?.format === f.preferences?.format && !!this.values[f.uuid]
|
||||
)
|
||||
if (this.reuseSignature !== false) {
|
||||
const signatureField = [...this.fields].reverse().find((f) =>
|
||||
f.type === 'signature' && field.preferences?.format === f.preferences?.format && !!this.values[f.uuid]
|
||||
)
|
||||
|
||||
return this.values[signatureField?.uuid]
|
||||
return this.values[signatureField?.uuid]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
},
|
||||
goToStep (step, scrollToArea = false, clickUpload = false) {
|
||||
this.currentStep = this.stepFields.indexOf(step)
|
||||
|
||||
@@ -117,6 +117,11 @@ export default {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
locale: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'en'
|
||||
},
|
||||
showFieldNames: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
@@ -163,6 +168,7 @@ export default {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
submitter_slug: this.submitterSlug,
|
||||
locale: this.locale,
|
||||
phone: this.$refs.phone.value
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
v-model="field.type"
|
||||
:editable="editable && !defaultField"
|
||||
:button-width="20"
|
||||
:menu-classes="'mt-1.5'"
|
||||
:menu-style="{ backgroundColor: dropdownBgColor }"
|
||||
@update:model-value="[maybeUpdateOptions(), save()]"
|
||||
@click="scrollToFirstArea"
|
||||
/>
|
||||
@@ -110,7 +112,8 @@
|
||||
<ul
|
||||
v-if="renderDropdown"
|
||||
tabindex="0"
|
||||
class="mt-1.5 dropdown-content menu menu-xs p-2 shadow bg-base-100 rounded-box w-52 z-10"
|
||||
class="mt-1.5 dropdown-content menu menu-xs p-2 shadow rounded-box w-52 z-10"
|
||||
:style="{ backgroundColor: dropdownBgColor }"
|
||||
draggable="true"
|
||||
@dragstart.prevent.stop
|
||||
@click="closeDropdown"
|
||||
@@ -121,7 +124,7 @@
|
||||
@click.stop
|
||||
>
|
||||
<select
|
||||
class="select select-bordered select-xs w-full max-w-xs h-7 !outline-0 font-normal"
|
||||
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
|
||||
@@ -134,7 +137,7 @@
|
||||
</option>
|
||||
</select>
|
||||
<label
|
||||
:style="{ backgroundColor: backgroundColor }"
|
||||
:style="{ backgroundColor: dropdownBgColor }"
|
||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||
style="font-size: 8px"
|
||||
>
|
||||
@@ -151,12 +154,12 @@
|
||||
:placeholder="t('default_value')"
|
||||
dir="auto"
|
||||
:type="field.type"
|
||||
class="input input-bordered input-xs w-full max-w-xs h-7 !outline-0"
|
||||
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: backgroundColor }"
|
||||
:style="{ backgroundColor: dropdownBgColor }"
|
||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||
style="font-size: 8px"
|
||||
>
|
||||
@@ -171,7 +174,7 @@
|
||||
<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"
|
||||
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
|
||||
@change="save"
|
||||
>
|
||||
<option
|
||||
@@ -183,7 +186,7 @@
|
||||
</option>
|
||||
</select>
|
||||
<label
|
||||
:style="{ backgroundColor: backgroundColor }"
|
||||
:style="{ backgroundColor: dropdownBgColor }"
|
||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||
style="font-size: 8px"
|
||||
>
|
||||
@@ -197,7 +200,7 @@
|
||||
>
|
||||
<select
|
||||
:placeholder="t('format')"
|
||||
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0"
|
||||
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
|
||||
@@ -220,7 +223,7 @@
|
||||
</option>
|
||||
</select>
|
||||
<label
|
||||
:style="{ backgroundColor: backgroundColor }"
|
||||
:style="{ backgroundColor: dropdownBgColor }"
|
||||
class="absolute -top-1 left-2.5 px-1 h-4"
|
||||
style="font-size: 8px"
|
||||
>
|
||||
@@ -569,6 +572,9 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
fieldNames: FieldType.computed.fieldNames,
|
||||
dropdownBgColor () {
|
||||
return ['', null, 'transparent'].includes(this.backgroundColor) ? 'white' : this.backgroundColor
|
||||
},
|
||||
schemaAttachmentsIndexes () {
|
||||
return (this.template.schema || []).reduce((acc, item, index) => {
|
||||
acc[item.attachment_uuid] = index
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
tabindex="0"
|
||||
class="rounded-md min-w-max mb-2"
|
||||
:class="menuClasses"
|
||||
:style="menuStyle"
|
||||
@click="closeDropdown"
|
||||
>
|
||||
<li
|
||||
@@ -136,6 +137,7 @@
|
||||
v-if="(editable || !compact) && renderDropdown"
|
||||
tabindex="0"
|
||||
:class="menuClasses"
|
||||
:style="menuStyle"
|
||||
@click="closeDropdown"
|
||||
>
|
||||
<li
|
||||
@@ -253,10 +255,15 @@ export default {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
menuStyle: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({})
|
||||
},
|
||||
menuClasses: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'dropdown-content menu p-2 shadow bg-base-100 rounded-box w-full z-10'
|
||||
default: 'dropdown-content menu p-2 shadow rounded-box w-full z-10'
|
||||
}
|
||||
},
|
||||
emits: ['update:model-value', 'remove', 'new-submitter', 'name-change'],
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
v-if="editable && renderDropdown"
|
||||
tabindex="0"
|
||||
class="dropdown-content menu menu-xs p-2 shadow rounded-box w-52 z-10 mb-3"
|
||||
:style="menuStyle"
|
||||
:class="menuClasses"
|
||||
@click="closeDropdown"
|
||||
>
|
||||
@@ -65,6 +66,11 @@ export default {
|
||||
required: false,
|
||||
default: 'mt-1.5 bg-base-100'
|
||||
},
|
||||
menuStyle: {
|
||||
type: Object,
|
||||
required: false,
|
||||
default: () => ({})
|
||||
},
|
||||
buttonClasses: {
|
||||
type: String,
|
||||
required: false,
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
<FieldSubmitter
|
||||
:model-value="selectedSubmitter.uuid"
|
||||
class="roles-dropdown w-full rounded-lg"
|
||||
:class="{ 'bg-base-100': withStickySubmitters }"
|
||||
:style="withStickySubmitters ? { backgroundColor } : {}"
|
||||
:submitters="submitters"
|
||||
:menu-style="{ backgroundColor: ['', null, 'transparent'].includes(backgroundColor) ? 'white' : backgroundColor }"
|
||||
:editable="editable && !defaultSubmitters.length"
|
||||
@new-submitter="save"
|
||||
@remove="removeSubmitter"
|
||||
@@ -71,7 +72,7 @@
|
||||
:key="field.name"
|
||||
>
|
||||
<div
|
||||
:style="{ backgroundColor: backgroundColor }"
|
||||
:style="{ backgroundColor }"
|
||||
draggable="true"
|
||||
class="default-field border border-base-300 rounded rounded-tr-none relative group mb-2"
|
||||
@dragstart="onDragstart({ type: 'text', ...field })"
|
||||
@@ -113,7 +114,7 @@
|
||||
v-if="(fieldTypes.length === 0 || fieldTypes.includes(type)) && (withPhone || type != 'phone') && (withPayment || type != 'payment')"
|
||||
draggable="true"
|
||||
class="field-type-button group flex items-center justify-center border border-dashed w-full rounded relative"
|
||||
:style="{ backgroundColor: backgroundColor }"
|
||||
:style="{ backgroundColor }"
|
||||
:class="drawFieldType === type ? 'border-base-content/40' : 'border-base-300 hover:border-base-content/20'"
|
||||
@dragstart="onDragstart({ type: type })"
|
||||
@dragend="$emit('drag-end')"
|
||||
@@ -142,7 +143,7 @@
|
||||
href="https://www.docuseal.co/pricing"
|
||||
target="_blank"
|
||||
class="opacity-50 flex items-center justify-center border border-dashed border-base-300 w-full rounded relative"
|
||||
:style="{ backgroundColor: backgroundColor }"
|
||||
:style="{ backgroundColor }"
|
||||
>
|
||||
<div class="w-0 absolute left-0">
|
||||
<IconLock
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
:submitters="submitters"
|
||||
:editable="editable"
|
||||
:mobile-view="true"
|
||||
:menu-style="{ backgroundColor: ['', null, 'transparent'].includes(backgroundColor) ? 'white' : backgroundColor }"
|
||||
@new-submitter="save"
|
||||
@remove="removeSubmitter"
|
||||
@name-change="save"
|
||||
@@ -43,7 +44,7 @@ export default {
|
||||
Field,
|
||||
FieldSubmitter
|
||||
},
|
||||
inject: ['save', 't'],
|
||||
inject: ['save', 't', 'backgroundColor'],
|
||||
props: {
|
||||
drawField: {
|
||||
type: Object,
|
||||
|
||||
+10
-7
@@ -4,13 +4,14 @@
|
||||
#
|
||||
# Table name: accounts
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# locale :string not null
|
||||
# name :string not null
|
||||
# timezone :string not null
|
||||
# uuid :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# id :bigint not null, primary key
|
||||
# archived_at :datetime
|
||||
# locale :string not null
|
||||
# name :string not null
|
||||
# timezone :string not null
|
||||
# uuid :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
@@ -49,6 +50,8 @@ class Account < ApplicationRecord
|
||||
attribute :timezone, :string, default: 'UTC'
|
||||
attribute :locale, :string, default: 'en-US'
|
||||
|
||||
scope :active, -> { where(archived_at: nil) }
|
||||
|
||||
def testing?
|
||||
linked_account_account&.testing?
|
||||
end
|
||||
|
||||
@@ -36,6 +36,7 @@ class AccountConfig < ApplicationRecord
|
||||
WEBHOOK_PREFERENCES_KEY = 'webhook_preferences'
|
||||
DOWNLOAD_LINKS_AUTH_KEY = 'download_links_auth'
|
||||
FORCE_SSO_AUTH_KEY = 'force_sso_auth'
|
||||
FLATTEN_RESULT_PDF_KEY = 'flatten_result_pdf'
|
||||
|
||||
DEFAULT_VALUES = {
|
||||
SUBMITTER_INVITATION_EMAIL_KEY => {
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def active_for_authentication?
|
||||
super && !archived_at?
|
||||
super && !archived_at? && !account.archived_at?
|
||||
end
|
||||
|
||||
def remember_me
|
||||
|
||||
@@ -140,6 +140,18 @@
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::FLATTEN_RESULT_PDF_KEY) %>
|
||||
<% if can?(:manage, account_config) %>
|
||||
<%= form_for account_config, url: account_configs_path, method: :post do |f| %>
|
||||
<%= f.hidden_field :key %>
|
||||
<div class="flex items-center justify-between py-2.5">
|
||||
<span>
|
||||
Remove PDF form fillable fields from the signed PDF (flatten form)
|
||||
</span>
|
||||
<%= f.check_box :value, { class: 'toggle', checked: account_config.value != false, onchange: 'this.form.requestSubmit()' } %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -37,11 +37,17 @@
|
||||
<%= link_to 'E-Signature', settings_esign_path, class: 'text-base hover:bg-base-300' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if can?(:read, AccountConfig) %>
|
||||
<li>
|
||||
<%= link_to 'Personalization', settings_personalization_path, class: 'text-base hover:bg-base-300' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if can?(:read, User) %>
|
||||
<li>
|
||||
<%= link_to 'Users', settings_users_path, class: 'text-base hover:bg-base-300' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<%= render 'shared/settings_nav_extra' %>
|
||||
<% if Docuseal.demo? || !Docuseal.multitenant? %>
|
||||
<% if can?(:read, AccessToken) %>
|
||||
<li>
|
||||
@@ -54,12 +60,6 @@
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if can?(:read, AccountConfig) %>
|
||||
<li>
|
||||
<%= link_to 'Personalization', settings_personalization_path, class: 'text-base hover:bg-base-300' %>
|
||||
</li>
|
||||
<% end %>
|
||||
<%= render 'shared/settings_nav_extra' %>
|
||||
<% if !Docuseal.demo? && can?(:manage, EncryptedConfig) && (current_user != true_user || !current_account.testing?) %>
|
||||
<li>
|
||||
<%= link_to Docuseal.multitenant? ? console_redirect_index_path(redir: "#{Docuseal::CONSOLE_URL}/plans") : "#{Docuseal::CLOUD_URL}/sign_up?#{{ redir: "#{Docuseal::CONSOLE_URL}/on_premise" }.to_query}", class: 'text-base hover:bg-base-300', data: { prefetch: false } do %>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
<% if !template.archived_at? %>
|
||||
<div class="flex items-center space-x-2">
|
||||
<% if can?(:update, template) && (Docuseal.multitenant? || current_account.testing? || current_account.id == 1) %>
|
||||
<% if can?(:update, template) %>
|
||||
<div class="tooltip" data-tip="Preferences">
|
||||
<%= link_to template_preferences_path(template), class: 'btn border border-base-200 bg-base-200 hover:bg-base-300 hover:border-base-300 btn-sm flex-1 hidden md:flex', data: { turbo_frame: :modal } do %>
|
||||
<span class="flex items-center justify-center space-x-2">
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<% if @base_template %>
|
||||
<%= hidden_field_tag :base_template_id, @base_template.id %>
|
||||
<% end %>
|
||||
<% if @base_template && (can?(:manage, :tenants) || true_user != current_user) && true_user.account.account_linked_accounts.exists? %>
|
||||
<% if @base_template && (can?(:manage, :tenants) || true_user != current_user) && true_user.account.linked_accounts.active.exists? %>
|
||||
<div class="form-control -mb-2 mt-2">
|
||||
<%= select_tag :account_id, options_for_select([true_user.account, *true_user.account.linked_accounts].uniq.map { |e| [e.name, e.id] }, current_account.id), required: true, class: 'base-select' %>
|
||||
<%= select_tag :account_id, options_for_select([true_user.account, *true_user.account.linked_accounts.active].uniq.map { |e| [e.name, e.id] }, current_account.id), required: true, class: 'base-select' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-control mt-6">
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
<%= render 'shared/turbo_modal_large', title: 'Preferences', close_after_submit: false do %>
|
||||
<% options = [['General', 'general'], ['API and Embedding', 'api']] %>
|
||||
<toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center mt-3 block">
|
||||
<div class="join">
|
||||
<% options.each_with_index do |(label, value), index| %>
|
||||
<span>
|
||||
<%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %>
|
||||
<label for="option_<%= value %>" class="<%= '!rounded-s-full' if index.zero? %> btn btn-focus btn-sm join-item md:w-48 peer-checked:btn-active normal-case <%= 'px-8 md:px-0' if value == 'general' %>">
|
||||
<%= label %>
|
||||
</label>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</toggle-visible>
|
||||
<% show_api = Docuseal.multitenant? || current_account.testing? || !current_account.linked_account_account %>
|
||||
<% options = [%w[General general]] %>
|
||||
<% options << ['API and Embedding', 'api'] if show_api %>
|
||||
<% if options.size > 1 %>
|
||||
<toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center mt-3 block">
|
||||
<div class="join">
|
||||
<% options.each_with_index do |(label, value), index| %>
|
||||
<span>
|
||||
<%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %>
|
||||
<label for="option_<%= value %>" class="<%= '!rounded-s-full' if index.zero? %> btn btn-focus btn-sm join-item md:w-48 peer-checked:btn-active normal-case <%= 'px-8 md:px-0' if value == 'general' %>">
|
||||
<%= label %>
|
||||
</label>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</toggle-visible>
|
||||
<% end %>
|
||||
<div id="general" class="px-5 mb-4">
|
||||
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' } do |f| %>
|
||||
<toggle-on-submit data-element-id="email_saved_alert"></toggle-on-submit>
|
||||
@@ -62,39 +66,41 @@
|
||||
<% end %>
|
||||
<%= render 'templates_code_modal/preferences' %>
|
||||
</div>
|
||||
<div id="api" class="hidden mt-2 mb-4 px-5">
|
||||
<div>
|
||||
<label class="text-sm font-semibold" for="template_id">
|
||||
Template ID
|
||||
</label>
|
||||
<div class="flex gap-2 mb-4 mt-2">
|
||||
<input id="template_id" type="text" value="<%= @template.id %>" class="base-input w-full" autocomplete="off" readonly>
|
||||
<%= render 'shared/clipboard_copy', icon: 'copy', text: @template.id, class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %>
|
||||
<% if show_api %>
|
||||
<div id="api" class="hidden mt-2 mb-4 px-5">
|
||||
<div>
|
||||
<label class="text-sm font-semibold" for="template_id">
|
||||
Template ID
|
||||
</label>
|
||||
<div class="flex gap-2 mb-4 mt-2">
|
||||
<input id="template_id" type="text" value="<%= @template.id %>" class="base-input w-full" autocomplete="off" readonly>
|
||||
<%= render 'shared/clipboard_copy', icon: 'copy', text: @template.id, class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-sm font-semibold" for="embedding_url">
|
||||
Embedding URL
|
||||
</label>
|
||||
<div class="flex gap-2 mb-4 mt-2">
|
||||
<input id="embedding_url" type="text" value="<%= start_form_url(slug: @template.slug) %>" class="base-input w-full" autocomplete="off" readonly>
|
||||
<%= render 'shared/clipboard_copy', icon: 'copy', text: start_form_url(slug: @template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %>
|
||||
<div>
|
||||
<label class="text-sm font-semibold" for="embedding_url">
|
||||
Embedding URL
|
||||
</label>
|
||||
<div class="flex gap-2 mb-4 mt-2">
|
||||
<input id="embedding_url" type="text" value="<%= start_form_url(slug: @template.slug) %>" class="base-input w-full" autocomplete="off" readonly>
|
||||
<%= render 'shared/clipboard_copy', icon: 'copy', text: start_form_url(slug: @template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= render 'templates_code_modal/placeholder' %>
|
||||
<%= render 'templates/embedding', template: @template %>
|
||||
<% if can?(:manage, TemplateSharing.new(template: @template)) %>
|
||||
<%= form_for '', url: template_sharings_testing_index_path, method: :post, html: { class: 'mt-1' } do |f| %>
|
||||
<%= f.hidden_field :template_id, value: @template.id %>
|
||||
<div class="flex items-center justify-between">
|
||||
<span>
|
||||
Share template with Test Environment
|
||||
</span>
|
||||
<%= f.check_box :value, class: 'toggle', checked: @template.template_sharings.exists?(account_id: current_account.testing_accounts), onchange: 'this.form.requestSubmit()' %>
|
||||
<%= render 'templates_code_modal/placeholder' %>
|
||||
<%= render 'templates/embedding', template: @template %>
|
||||
<% if can?(:manage, TemplateSharing.new(template: @template)) %>
|
||||
<%= form_for '', url: template_sharings_testing_index_path, method: :post, html: { class: 'mt-1' } do |f| %>
|
||||
<%= f.hidden_field :template_id, value: @template.id %>
|
||||
<div class="flex items-center justify-between">
|
||||
<span>
|
||||
Share template with Test Environment
|
||||
</span>
|
||||
<%= f.check_box :value, class: 'toggle', checked: @template.template_sharings.exists?(account_id: current_account.testing_accounts), onchange: 'this.form.requestSubmit()' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="mb-4">
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="mb-4">
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -128,14 +128,22 @@ Rails.application.configure do
|
||||
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
||||
|
||||
config.lograge.custom_payload do |controller|
|
||||
params = controller.request.try(:params) || {}
|
||||
params =
|
||||
begin
|
||||
controller.request.try(:params) || {}
|
||||
rescue StandardError
|
||||
{}
|
||||
end
|
||||
|
||||
{
|
||||
fwd: controller.request.ip,
|
||||
params: {
|
||||
id: params[:id],
|
||||
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
|
||||
slug: (params[:slug] || params[:submission_slug] || params[:template_slug]).to_s.last(5)
|
||||
slug: (params[:slug] ||
|
||||
params[:submitter_slug] ||
|
||||
params[:submission_slug] ||
|
||||
params[:template_slug]).to_s.last(5)
|
||||
}.compact_blank,
|
||||
host: controller.request.host,
|
||||
uid: controller.instance_variable_get(:@current_user).try(:id)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
en: &en
|
||||
email: Email
|
||||
verification_code_code: 'Verification code: %{code}'
|
||||
digitally_signed_by: Digitally signed by
|
||||
role: Role
|
||||
provide_your_email_to_start: Provide your email to start
|
||||
@@ -21,6 +22,7 @@ en: &en
|
||||
|
||||
es: &es
|
||||
role: Rol
|
||||
verification_code_code: 'Código de verificación: %{code}'
|
||||
email: Correo electrónico
|
||||
digitally_signed_by: Firmado digitalmente por
|
||||
role: Rol
|
||||
@@ -42,6 +44,7 @@ es: &es
|
||||
|
||||
it:
|
||||
role: Rôle
|
||||
verification_code_code: 'Codice di verifica: %{code}'
|
||||
email: Email
|
||||
digitally_signed_by: Firmato digitalmente da
|
||||
role: Ruolo
|
||||
@@ -63,6 +66,7 @@ it:
|
||||
|
||||
fr: &fr
|
||||
email: Email
|
||||
verification_code_code: 'Code de vérification: %{code}'
|
||||
digitally_signed_by: Signé numériquement par
|
||||
role: Rôle
|
||||
provide_your_email_to_start: Entrez votre adresse email pour commencer
|
||||
@@ -84,6 +88,7 @@ fr: &fr
|
||||
pt: &pt
|
||||
role: Função
|
||||
email: Email
|
||||
verification_code_code: 'Código de verificação: %{code}'
|
||||
digitally_signed_by: Assinado digitalmente por
|
||||
role: Função
|
||||
provide_your_email_to_start: Forneça o seu email para começar
|
||||
@@ -104,6 +109,7 @@ pt: &pt
|
||||
|
||||
de: &de
|
||||
role: Rolle
|
||||
verification_code_code: 'Verifizierungscode: %{code}'
|
||||
email: E-Mail
|
||||
digitally_signed_by: Digital signiert von
|
||||
role: Rolle
|
||||
@@ -125,6 +131,7 @@ de: &de
|
||||
|
||||
pl:
|
||||
email: Email
|
||||
verification_code_code: 'Kod weryfikacyjny: %{code}'
|
||||
digitally_signed_by: Podpis cyfrowy przez
|
||||
role: Rola
|
||||
provide_your_email_to_start: Podaj swój adres email, aby rozpocząć
|
||||
@@ -146,6 +153,7 @@ pl:
|
||||
uk:
|
||||
email: Email
|
||||
digitally_signed_by: Цифровий підпис від
|
||||
verification_code_code: 'Код підтвердження: %{code}'
|
||||
role: Роль
|
||||
provide_your_email_to_start: Введіть свій email, щоб почати
|
||||
start: Почати
|
||||
@@ -166,6 +174,7 @@ uk:
|
||||
cs:
|
||||
email: Email
|
||||
digitally_signed_by: Digitálně podepsáno uživatelem
|
||||
verification_code_code: 'Ověřovací kód: %{code}'
|
||||
role: Role
|
||||
provide_your_email_to_start: Zadejte svůj email pro zahájení
|
||||
start: Zahájit
|
||||
@@ -187,6 +196,7 @@ he:
|
||||
email: דוא"ל
|
||||
digitally_signed_by: חתום דיגיטלית על ידי
|
||||
role: תפקיד
|
||||
verification_code_code: 'קוד אימות: %{code}'
|
||||
provide_your_email_to_start: ספק את כתובת הדוא"ל שלך כדי להתחיל
|
||||
start: התחל
|
||||
starting: מתחיל
|
||||
@@ -207,6 +217,7 @@ nl:
|
||||
email: E-mail
|
||||
digitally_signed_by: Digitaal ondertekend door
|
||||
role: Rol
|
||||
verification_code_code: 'Verificatiecode: %{code}'
|
||||
provide_your_email_to_start: Geef uw e-mailadres om te beginnen
|
||||
start: Start
|
||||
starting: Starten
|
||||
@@ -231,6 +242,7 @@ ar:
|
||||
provide_your_email_to_start: قدم بريدك الإلكتروني للبدء
|
||||
start: بدء
|
||||
starting: بداية
|
||||
verification_code_code: 'رمز التحقق: %{code}'
|
||||
form_has_been_deleted_by_html: 'تم حذف الاستمارة بواسطة <span class="font-semibold">%{name}</span>.'
|
||||
invited_by_html: 'تمت الدعوة بواسطة <span class="font-semibold">%{name}</span>'
|
||||
you_have_been_invited_to_submit_a_form: تمت دعوتك لتقديم استمارة
|
||||
@@ -255,6 +267,7 @@ ko:
|
||||
form_has_been_deleted_by_html: '<span class="font-semibold">%{name}</span>에 의해 양식이 삭제되었습니다.'
|
||||
invited_by_html: '<span class="font-semibold">%{name}</span>에 의해 초대되었습니다.'
|
||||
you_have_been_invited_to_submit_a_form: 양식을 제출하도록 초대되었습니다.
|
||||
verification_code_code: '확인 코드: %{code}'
|
||||
signed_on_time: '%{time}에 서명됨'
|
||||
form_has_been_submitted_already: 양식이 이미 제출되었습니다.
|
||||
send_copy_to_email: 이메일로 사본 보내기
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddArchivedAtToAccounts < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :accounts, :archived_at, :datetime
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PopulateAccountLinkedAccounts < ActiveRecord::Migration[7.1]
|
||||
class MigrationAccount < ApplicationRecord
|
||||
self.table_name = 'accounts'
|
||||
end
|
||||
|
||||
class MigrationAccountLinkedAccount < ApplicationRecord
|
||||
self.table_name = 'account_linked_accounts'
|
||||
end
|
||||
|
||||
def up
|
||||
return if Docuseal.multitenant?
|
||||
|
||||
MigrationAccount.order(:id).each do |account|
|
||||
next if account.id == 1
|
||||
next if MigrationAccountLinkedAccount.exists?(linked_account_id: account.id)
|
||||
|
||||
MigrationAccountLinkedAccount.create!(account_id: 1,
|
||||
linked_account_id: account.id,
|
||||
account_type: :linked)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
nil
|
||||
end
|
||||
end
|
||||
+2
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_04_16_170023) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_04_28_112400) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -52,6 +52,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_16_170023) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "uuid", null: false
|
||||
t.datetime "archived_at"
|
||||
t.index ["uuid"], name: "index_accounts_on_uuid", unique: true
|
||||
end
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ module Submissions
|
||||
composer.column(columns: 1) do |column|
|
||||
add_logo(column, submission)
|
||||
|
||||
column.text(account.linked_account_account&.testing? ? 'Testing Log - Not for Production Use' : 'Audit Log',
|
||||
column.text(account.testing? ? 'Testing Log - Not for Production Use' : 'Audit Log',
|
||||
font_size: 16,
|
||||
padding: [10, 0, 0, 0],
|
||||
position: :float, text_align: :right)
|
||||
|
||||
@@ -17,6 +17,7 @@ module Submissions
|
||||
|
||||
TEXT_LEFT_MARGIN = 1
|
||||
TEXT_TOP_MARGIN = 1
|
||||
MAX_PAGE_ROTATE = 20
|
||||
|
||||
A4_SIZE = [595, 842].freeze
|
||||
SUPPORTED_IMAGE_TYPES = ['image/png', 'image/jpeg'].freeze
|
||||
@@ -43,12 +44,16 @@ module Submissions
|
||||
|
||||
template = submitter.submission.template
|
||||
|
||||
is_flatten =
|
||||
submitter.account.account_configs
|
||||
.find_or_initialize_by(key: AccountConfig::FLATTEN_RESULT_PDF_KEY).value != false
|
||||
|
||||
account = submitter.account
|
||||
pkcs = Accounts.load_signing_pkcs(account)
|
||||
tsa_url = Accounts.load_timeserver_url(account)
|
||||
attachments_data_cache = {}
|
||||
|
||||
pdfs_index = build_pdfs_index(submitter)
|
||||
pdfs_index = build_pdfs_index(submitter, flatten: is_flatten)
|
||||
|
||||
submitter.submission.template_fields.each do |field|
|
||||
next if field['submitter_uuid'] != submitter.uuid
|
||||
@@ -85,10 +90,12 @@ module Submissions
|
||||
|
||||
next if Array.wrap(value).compact_blank.blank?
|
||||
|
||||
begin
|
||||
page.flatten_annotations
|
||||
rescue StandardError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
if is_flatten
|
||||
begin
|
||||
page.flatten_annotations
|
||||
rescue StandardError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
end
|
||||
end
|
||||
|
||||
canvas = page.canvas(type: :overlay)
|
||||
@@ -140,17 +147,22 @@ module Submissions
|
||||
attachment_uuid = Array.wrap(value)[acc]
|
||||
attachment = submitter.attachments.find { |a| a.uuid == attachment_uuid }
|
||||
|
||||
next_index =
|
||||
lines[(index + 1)..].index { |l| l.items.first.is_a?(HexaPDF::Layout::InlineBox) } || (lines.size - 1)
|
||||
next_index = lines[(index + 1)..].index { |l| l.items.first.is_a?(HexaPDF::Layout::InlineBox) }
|
||||
next_index += index if next_index
|
||||
next_index ||= lines.size - 1
|
||||
|
||||
diff = ((area['h'] * height) / 2) - (lines.sum(&:height) / 2)
|
||||
|
||||
page[:Annots] << pdf.add(
|
||||
{
|
||||
Type: :Annot, Subtype: :Link,
|
||||
Rect: [
|
||||
(area['x'] * width) + TEXT_LEFT_MARGIN,
|
||||
height - (area['y'] * height) - lines[...index].sum(&:height) + height_diff,
|
||||
height - (area['y'] * height) - lines[...index].sum(&:height) +
|
||||
height_diff - (height_diff.zero? ? diff : 0),
|
||||
(area['x'] * width) + (area['w'] * width) + TEXT_LEFT_MARGIN,
|
||||
height - (area['y'] * height) - lines[..next_index].sum(&:height) + height_diff
|
||||
height - (area['y'] * height) - lines[..next_index].sum(&:height) +
|
||||
height_diff - (height_diff.zero? ? diff : 0)
|
||||
],
|
||||
A: { Type: :Action, S: :URI,
|
||||
URI: ActiveStorage::Blob.proxy_url(attachment.blob) }
|
||||
@@ -334,7 +346,7 @@ module Submissions
|
||||
Digest::UUID.uuid_v5(Digest::UUID::OID_NAMESPACE, attachments.map(&:uuid).sort.join(':'))
|
||||
end
|
||||
|
||||
def build_pdfs_index(submitter)
|
||||
def build_pdfs_index(submitter, flatten: true)
|
||||
latest_submitter = find_last_submitter(submitter)
|
||||
|
||||
Submissions::EnsureResultGenerated.call(latest_submitter) if latest_submitter
|
||||
@@ -350,10 +362,14 @@ module Submissions
|
||||
HexaPDF::Document.new(io: StringIO.new(attachment.download))
|
||||
end
|
||||
|
||||
begin
|
||||
pdf.acro_form&.flatten
|
||||
rescue StandardError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
pdf = maybe_rotate_pdf(pdf)
|
||||
|
||||
if flatten
|
||||
begin
|
||||
pdf.acro_form&.flatten
|
||||
rescue StandardError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
end
|
||||
end
|
||||
|
||||
pdf.config['font.on_missing_glyph'] = method(:on_missing_glyph).to_proc
|
||||
@@ -362,6 +378,26 @@ module Submissions
|
||||
end
|
||||
end
|
||||
|
||||
def maybe_rotate_pdf(pdf)
|
||||
return pdf if pdf.pages.size > MAX_PAGE_ROTATE
|
||||
|
||||
is_rotated = pdf.pages.filter_map do |page|
|
||||
page.rotate(0, flatten: true) if page[:Rotate] != 0
|
||||
end.present?
|
||||
|
||||
return pdf unless is_rotated
|
||||
|
||||
io = StringIO.new
|
||||
|
||||
pdf.write(io, incremental: false, validate: false)
|
||||
|
||||
HexaPDF::Document.new(io:)
|
||||
rescue StandardError => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
|
||||
pdf
|
||||
end
|
||||
|
||||
def on_missing_glyph(character, font_wrapper)
|
||||
Rollbar.error("Missing glyph: #{character}") if character.present? && defined?(Rollbar)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ module Submissions
|
||||
|
||||
submitter_params[:fields]&.each do |f|
|
||||
default_values[f[:name].presence || f[:uuid]] = f[:default_value] if f.key?(:default_value)
|
||||
default_values[f[:name].presence || f[:uuid]] = f[:value] if f.key?(:value)
|
||||
end
|
||||
|
||||
return submitter_params if default_values.blank?
|
||||
|
||||
@@ -2,38 +2,44 @@
|
||||
|
||||
module Submitters
|
||||
module SerializeForApi
|
||||
SERIALIZE_PARAMS = {
|
||||
only: %i[id slug uuid name email phone completed_at external_id
|
||||
submission_id metadata opened_at sent_at created_at updated_at],
|
||||
methods: %i[status application_key]
|
||||
}.freeze
|
||||
|
||||
module_function
|
||||
|
||||
def call(submitter, with_template: false, with_events: false)
|
||||
def call(submitter, with_template: false, with_events: false, with_documents: true, with_urls: false)
|
||||
ActiveRecord::Associations::Preloader.new(
|
||||
records: [submitter],
|
||||
associations: [documents_attachments: :blob, attachments_attachments: :blob]
|
||||
associations: if with_documents
|
||||
[documents_attachments: :blob, attachments_attachments: :blob]
|
||||
else
|
||||
[attachments_attachments: :blob]
|
||||
end
|
||||
).call
|
||||
|
||||
values = SerializeForWebhook.build_values_array(submitter)
|
||||
documents = SerializeForWebhook.build_documents_array(submitter)
|
||||
additional_attrs = {}
|
||||
|
||||
submitter_name = (submitter.submission.template_submitters ||
|
||||
submitter.submission.template.submitters).find { |e| e['uuid'] == submitter.uuid }['name']
|
||||
additional_attrs['values'] = SerializeForWebhook.build_values_array(submitter)
|
||||
additional_attrs['documents'] = SerializeForWebhook.build_documents_array(submitter) if with_documents
|
||||
additional_attrs['preferences'] = submitter.preferences.except('default_values')
|
||||
|
||||
serialize_params = {
|
||||
include: {},
|
||||
only: %i[id slug uuid name email phone completed_at external_id
|
||||
submission_id metadata opened_at sent_at created_at updated_at],
|
||||
methods: %i[status application_key]
|
||||
}
|
||||
additional_attrs['role'] =
|
||||
(submitter.submission.template_submitters ||
|
||||
submitter.submission.template.submitters).find { |e| e['uuid'] == submitter.uuid }['name']
|
||||
|
||||
serialize_params[:include][:template] = { only: %i[id name created_at updated_at] } if with_template
|
||||
|
||||
if with_events
|
||||
serialize_params[:include][:submission_events] =
|
||||
{ as: :events, only: %i[id submitter_id event_type event_timestamp] }
|
||||
if with_urls
|
||||
additional_attrs['embed_src'] =
|
||||
Rails.application.routes.url_helpers.submit_form_url(slug: submitter.slug, **Docuseal.default_url_options)
|
||||
end
|
||||
|
||||
submitter.as_json(serialize_params)
|
||||
.merge('values' => values,
|
||||
'documents' => documents,
|
||||
'role' => submitter_name)
|
||||
include_params = {}
|
||||
include_params[:template] = { only: %i[id name created_at updated_at] } if with_template
|
||||
include_params[:submission_events] = { only: %i[id submitter_id event_type event_timestamp] } if with_events
|
||||
|
||||
submitter.as_json(SERIALIZE_PARAMS.merge(include: include_params)).merge(additional_attrs)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
module Submitters
|
||||
module SerializeForWebhook
|
||||
SERIALIZE_PARAMS = {
|
||||
methods: %i[status application_key],
|
||||
only: %i[id submission_id email phone name ua ip sent_at opened_at
|
||||
completed_at created_at updated_at external_id metadata]
|
||||
}.freeze
|
||||
|
||||
module_function
|
||||
|
||||
def call(submitter)
|
||||
@@ -16,10 +22,7 @@ module Submitters
|
||||
submitter_name = (submitter.submission.template_submitters ||
|
||||
submitter.submission.template.submitters).find { |e| e['uuid'] == submitter.uuid }['name']
|
||||
|
||||
submitter.as_json(methods: %i[status application_key],
|
||||
only: %i[id submission_id email phone name ua ip sent_at opened_at
|
||||
completed_at created_at updated_at external_id metadata])
|
||||
.except('uuid', 'values', 'slug')
|
||||
submitter.as_json(SERIALIZE_PARAMS)
|
||||
.merge('role' => submitter_name,
|
||||
'preferences' => submitter.preferences.except('default_values'),
|
||||
'values' => values,
|
||||
|
||||
+22
-4
@@ -4,10 +4,9 @@ module Templates
|
||||
module Clone
|
||||
module_function
|
||||
|
||||
# rubocop:disable Metrics
|
||||
def call(original_template, author:, external_id: nil, name: nil, folder_name: nil)
|
||||
original_template_account = original_template.account
|
||||
|
||||
template = original_template_account.templates.new
|
||||
template = original_template.account.templates.new
|
||||
|
||||
template.external_id = external_id
|
||||
template.author = author
|
||||
@@ -19,6 +18,7 @@ module Templates
|
||||
template.folder = TemplateFolders.find_or_create_by_name(author, folder_name) if folder_name.present?
|
||||
|
||||
submitter_uuids_replacements = {}
|
||||
field_uuids_replacements = {}
|
||||
|
||||
cloned_submitters = original_template['submitters'].deep_dup
|
||||
cloned_fields = original_template['fields'].deep_dup
|
||||
@@ -31,13 +31,31 @@ module Templates
|
||||
end
|
||||
|
||||
cloned_fields.each do |field|
|
||||
field['uuid'] = SecureRandom.uuid
|
||||
new_field_uuid = SecureRandom.uuid
|
||||
|
||||
field_uuids_replacements[field['uuid']] = new_field_uuid
|
||||
field['uuid'] = new_field_uuid
|
||||
|
||||
field['submitter_uuid'] = submitter_uuids_replacements[field['submitter_uuid']]
|
||||
end
|
||||
|
||||
replace_fields_regexp = Regexp.union(field_uuids_replacements.keys)
|
||||
|
||||
cloned_fields.each do |field|
|
||||
Array.wrap(field['conditions']).each do |condition|
|
||||
condition['field_uuid'] = field_uuids_replacements[condition['field_uuid']]
|
||||
end
|
||||
|
||||
if field.dig('preferences', 'formula').present?
|
||||
field['preferences']['formula'] =
|
||||
field['preferences']['formula'].gsub(replace_fields_regexp, field_uuids_replacements)
|
||||
end
|
||||
end
|
||||
|
||||
template.assign_attributes(fields: cloned_fields, submitters: cloned_submitters)
|
||||
|
||||
template
|
||||
end
|
||||
# rubocop:enable Metrics
|
||||
end
|
||||
end
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
module Templates
|
||||
module SerializeForApi
|
||||
SERIALIZE_PARAMS = {
|
||||
methods: %i[application_key folder_name],
|
||||
include: { author: { only: %i[id email first_name last_name] } }
|
||||
}.freeze
|
||||
|
||||
module_function
|
||||
|
||||
def call(template, schema_documents = template.schema_documents, preview_image_attachments = [])
|
||||
json = template.as_json(
|
||||
methods: %i[application_key folder_name],
|
||||
include: { author: { only: %i[id email first_name last_name] } }
|
||||
)
|
||||
json = template.as_json(SERIALIZE_PARAMS)
|
||||
|
||||
json[:documents] = template.schema.map do |item|
|
||||
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
|
||||
|
||||
Reference in new issue
Block a user