mirror of
https://github.com/docusealco/docuseal
synced 2026-11-05 14:42:33 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
202943f58d | ||
|
|
6dd15b2091 | ||
|
|
1c55e4f18b | ||
|
|
6cc36b1728 | ||
|
|
37751cd5c1 | ||
|
|
80d882cd20 | ||
|
|
8bef75e570 | ||
|
|
077eab7005 | ||
|
|
715c70d422 | ||
|
|
a3c23f9d53 | ||
|
|
c1e67a8af0 | ||
|
|
2fdc294293 | ||
|
|
1f49ba069e | ||
|
|
43ef0fc0d0 | ||
|
|
a1a920e536 | ||
|
|
dec33b4331 | ||
|
|
432f290633 | ||
|
|
cf98616a27 | ||
|
|
1a720cf1ad | ||
|
|
557c6c34f2 | ||
|
|
943c76505d | ||
|
|
66eb83e6a7 | ||
|
|
0844427357 | ||
|
|
72e9d9ea2d | ||
|
|
3db7d47746 | ||
|
|
95899336b8 | ||
|
|
f6691c110e | ||
|
|
749722a9df | ||
|
|
265b668cb4 | ||
|
|
0527e6a5c1 | ||
|
|
d989b61d19 | ||
|
|
c1f3e6ff13 | ||
|
|
3c0fff2d82 | ||
|
|
bd599c264f | ||
|
|
0274093c89 | ||
|
|
5845b5bdfd | ||
|
|
3dd0ba6b0b | ||
|
|
e79306f8a3 | ||
|
|
0171b0c2dd | ||
|
|
a963ef53d3 | ||
|
|
344f302c76 | ||
|
|
17ded282b2 | ||
|
|
2ce57df485 | ||
|
|
849289287e | ||
|
|
704fbc2393 | ||
|
|
168fc8bd03 | ||
|
|
c5598d9efe |
No files matched your search
+7
-5
@@ -2,7 +2,9 @@ FROM ruby:3.2.2-alpine3.18 as fonts
|
|||||||
|
|
||||||
WORKDIR /fonts
|
WORKDIR /fonts
|
||||||
|
|
||||||
RUN apk --no-cache add wget && wget https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf && wget https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Bold.ttf && wget https://github.com/impallari/DancingScript/raw/master/fonts/DancingScript-Regular.otf && wget https://github.com/impallari/DancingScript/raw/master/OFL.txt
|
RUN apk --no-cache add fontforge wget && wget https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Regular.ttf && wget https://github.com/satbyy/go-noto-universal/releases/download/v7.0/GoNotoKurrent-Bold.ttf && wget https://github.com/impallari/DancingScript/raw/master/fonts/DancingScript-Regular.otf && wget https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSansSymbols2/hinted/ttf/NotoSansSymbols2-Regular.ttf && wget https://github.com/Maxattax97/gnu-freefont/raw/master/ttf/FreeSans.ttf && wget https://github.com/impallari/DancingScript/raw/master/OFL.txt
|
||||||
|
|
||||||
|
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.2.2-alpine3.18 as webpack
|
||||||
|
|
||||||
@@ -34,15 +36,14 @@ FROM ruby:3.2.2-alpine3.18 as app
|
|||||||
|
|
||||||
ENV RAILS_ENV=production
|
ENV RAILS_ENV=production
|
||||||
ENV BUNDLE_WITHOUT="development:test"
|
ENV BUNDLE_WITHOUT="development:test"
|
||||||
ENV PIDFILE=/dev/null
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN apk add --no-cache build-base sqlite-dev libpq-dev mariadb-dev vips-dev vips-poppler poppler-utils vips-heif libc6-compat ttf-freefont && mkdir /fonts
|
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
|
||||||
|
|
||||||
COPY ./Gemfile ./Gemfile.lock ./
|
COPY ./Gemfile ./Gemfile.lock ./
|
||||||
|
|
||||||
RUN bundle update --bundler && bundle install && 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 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
|
||||||
|
|
||||||
COPY ./bin ./bin
|
COPY ./bin ./bin
|
||||||
COPY ./app ./app
|
COPY ./app ./app
|
||||||
@@ -55,6 +56,7 @@ COPY ./tmp ./tmp
|
|||||||
COPY LICENSE README.md Rakefile config.ru .version ./
|
COPY LICENSE README.md Rakefile config.ru .version ./
|
||||||
|
|
||||||
COPY --from=fonts /fonts/GoNotoKurrent-Regular.ttf /fonts/GoNotoKurrent-Bold.ttf /fonts/DancingScript-Regular.otf /fonts/OFL.txt /fonts
|
COPY --from=fonts /fonts/GoNotoKurrent-Regular.ttf /fonts/GoNotoKurrent-Bold.ttf /fonts/DancingScript-Regular.otf /fonts/OFL.txt /fonts
|
||||||
|
COPY --from=fonts /fonts/FreeSans.ttf /usr/share/fonts/freefont
|
||||||
COPY --from=webpack /app/public/packs ./public/packs
|
COPY --from=webpack /app/public/packs ./public/packs
|
||||||
|
|
||||||
RUN ln -s /fonts /app/public/fonts
|
RUN ln -s /fonts /app/public/fonts
|
||||||
@@ -64,4 +66,4 @@ WORKDIR /data/docuseal
|
|||||||
ENV WORKDIR=/data/docuseal
|
ENV WORKDIR=/data/docuseal
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["/app/bin/rails", "server"]
|
CMD ["/app/bin/bundle", "exec", "puma", "-C", "/app/config/puma.rb", "--dir", "/app"]
|
||||||
@@ -51,11 +51,12 @@ DocuSeal is an open source platform that provides secure and efficient digital d
|
|||||||
- User roles
|
- User roles
|
||||||
- Automated reminders
|
- Automated reminders
|
||||||
- Invitation and identify verification via SMS
|
- Invitation and identify verification via SMS
|
||||||
|
- Conditional fields and formulas
|
||||||
- SSO / SAML
|
- SSO / SAML
|
||||||
- Template creation with HTML API ([Guide](https://www.docuseal.co/guides/create-pdf-document-fillable-form-with-html-api))
|
- Template creation with HTML API ([Guide](https://www.docuseal.co/guides/create-pdf-document-fillable-form-with-html-api))
|
||||||
- Template creation with PDF or DOCX and field tags API ([Guide](https://www.docuseal.co/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form))
|
- Template creation with PDF or DOCX and field tags API ([Guide](https://www.docuseal.co/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form))
|
||||||
- Embedded signing form ([React](https://github.com/docusealco/docuseal-react), [Vue](https://github.com/docusealco/docuseal-vue) or [JavaScript](https://www.docuseal.co/docs/embedded))
|
- Embedded signing form ([React](https://github.com/docusealco/docuseal-react), [Vue](https://github.com/docusealco/docuseal-vue), [Angular](https://github.com/docusealco/docuseal-angular) or [JavaScript](https://www.docuseal.co/docs/embedded))
|
||||||
- Embedded document form builder ([React](https://github.com/docusealco/docuseal-react), [Vue](https://github.com/docusealco/docuseal-vue) or [JavaScript](https://www.docuseal.co/docs/embedded))
|
- Embedded document form builder ([React](https://github.com/docusealco/docuseal-react), [Vue](https://github.com/docusealco/docuseal-vue), [Angular](https://github.com/docusealco/docuseal-angular) or [JavaScript](https://www.docuseal.co/docs/embedded))
|
||||||
- [Learn more](https://www.docuseal.co/pricing)
|
- [Learn more](https://www.docuseal.co/pricing)
|
||||||
|
|
||||||
## Deploy
|
## Deploy
|
||||||
@@ -65,9 +66,6 @@ DocuSeal is an open source platform that provides secure and efficient digital d
|
|||||||
| [<img alt="Deploy on Heroku" src="https://www.herokucdn.com/deploy/button.svg" height="40">](https://heroku.com/deploy?template=https://github.com/docusealco/docuseal-heroku) | [<img alt="Deploy on Railway" src="https://railway.app/button.svg" height="40">](https://railway.app/template/IGoDnc?referralCode=ruU7JR)|
|
| [<img alt="Deploy on Heroku" src="https://www.herokucdn.com/deploy/button.svg" height="40">](https://heroku.com/deploy?template=https://github.com/docusealco/docuseal-heroku) | [<img alt="Deploy on Railway" src="https://railway.app/button.svg" height="40">](https://railway.app/template/IGoDnc?referralCode=ruU7JR)|
|
||||||
|**DigitalOcean**|**Render**|
|
|**DigitalOcean**|**Render**|
|
||||||
| [<img alt="Deploy on DigitalOcean" src="https://www.deploytodo.com/do-btn-blue.svg" height="40">](https://cloud.digitalocean.com/apps/new?repo=https://github.com/docusealco/docuseal-digitalocean/tree/master&refcode=421d50f53990) | [<img alt="Deploy to Render" src="https://render.com/images/deploy-to-render-button.svg" height="40">](https://render.com/deploy?repo=https://github.com/docusealco/docuseal-render)
|
| [<img alt="Deploy on DigitalOcean" src="https://www.deploytodo.com/do-btn-blue.svg" height="40">](https://cloud.digitalocean.com/apps/new?repo=https://github.com/docusealco/docuseal-digitalocean/tree/master&refcode=421d50f53990) | [<img alt="Deploy to Render" src="https://render.com/images/deploy-to-render-button.svg" height="40">](https://render.com/deploy?repo=https://github.com/docusealco/docuseal-render)
|
||||||
|**Koyeb**|**Elestio**|
|
|
||||||
| [<img alt="Deploy on Koyeb" src="https://www.koyeb.com/static/images/deploy/button.svg" height="40">](https://app.koyeb.com/deploy?name=docuseal&type=docker&image=docker.io/docuseal/docuseal&env[PORT]=8000&env[DATABASE_URL]=CHANGE_ME&env[SECRET_KEY_BASE]=CHANGE_ME&ports=8000;http;/) | [<img alt="Deploy on Elestio" src="https://pub-da36157c854648669813f3f76c526c2b.r2.dev/deploy-on-elestio-black.png">](https://dash.elest.io/deploy?soft=DocuSeal&id=339) |
|
|
||||||
|
|
||||||
|
|
||||||
#### Docker
|
#### Docker
|
||||||
|
|
||||||
@@ -100,3 +98,9 @@ At DocuSeal we have expertise and technologies to make documents creation, filli
|
|||||||
|
|
||||||
Distributed under the AGPLv3 License. See [LICENSE](https://github.com/docusealco/docuseal/blob/master/LICENSE) for more information.
|
Distributed under the AGPLv3 License. See [LICENSE](https://github.com/docusealco/docuseal/blob/master/LICENSE) for more information.
|
||||||
Unless otherwise noted, all files © 2023 DocuSeal LLC.
|
Unless otherwise noted, all files © 2023 DocuSeal LLC.
|
||||||
|
|
||||||
|
## Tools
|
||||||
|
|
||||||
|
- [Signature Maker](https://www.docuseal.co/online-signature)
|
||||||
|
- [Sign Document Online](https://www.docuseal.co/sign-documents-online)
|
||||||
|
- [Fill PDF Online](https://www.docuseal.co/fill-pdf)
|
||||||
@@ -19,10 +19,14 @@ module Api
|
|||||||
render json: { error: e.message }, status: :unprocessable_entity
|
render json: { error: e.message }, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from RateLimit::LimitApproached do |e|
|
||||||
|
Rollbar.error(e) if defined?(Rollbar)
|
||||||
|
|
||||||
|
render json: { error: 'Too many requests' }, status: :too_many_requests
|
||||||
|
end
|
||||||
|
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
rescue_from CanCan::AccessDenied do |e|
|
rescue_from CanCan::AccessDenied do |e|
|
||||||
Rollbar.warning(e) if defined?(Rollbar)
|
|
||||||
|
|
||||||
render json: { error: e.message }, status: :forbidden
|
render json: { error: e.message }, status: :forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -161,11 +161,11 @@ module Api
|
|||||||
|
|
||||||
def submissions_params
|
def submissions_params
|
||||||
permitted_attrs = [
|
permitted_attrs = [
|
||||||
:send_email, :send_sms, :bcc_completed, :completed_redirect_url,
|
:send_email, :send_sms, :bcc_completed, :completed_redirect_url, :reply_to,
|
||||||
{
|
{
|
||||||
message: %i[subject body],
|
message: %i[subject body],
|
||||||
submitters: [[:send_email, :send_sms, :completed_redirect_url, :uuid, :name, :email, :role,
|
submitters: [[:send_email, :send_sms, :completed_redirect_url, :uuid, :name, :email, :role,
|
||||||
:completed, :phone, :application_key, :external_id,
|
:completed, :phone, :application_key, :external_id, :reply_to,
|
||||||
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
||||||
fields: [%i[name default_value title description
|
fields: [%i[name default_value title description
|
||||||
readonly validation_pattern invalid_message]] }]]
|
readonly validation_pattern invalid_message]] }]]
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Api
|
|
||||||
class SubmittersAutocompleteController < ApiBaseController
|
|
||||||
load_and_authorize_resource :submitter, parent: false
|
|
||||||
|
|
||||||
SELECT_COLUMNS = %w[email phone name].freeze
|
|
||||||
LIMIT = 100
|
|
||||||
|
|
||||||
def index
|
|
||||||
submitters = search_submitters(@submitters)
|
|
||||||
|
|
||||||
values = submitters.limit(LIMIT).group(SELECT_COLUMNS.join(', ')).pluck(SELECT_COLUMNS.join(', '))
|
|
||||||
|
|
||||||
attrs = values.map { |row| SELECT_COLUMNS.zip(row).to_h }
|
|
||||||
attrs = attrs.uniq { |e| e[params[:field]] } if params[:field].present?
|
|
||||||
|
|
||||||
render json: attrs
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def search_submitters(submitters)
|
|
||||||
if SELECT_COLUMNS.include?(params[:field])
|
|
||||||
column = Submitter.arel_table[params[:field].to_sym]
|
|
||||||
|
|
||||||
term = "#{params[:q].downcase}%"
|
|
||||||
|
|
||||||
submitters.where(column.matches(term, false, true))
|
|
||||||
else
|
|
||||||
Submitters.search(submitters, params[:q])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Api
|
|
||||||
class TemplateFoldersAutocompleteController < ApiBaseController
|
|
||||||
load_and_authorize_resource :template_folder, parent: false
|
|
||||||
|
|
||||||
LIMIT = 100
|
|
||||||
|
|
||||||
def index
|
|
||||||
template_folders = @template_folders.joins(:templates).where(templates: { archived_at: nil }).distinct
|
|
||||||
template_folders = TemplateFolders.search(template_folders, params[:q]).limit(LIMIT)
|
|
||||||
|
|
||||||
render json: template_folders.as_json(only: %i[name archived_at])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -49,6 +49,14 @@ module Api
|
|||||||
@template.folder = TemplateFolders.find_or_create_by_name(current_user, folder_name)
|
@template.folder = TemplateFolders.find_or_create_by_name(current_user, folder_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Array.wrap(params[:roles].presence || params.dig(:template, :roles).presence).each_with_index do |role, index|
|
||||||
|
if (item = @template.submitters[index])
|
||||||
|
item['name'] = role
|
||||||
|
else
|
||||||
|
@template.submitters << { 'name' => role, 'uuid' => SecureRandom.uuid }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
archived = params.key?(:archived) ? params[:archived] : params.dig(:template, :archived)
|
archived = params.key?(:archived) ? params[:archived] : params.dig(:template, :archived)
|
||||||
|
|
||||||
if archived.in?([true, false])
|
if archived.in?([true, false])
|
||||||
@@ -83,23 +91,10 @@ module Api
|
|||||||
end
|
end
|
||||||
|
|
||||||
def template_params
|
def template_params
|
||||||
permit_params = [
|
|
||||||
:name,
|
|
||||||
{ schema: [%i[attachment_uuid name]],
|
|
||||||
submitters: [%i[name uuid]],
|
|
||||||
fields: [[:uuid, :submitter_uuid, :name, :type,
|
|
||||||
:required, :readonly, :default_value,
|
|
||||||
:title, :description,
|
|
||||||
{ preferences: {},
|
|
||||||
conditions: [%i[field_uuid value action]],
|
|
||||||
options: [%i[value uuid]],
|
|
||||||
areas: [%i[x y w h cell_w attachment_uuid option_uuid page]] }]] }
|
|
||||||
]
|
|
||||||
|
|
||||||
if params.key?(:template)
|
if params.key?(:template)
|
||||||
params.require(:template).permit(*permit_params)
|
params.require(:template).permit(:name, submitters: [%i[name uuid]])
|
||||||
else
|
else
|
||||||
params.permit(*permit_params)
|
params.permit(:name, submitters: [%i[name uuid]])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Api
|
|
||||||
class TemplatesDocumentsController < ApiBaseController
|
|
||||||
load_and_authorize_resource :template
|
|
||||||
|
|
||||||
def create
|
|
||||||
return head :unprocessable_entity if params[:blobs].blank? && params[:files].blank?
|
|
||||||
|
|
||||||
documents = Templates::CreateAttachments.call(@template, params)
|
|
||||||
|
|
||||||
schema = documents.map do |doc|
|
|
||||||
{ attachment_uuid: doc.uuid, name: doc.filename.base }
|
|
||||||
end
|
|
||||||
|
|
||||||
render json: {
|
|
||||||
schema:,
|
|
||||||
documents: documents.as_json(
|
|
||||||
methods: %i[metadata signed_uuid],
|
|
||||||
include: {
|
|
||||||
preview_images: { methods: %i[url metadata filename] }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
rescue Templates::CreateAttachments::PdfEncrypted
|
|
||||||
render json: { error: 'PDF encrypted' }, status: :unprocessable_entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -22,6 +22,12 @@ class ApplicationController < ActionController::Base
|
|||||||
redirect_to request.path
|
redirect_to request.path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rescue_from RateLimit::LimitApproached do |e|
|
||||||
|
Rollbar.error(e) if defined?(Rollbar)
|
||||||
|
|
||||||
|
redirect_to request.referer, alert: 'Too many requests', status: :too_many_requests
|
||||||
|
end
|
||||||
|
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
rescue_from CanCan::AccessDenied do |e|
|
rescue_from CanCan::AccessDenied do |e|
|
||||||
Rollbar.warning(e) if defined?(Rollbar)
|
Rollbar.warning(e) if defined?(Rollbar)
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ class ConsoleRedirectController < ApplicationController
|
|||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
if request.path == '/upgrade'
|
||||||
|
params[:redir] = Docuseal.multitenant? ? "#{Docuseal::CONSOLE_URL}/plans" : "#{Docuseal::CONSOLE_URL}/on_premise"
|
||||||
|
end
|
||||||
|
|
||||||
return redirect_to(new_user_session_path({ redir: params[:redir] }.compact)) if true_user.blank?
|
return redirect_to(new_user_session_path({ redir: params[:redir] }.compact)) if true_user.blank?
|
||||||
|
|
||||||
auth = JsonWebToken.encode(uuid: true_user.uuid,
|
auth = JsonWebToken.encode(uuid: true_user.uuid,
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class SendSubmissionEmailController < ApplicationController
|
|||||||
Submitter.find_by!(slug: params[:submitter_slug])
|
Submitter.find_by!(slug: params[:submitter_slug])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RateLimit.call("send-email-#{@submitter.id}", limit: 2, ttl: 5.minutes)
|
||||||
|
|
||||||
SubmitterMailer.documents_copy_email(@submitter, sig: true).deliver_later!
|
SubmitterMailer.documents_copy_email(@submitter, sig: true).deliver_later!
|
||||||
|
|
||||||
respond_to do |f|
|
respond_to do |f|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SubmittersAutocompleteController < ApplicationController
|
||||||
|
load_and_authorize_resource :submitter, parent: false
|
||||||
|
|
||||||
|
SELECT_COLUMNS = %w[email phone name].freeze
|
||||||
|
LIMIT = 100
|
||||||
|
|
||||||
|
def index
|
||||||
|
submitters = search_submitters(@submitters)
|
||||||
|
|
||||||
|
values = submitters.limit(LIMIT).group(SELECT_COLUMNS.join(', ')).pluck(SELECT_COLUMNS.join(', '))
|
||||||
|
|
||||||
|
attrs = values.map { |row| SELECT_COLUMNS.zip(row).to_h }
|
||||||
|
attrs = attrs.uniq { |e| e[params[:field]] } if params[:field].present?
|
||||||
|
|
||||||
|
render json: attrs
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def search_submitters(submitters)
|
||||||
|
if SELECT_COLUMNS.include?(params[:field])
|
||||||
|
column = Submitter.arel_table[params[:field].to_sym]
|
||||||
|
|
||||||
|
term = "#{params[:q].downcase}%"
|
||||||
|
|
||||||
|
submitters.where(column.matches(term, false, true))
|
||||||
|
else
|
||||||
|
Submitters.search(submitters, params[:q])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class TemplateDocumentsController < ApplicationController
|
||||||
|
load_and_authorize_resource :template
|
||||||
|
|
||||||
|
def create
|
||||||
|
return head :unprocessable_entity if params[:blobs].blank? && params[:files].blank?
|
||||||
|
|
||||||
|
documents = Templates::CreateAttachments.call(@template, params)
|
||||||
|
|
||||||
|
schema = documents.map do |doc|
|
||||||
|
{ attachment_uuid: doc.uuid, name: doc.filename.base }
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: {
|
||||||
|
schema:,
|
||||||
|
documents: documents.as_json(
|
||||||
|
methods: %i[metadata signed_uuid],
|
||||||
|
include: {
|
||||||
|
preview_images: { methods: %i[url metadata filename] }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
rescue Templates::CreateAttachments::PdfEncrypted
|
||||||
|
render json: { error: 'PDF encrypted' }, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class TemplateFoldersAutocompleteController < ApplicationController
|
||||||
|
load_and_authorize_resource :template_folder, parent: false
|
||||||
|
|
||||||
|
LIMIT = 100
|
||||||
|
|
||||||
|
def index
|
||||||
|
template_folders = @template_folders.joins(:templates).where(templates: { archived_at: nil }).distinct
|
||||||
|
template_folders = TemplateFolders.search(template_folders, params[:q]).limit(LIMIT)
|
||||||
|
|
||||||
|
render json: template_folders.as_json(only: %i[name archived_at])
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -6,7 +6,7 @@ class TemplatesArchivedSubmissionsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@submissions = @submissions.where.not(archived_at: nil)
|
@submissions = @submissions.where.not(archived_at: nil)
|
||||||
@submissions = Submissions.search(@submissions, params[:q])
|
@submissions = Submissions.search(@submissions, params[:q], search_values: true)
|
||||||
|
|
||||||
@pagy, @submissions = pagy(@submissions.preload(:submitters).order(id: :desc))
|
@pagy, @submissions = pagy(@submissions.preload(:submitters).order(id: :desc))
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class TemplatesController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
submissions = @template.submissions.accessible_by(current_ability)
|
submissions = @template.submissions.accessible_by(current_ability)
|
||||||
submissions = submissions.active if @template.archived_at.blank?
|
submissions = submissions.active if @template.archived_at.blank?
|
||||||
submissions = Submissions.search(submissions, params[:q])
|
submissions = Submissions.search(submissions, params[:q], search_values: true)
|
||||||
|
|
||||||
@base_submissions = submissions
|
@base_submissions = submissions
|
||||||
|
|
||||||
@@ -67,6 +67,12 @@ class TemplatesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@template.update!(template_params)
|
||||||
|
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
notice =
|
notice =
|
||||||
if params[:permanently].present?
|
if params[:permanently].present?
|
||||||
@@ -86,6 +92,22 @@ class TemplatesController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def template_params
|
||||||
|
params.require(:template).permit(
|
||||||
|
:name,
|
||||||
|
{ schema: [%i[attachment_uuid name]],
|
||||||
|
submitters: [%i[name uuid]],
|
||||||
|
fields: [[:uuid, :submitter_uuid, :name, :type,
|
||||||
|
:required, :readonly, :default_value,
|
||||||
|
:title, :description,
|
||||||
|
{ preferences: {},
|
||||||
|
conditions: [%i[field_uuid value action]],
|
||||||
|
options: [%i[value uuid]],
|
||||||
|
validation: %i[message pattern],
|
||||||
|
areas: [%i[x y w h cell_w attachment_uuid option_uuid page]] }]] }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def authorized_clone_account_id?(account_id)
|
def authorized_clone_account_id?(account_id)
|
||||||
true_user.account_id.to_s == account_id.to_s || true_user.account.linked_accounts.exists?(id: account_id)
|
true_user.account_id.to_s == account_id.to_s || true_user.account.linked_accounts.exists?(id: account_id)
|
||||||
end
|
end
|
||||||
@@ -98,10 +120,6 @@ class TemplatesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_params
|
|
||||||
params.require(:template).permit(:name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def load_base_template
|
def load_base_template
|
||||||
return if params[:base_template_id].blank?
|
return if params[:base_template_id].blank?
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import FolderAutocomplete from './elements/folder_autocomplete'
|
|||||||
import SignatureForm from './elements/signature_form'
|
import SignatureForm from './elements/signature_form'
|
||||||
import SubmitForm from './elements/submit_form'
|
import SubmitForm from './elements/submit_form'
|
||||||
import PromptPassword from './elements/prompt_password'
|
import PromptPassword from './elements/prompt_password'
|
||||||
|
import EmailsTextarea from './elements/emails_textarea'
|
||||||
|
|
||||||
import * as TurboInstantClick from './lib/turbo_instant_click'
|
import * as TurboInstantClick from './lib/turbo_instant_click'
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ window.customElements.define('folder-autocomplete', FolderAutocomplete)
|
|||||||
window.customElements.define('signature-form', SignatureForm)
|
window.customElements.define('signature-form', SignatureForm)
|
||||||
window.customElements.define('submit-form', SubmitForm)
|
window.customElements.define('submit-form', SubmitForm)
|
||||||
window.customElements.define('prompt-password', PromptPassword)
|
window.customElements.define('prompt-password', PromptPassword)
|
||||||
|
window.customElements.define('emails-textarea', EmailsTextarea)
|
||||||
|
|
||||||
document.addEventListener('turbo:before-fetch-request', encodeMethodIntoRequestBody)
|
document.addEventListener('turbo:before-fetch-request', encodeMethodIntoRequestBody)
|
||||||
document.addEventListener('turbo:submit-end', async (event) => {
|
document.addEventListener('turbo:submit-end', async (event) => {
|
||||||
@@ -89,6 +91,7 @@ window.customElements.define('template-builder', class extends HTMLElement {
|
|||||||
withPhone: this.dataset.withPhone === 'true',
|
withPhone: this.dataset.withPhone === 'true',
|
||||||
withLogo: this.dataset.withLogo !== 'false',
|
withLogo: this.dataset.withLogo !== 'false',
|
||||||
editable: this.dataset.editable !== 'false',
|
editable: this.dataset.editable !== 'false',
|
||||||
|
authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content,
|
||||||
withPayment: this.dataset.withPayment === 'true',
|
withPayment: this.dataset.withPayment === 'true',
|
||||||
withFormula: this.dataset.withFormula === 'true',
|
withFormula: this.dataset.withFormula === 'true',
|
||||||
withConditions: this.dataset.withConditions === 'true',
|
withConditions: this.dataset.withConditions === 'true',
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
const emailRegexp = /([^@;,<>\s]+@[^@;,<>\s]+)/g
|
||||||
|
|
||||||
|
export default class extends HTMLElement {
|
||||||
|
connectedCallback () {
|
||||||
|
if (this.dataset.limit) {
|
||||||
|
this.textarea.addEventListener('input', () => {
|
||||||
|
const emails = this.textarea.value.match(emailRegexp) || []
|
||||||
|
|
||||||
|
this.updateCounter(emails.length)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCounter (count) {
|
||||||
|
let counter = document.getElementById('emails_counter')
|
||||||
|
let bulkMessage = document.getElementById('bulk_message')
|
||||||
|
|
||||||
|
if (count < 2) {
|
||||||
|
counter?.remove()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((count + 10) > this.dataset.limit) {
|
||||||
|
if (!counter) {
|
||||||
|
counter = document.createElement('span')
|
||||||
|
|
||||||
|
counter.id = 'emails_counter'
|
||||||
|
counter.classList.add('text-xs', 'right-0', 'absolute')
|
||||||
|
counter.style.bottom = '-15px'
|
||||||
|
|
||||||
|
this.textarea.parentNode.append(counter)
|
||||||
|
}
|
||||||
|
|
||||||
|
counter.innerText = `${count} / ${this.dataset.limit}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dataset.bulkEnabled !== 'true') {
|
||||||
|
if (!bulkMessage) {
|
||||||
|
bulkMessage = document.createElement('span')
|
||||||
|
|
||||||
|
bulkMessage.id = 'bulk_message'
|
||||||
|
bulkMessage.classList.add('text-xs', 'left-0', 'absolute')
|
||||||
|
bulkMessage.style.bottom = '-15px'
|
||||||
|
|
||||||
|
this.textarea.parentNode.append(bulkMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
bulkMessage.innerHTML = '<a class="link" data-turbo="false" href="/upgrade">Upgrade</a> to bulk send multiple recipients'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get textarea () {
|
||||||
|
return this.querySelector('textarea')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ export default class extends HTMLElement {
|
|||||||
fetch = (text, resolve) => {
|
fetch = (text, resolve) => {
|
||||||
const queryParams = new URLSearchParams({ q: text })
|
const queryParams = new URLSearchParams({ q: text })
|
||||||
|
|
||||||
fetch('/api/template_folders_autocomplete?' + queryParams).then(async (resp) => {
|
fetch('/template_folders_autocomplete?' + queryParams).then(async (resp) => {
|
||||||
const items = await resp.json()
|
const items = await resp.json()
|
||||||
|
|
||||||
resolve(items)
|
resolve(items)
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ export default class extends HTMLElement {
|
|||||||
|
|
||||||
if (textarea && item[field]) {
|
if (textarea && item[field]) {
|
||||||
textarea.value = textarea.value.replace(/[^;,\s]+$/, item[field] + ' ')
|
textarea.value = textarea.value.replace(/[^;,\s]+$/, item[field] + ' ')
|
||||||
|
|
||||||
|
textarea.dispatchEvent(new Event('input', { bubbles: true }))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -38,7 +40,7 @@ export default class extends HTMLElement {
|
|||||||
if (q) {
|
if (q) {
|
||||||
const queryParams = new URLSearchParams({ q, field: this.dataset.field })
|
const queryParams = new URLSearchParams({ q, field: this.dataset.field })
|
||||||
|
|
||||||
this.currentFetch ||= fetch('/api/submitters_autocomplete?' + queryParams)
|
this.currentFetch ||= fetch('/submitters_autocomplete?' + queryParams)
|
||||||
|
|
||||||
this.currentFetch.then(async (resp) => {
|
this.currentFetch.then(async (resp) => {
|
||||||
const items = await resp.json()
|
const items = await resp.json()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ window.customElements.define('submission-form', class extends HTMLElement {
|
|||||||
attribution: this.dataset.attribution !== 'false',
|
attribution: this.dataset.attribution !== 'false',
|
||||||
withConfetti: this.dataset.withConfetti !== 'false',
|
withConfetti: this.dataset.withConfetti !== 'false',
|
||||||
withTypedSignature: this.dataset.withTypedSignature !== 'false',
|
withTypedSignature: this.dataset.withTypedSignature !== 'false',
|
||||||
|
authenticityToken: document.querySelector('meta[name="csrf-token"]')?.content,
|
||||||
values: reactive(JSON.parse(this.dataset.values)),
|
values: reactive(JSON.parse(this.dataset.values)),
|
||||||
completedButton: JSON.parse(this.dataset.completedButton),
|
completedButton: JSON.parse(this.dataset.completedButton),
|
||||||
completedRedirectUrl: this.dataset.completedRedirectUrl,
|
completedRedirectUrl: this.dataset.completedRedirectUrl,
|
||||||
|
|||||||
@@ -157,6 +157,7 @@
|
|||||||
ref="textContainer"
|
ref="textContainer"
|
||||||
dir="auto"
|
dir="auto"
|
||||||
class="flex items-center px-0.5 w-full"
|
class="flex items-center px-0.5 w-full"
|
||||||
|
:class="alignClasses[field.preferences?.align]"
|
||||||
>
|
>
|
||||||
<span v-if="Array.isArray(modelValue)">
|
<span v-if="Array.isArray(modelValue)">
|
||||||
{{ modelValue.join(', ') }}
|
{{ modelValue.join(', ') }}
|
||||||
@@ -167,6 +168,7 @@
|
|||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
class="whitespace-pre-wrap"
|
class="whitespace-pre-wrap"
|
||||||
|
:class="{ 'w-full': field.preferences?.align }"
|
||||||
>{{ modelValue }}</span>
|
>{{ modelValue }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -253,6 +255,13 @@ export default {
|
|||||||
phone: this.t('phone')
|
phone: this.t('phone')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
alignClasses () {
|
||||||
|
return {
|
||||||
|
center: 'text-center',
|
||||||
|
left: 'text-left',
|
||||||
|
right: 'text-right'
|
||||||
|
}
|
||||||
|
},
|
||||||
option () {
|
option () {
|
||||||
return this.field.options.find((o) => o.uuid === this.area.option_uuid)
|
return this.field.options.find((o) => o.uuid === this.area.option_uuid)
|
||||||
},
|
},
|
||||||
@@ -338,17 +347,19 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
modelValue () {
|
modelValue () {
|
||||||
if (this.field.type === 'text' && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.modelValue.length)) {
|
this.$nextTick(() => {
|
||||||
this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0
|
if (['date', 'text', 'number'].includes(this.field.type) && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > `${this.modelValue}`.length)) {
|
||||||
}
|
this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? `${this.modelValue}`.length : 0
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.field.type === 'text' && this.$refs.textContainer) {
|
this.$nextTick(() => {
|
||||||
this.$nextTick(() => {
|
if (['date', 'text', 'number'].includes(this.field.type) && this.$refs.textContainer) {
|
||||||
this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0
|
this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? `${this.modelValue}`.length : 0
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
optionValue (option) {
|
optionValue (option) {
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
<div class="space-y-3 mt-5">
|
<div class="space-y-3 mt-5">
|
||||||
<a
|
<a
|
||||||
v-if="completedButton.url"
|
v-if="completedButton.url"
|
||||||
:href="completedButton.url"
|
:href="sanitizeHref(completedButton.url)"
|
||||||
|
rel="noopener noreferrer nofollow"
|
||||||
class="white-button flex items-center w-full"
|
class="white-button flex items-center w-full"
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
@@ -215,6 +216,11 @@ export default {
|
|||||||
|
|
||||||
this.isDownloading = false
|
this.isDownloading = false
|
||||||
},
|
},
|
||||||
|
sanitizeHref (href) {
|
||||||
|
if (href && href.trim().match(/^((?:https?:\/\/)|\/)/)) {
|
||||||
|
return href.replace(/javascript:/g, '')
|
||||||
|
}
|
||||||
|
},
|
||||||
downloadSafariIos (urls) {
|
downloadSafariIos (urls) {
|
||||||
const fileRequests = urls.map((url) => {
|
const fileRequests = urls.map((url) => {
|
||||||
return fetch(url).then(async (resp) => {
|
return fetch(url).then(async (resp) => {
|
||||||
|
|||||||
@@ -611,6 +611,11 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
},
|
},
|
||||||
|
authenticityToken: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
i18n: {
|
i18n: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -658,9 +663,6 @@ export default {
|
|||||||
queryParams () {
|
queryParams () {
|
||||||
return new URLSearchParams(window.location.search)
|
return new URLSearchParams(window.location.search)
|
||||||
},
|
},
|
||||||
authenticityToken () {
|
|
||||||
return document.querySelector('meta[name="csrf-token"]')?.content
|
|
||||||
},
|
|
||||||
submitterSlug () {
|
submitterSlug () {
|
||||||
return this.submitter.slug
|
return this.submitter.slug
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
v-if="item.startsWith('<a') && item.endsWith('</a>')"
|
v-if="item.startsWith('<a') && item.endsWith('</a>')"
|
||||||
:href="extractAttr(item, 'href')"
|
:href="sanitizeHref(extractAttr(item, 'href'))"
|
||||||
rel="noopener noreferrer nofollow"
|
rel="noopener noreferrer nofollow"
|
||||||
:class="extractAttr(item, 'class') || 'link'"
|
:class="extractAttr(item, 'class') || 'link'"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -55,6 +55,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
sanitizeHref (href) {
|
||||||
|
if (href && href.trim().match(/^((?:https?:\/\/)|\/)/)) {
|
||||||
|
return href.replace(/javascript:/g, '')
|
||||||
|
}
|
||||||
|
},
|
||||||
extractAttr (text, attr) {
|
extractAttr (text, attr) {
|
||||||
if (text.includes(attr)) {
|
if (text.includes(attr)) {
|
||||||
return text.split(attr).pop().split('"')[1]
|
return text.split(attr).pop().split('"')[1]
|
||||||
|
|||||||
@@ -68,14 +68,13 @@
|
|||||||
class="base-input !text-2xl w-full"
|
class="base-input !text-2xl w-full"
|
||||||
autocomplete="tel"
|
autocomplete="tel"
|
||||||
pattern="^\+[0-9\s\-]+$"
|
pattern="^\+[0-9\s\-]+$"
|
||||||
:oninvalid="`this.value ? this.setCustomValidity('${t('use_international_format')}...') : ''`"
|
|
||||||
oninput="this.setCustomValidity('')"
|
|
||||||
type="tel"
|
type="tel"
|
||||||
inputmode="tel"
|
inputmode="tel"
|
||||||
:required="field.required"
|
:required="field.required"
|
||||||
placeholder="+1 234 567-8900"
|
placeholder="+1 234 567-8900"
|
||||||
:name="`values[${field.uuid}]`"
|
:name="`values[${field.uuid}]`"
|
||||||
@input="$emit('update:model-value', $event.target.value)"
|
@invalid="$event.target.value ? $event.target.setCustomValidity(`${t('use_international_format')}...`) : ''"
|
||||||
|
@input="[$event.target.setCustomValidity(''), $emit('update:model-value', $event.target.value)]"
|
||||||
@focus="$emit('focus')"
|
@focus="$emit('focus')"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,11 +35,11 @@
|
|||||||
:class="{ '!pr-11 -mr-10': !field.validation?.pattern }"
|
:class="{ '!pr-11 -mr-10': !field.validation?.pattern }"
|
||||||
:required="field.required"
|
:required="field.required"
|
||||||
:pattern="field.validation?.pattern"
|
:pattern="field.validation?.pattern"
|
||||||
:oninvalid="field.validation?.message ? `this.setCustomValidity(${JSON.stringify(field.validation.message)})` : ''"
|
|
||||||
:oninput="field.validation?.message ? `this.setCustomValidity('')` : ''"
|
|
||||||
:placeholder="`${t('type_here_')}${field.required ? '' : ` (${t('optional')})`}`"
|
:placeholder="`${t('type_here_')}${field.required ? '' : ` (${t('optional')})`}`"
|
||||||
type="text"
|
type="text"
|
||||||
:name="`values[${field.uuid}]`"
|
:name="`values[${field.uuid}]`"
|
||||||
|
@invalid="field.validation?.message ? $event.target.setCustomValidity(field.validation.message) : ''"
|
||||||
|
@input="field.validation?.message ? $event.target.setCustomValidity('') : ''"
|
||||||
@focus="$emit('focus')"
|
@focus="$emit('focus')"
|
||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
v-model="field.submitter_uuid"
|
v-model="field.submitter_uuid"
|
||||||
class="border-r"
|
class="border-r"
|
||||||
:compact="true"
|
:compact="true"
|
||||||
:editable="editable && !defaultField"
|
:editable="editable && (!defaultField || defaultField.role !== submitter?.name)"
|
||||||
:allow-add-new="!defaultSubmitters.length"
|
:allow-add-new="!defaultSubmitters.length"
|
||||||
:menu-classes="'dropdown-content bg-white menu menu-xs p-2 shadow rounded-box w-52 rounded-t-none -left-[1px] mt-[1px]'"
|
:menu-classes="'dropdown-content bg-white menu menu-xs p-2 shadow rounded-box w-52 rounded-t-none -left-[1px] mt-[1px]'"
|
||||||
:submitters="template.submitters"
|
:submitters="template.submitters"
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
<div
|
<div
|
||||||
class="flex items-center h-full w-full"
|
class="flex items-center h-full w-full"
|
||||||
dir="auto"
|
dir="auto"
|
||||||
:class="[bgColors[submitterIndex], field?.default_value ? '' : 'justify-center']"
|
:class="[bgColors[submitterIndex], field?.default_value ? (alignClasses[field.preferences?.align] || '') : 'justify-center']"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="field"
|
v-if="field"
|
||||||
@@ -211,6 +211,13 @@ export default {
|
|||||||
defaultName () {
|
defaultName () {
|
||||||
return this.buildDefaultName(this.field, this.template.fields)
|
return this.buildDefaultName(this.field, this.template.fields)
|
||||||
},
|
},
|
||||||
|
alignClasses () {
|
||||||
|
return {
|
||||||
|
center: 'justify-center',
|
||||||
|
left: 'justify-start',
|
||||||
|
right: 'justify-end'
|
||||||
|
}
|
||||||
|
},
|
||||||
optionIndexText () {
|
optionIndexText () {
|
||||||
if (this.area.option_uuid && this.field.options) {
|
if (this.area.option_uuid && this.field.options) {
|
||||||
return `${this.field.options.findIndex((o) => o.uuid === this.area.option_uuid) + 1}.`
|
return `${this.field.options.findIndex((o) => o.uuid === this.area.option_uuid) + 1}.`
|
||||||
@@ -301,17 +308,19 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'field.default_value' () {
|
'field.default_value' () {
|
||||||
if (this.field.type === 'text' && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.field.default_value.length)) {
|
this.$nextTick(() => {
|
||||||
this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? this.field.default_value.length : 0
|
if (['date', 'text', 'number'].includes(this.field.type) && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > `${this.field.default_value}`.length)) {
|
||||||
}
|
this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? `${this.field.default_value}`.length : 0
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.field.type === 'text' && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.field.default_value)) {
|
this.$nextTick(() => {
|
||||||
this.$nextTick(() => {
|
if (['date', 'text', 'number'].includes(this.field.type) && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > `${this.field.default_value}`.length)) {
|
||||||
this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? this.field.default_value.length : 0
|
this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? `${this.field.default_value}`.length : 0
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildDefaultName: Field.methods.buildDefaultName,
|
buildDefaultName: Field.methods.buildDefaultName,
|
||||||
|
|||||||
@@ -444,6 +444,11 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
authenticityToken: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
withDocumentsList: {
|
withDocumentsList: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -1023,7 +1028,11 @@ export default {
|
|||||||
baseFetch (path, options = {}) {
|
baseFetch (path, options = {}) {
|
||||||
return fetch(this.baseUrl + path, {
|
return fetch(this.baseUrl + path, {
|
||||||
...options,
|
...options,
|
||||||
headers: { ...this.fetchOptions.headers, ...options.headers }
|
headers: {
|
||||||
|
'X-CSRF-Token': this.authenticityToken,
|
||||||
|
...this.fetchOptions.headers,
|
||||||
|
...options.headers
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
save ({ force } = { force: false }) {
|
save ({ force } = { force: false }) {
|
||||||
@@ -1039,7 +1048,7 @@ export default {
|
|||||||
|
|
||||||
this.pushUndo()
|
this.pushUndo()
|
||||||
|
|
||||||
return this.baseFetch(`/api/templates/${this.template.id}`, {
|
return this.baseFetch(`/templates/${this.template.id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
template: {
|
template: {
|
||||||
|
|||||||
@@ -116,15 +116,41 @@
|
|||||||
@click="closeDropdown"
|
@click="closeDropdown"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="field.type === 'text' && !defaultField"
|
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"
|
||||||
|
@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: 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"
|
class="py-1.5 px-1 relative"
|
||||||
@click.stop
|
@click.stop
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="field.default_value"
|
v-model="field.default_value"
|
||||||
type="text"
|
|
||||||
:placeholder="t('default_value')"
|
:placeholder="t('default_value')"
|
||||||
dir="auto"
|
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"
|
||||||
@blur="save"
|
@blur="save"
|
||||||
>
|
>
|
||||||
@@ -202,7 +228,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<li
|
<li
|
||||||
v-if="field.type != 'phone'"
|
v-if="field.type != 'phone' && field.type != 'stamp'"
|
||||||
@click.stop
|
@click.stop
|
||||||
>
|
>
|
||||||
<label class="cursor-pointer py-1.5">
|
<label class="cursor-pointer py-1.5">
|
||||||
@@ -215,6 +241,20 @@
|
|||||||
<span class="label-text">{{ t('required') }}</span>
|
<span class="label-text">{{ t('required') }}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</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
|
<li
|
||||||
v-if="field.type == 'checkbox'"
|
v-if="field.type == 'checkbox'"
|
||||||
@click.stop
|
@click.stop
|
||||||
@@ -244,7 +284,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
v-if="field.type === 'text' && !defaultField"
|
v-if="['text', 'number'].includes(field.type) && !defaultField"
|
||||||
@click.stop
|
@click.stop
|
||||||
>
|
>
|
||||||
<label class="cursor-pointer py-1.5">
|
<label class="cursor-pointer py-1.5">
|
||||||
@@ -257,8 +297,13 @@
|
|||||||
<span class="label-text">{{ t('read_only') }}</span>
|
<span class="label-text">{{ t('read_only') }}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<hr class="pb-0.5 mt-0.5">
|
<hr
|
||||||
<li>
|
v-if="field.type != 'stamp'"
|
||||||
|
class="pb-0.5 mt-0.5"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
v-if="field.type != 'stamp'"
|
||||||
|
>
|
||||||
<label
|
<label
|
||||||
class="label-text cursor-pointer text-center w-full flex items-center"
|
class="label-text cursor-pointer text-center w-full flex items-center"
|
||||||
@click="isShowDescriptionModal = !isShowDescriptionModal"
|
@click="isShowDescriptionModal = !isShowDescriptionModal"
|
||||||
@@ -271,7 +316,9 @@
|
|||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li
|
||||||
|
v-if="field.type != 'stamp'"
|
||||||
|
>
|
||||||
<label
|
<label
|
||||||
class="label-text cursor-pointer text-center w-full flex items-center"
|
class="label-text cursor-pointer text-center w-full flex items-center"
|
||||||
@click="isShowConditionsModal = !isShowConditionsModal"
|
@click="isShowConditionsModal = !isShowConditionsModal"
|
||||||
@@ -664,7 +711,12 @@ export default {
|
|||||||
},
|
},
|
||||||
removeOption (option) {
|
removeOption (option) {
|
||||||
this.field.options.splice(this.field.options.indexOf(option), 1)
|
this.field.options.splice(this.field.options.indexOf(option), 1)
|
||||||
this.field.areas.splice(this.field.areas.findIndex((a) => a.option_uuid === option.uuid), 1)
|
|
||||||
|
const optionIndex = this.field.areas.findIndex((a) => a.option_uuid === option.uuid)
|
||||||
|
|
||||||
|
if (optionIndex !== -1) {
|
||||||
|
this.field.areas.splice(this.field.areas.findIndex((a) => a.option_uuid === option.uuid), 1)
|
||||||
|
}
|
||||||
|
|
||||||
this.save()
|
this.save()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -36,32 +36,63 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="submitterDefaultFields.length">
|
<div v-if="submitterDefaultFields.length">
|
||||||
<hr class="mb-2">
|
<hr class="mb-2">
|
||||||
<template
|
<template v-if="isShowFieldSearch">
|
||||||
v-for="field in submitterDefaultFields"
|
<input
|
||||||
:key="field.name"
|
v-model="defaultFieldsSearch"
|
||||||
|
:placeholder="t('search_field')"
|
||||||
|
class="input input-ghost input-xs px-0 text-base mb-2 !outline-0 !rounded bg-transparent w-full"
|
||||||
|
>
|
||||||
|
<hr class="mb-2">
|
||||||
|
</template>
|
||||||
|
<div
|
||||||
|
class="overflow-auto relative"
|
||||||
|
:style="{
|
||||||
|
maxHeight: isShowFieldSearch ? '210px' : '',
|
||||||
|
minHeight: isShowFieldSearch ? '210px' : ''
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
:style="{ backgroundColor: backgroundColor }"
|
v-if="!filteredSubmitterDefaultFields.length && defaultFieldsSearch"
|
||||||
draggable="true"
|
class="top-0 bottom-0 text-center absolute flex items-center justify-center w-full flex-col"
|
||||||
class="default-field border border-base-300 rounded rounded-tr-none relative group mb-2"
|
|
||||||
@dragstart="onDragstart({ type: 'text', ...field })"
|
|
||||||
@dragend="$emit('drag-end')"
|
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-between relative cursor-grab">
|
<div>
|
||||||
<div class="flex items-center p-1 space-x-1">
|
{{ t('field_not_found') }}
|
||||||
<IconDrag />
|
</div>
|
||||||
<FieldType
|
<a
|
||||||
:model-value="field.type || 'text'"
|
href="#"
|
||||||
:editable="false"
|
class="link"
|
||||||
:button-width="20"
|
@click.prevent="defaultFieldsSearch = ''"
|
||||||
/>
|
>
|
||||||
<span class="block pl-0.5">
|
{{ t('clear') }}
|
||||||
{{ field.name }}
|
</a>
|
||||||
</span>
|
</div>
|
||||||
|
<template
|
||||||
|
v-for="field in filteredSubmitterDefaultFields"
|
||||||
|
:key="field.name"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:style="{ backgroundColor: backgroundColor }"
|
||||||
|
draggable="true"
|
||||||
|
class="default-field border border-base-300 rounded rounded-tr-none relative group mb-2"
|
||||||
|
@dragstart="onDragstart({ type: 'text', ...field })"
|
||||||
|
@dragend="$emit('drag-end')"
|
||||||
|
>
|
||||||
|
<div class="flex items-center justify-between relative cursor-grab">
|
||||||
|
<div class="flex items-center p-1 space-x-1">
|
||||||
|
<IconDrag />
|
||||||
|
<FieldType
|
||||||
|
:model-value="field.type || 'text'"
|
||||||
|
:editable="false"
|
||||||
|
:button-width="20"
|
||||||
|
/>
|
||||||
|
<span class="block pl-0.5">
|
||||||
|
{{ field.name }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</template>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="editable && !onlyDefinedFields"
|
v-if="editable && !onlyDefinedFields"
|
||||||
@@ -205,9 +236,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['set-draw', 'set-drag', 'drag-end', 'scroll-to-area', 'change-submitter'],
|
emits: ['set-draw', 'set-drag', 'drag-end', 'scroll-to-area', 'change-submitter'],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
defaultFieldsSearch: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
fieldNames: FieldType.computed.fieldNames,
|
fieldNames: FieldType.computed.fieldNames,
|
||||||
fieldIcons: FieldType.computed.fieldIcons,
|
fieldIcons: FieldType.computed.fieldIcons,
|
||||||
|
isShowFieldSearch () {
|
||||||
|
return this.submitterDefaultFields.length > 15
|
||||||
|
},
|
||||||
fieldIconsSorted () {
|
fieldIconsSorted () {
|
||||||
if (this.fieldTypes.length) {
|
if (this.fieldTypes.length) {
|
||||||
return this.fieldTypes.reduce((acc, type) => {
|
return this.fieldTypes.reduce((acc, type) => {
|
||||||
@@ -226,6 +265,13 @@ export default {
|
|||||||
return this.defaultFields.filter((f) => {
|
return this.defaultFields.filter((f) => {
|
||||||
return !this.submitterFields.find((field) => field.name === f.name) && (!f.role || f.role === this.selectedSubmitter.name)
|
return !this.submitterFields.find((field) => field.name === f.name) && (!f.role || f.role === this.selectedSubmitter.name)
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
filteredSubmitterDefaultFields () {
|
||||||
|
if (this.defaultFieldsSearch) {
|
||||||
|
return this.submitterDefaultFields.filter((f) => f.name.toLowerCase().includes(this.defaultFieldsSearch.toLowerCase()))
|
||||||
|
} else {
|
||||||
|
return this.submitterDefaultFields
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
const en = {
|
const en = {
|
||||||
|
search_field: 'Search field',
|
||||||
|
field_not_found: 'Field not found',
|
||||||
|
clear: 'Clear',
|
||||||
|
align: 'Align',
|
||||||
|
left: 'Left',
|
||||||
|
right: 'Right',
|
||||||
|
center: 'Center',
|
||||||
description: 'Description',
|
description: 'Description',
|
||||||
display_title: 'Display title',
|
display_title: 'Display title',
|
||||||
|
with_logo: 'With logo',
|
||||||
unchecked: 'Unchecked',
|
unchecked: 'Unchecked',
|
||||||
equal: 'Equal',
|
equal: 'Equal',
|
||||||
not_equal: 'Not equal',
|
not_equal: 'Not equal',
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export default {
|
|||||||
|
|
||||||
this.isProcessing = true
|
this.isProcessing = true
|
||||||
|
|
||||||
this.baseFetch(`/api/templates/${this.templateId}/documents`, {
|
this.baseFetch(`/templates/${this.templateId}/documents`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ blobs }),
|
body: JSON.stringify({ blobs }),
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
@@ -132,7 +132,7 @@ export default {
|
|||||||
} else if (resp.status === 422) {
|
} else if (resp.status === 422) {
|
||||||
resp.json().then((data) => {
|
resp.json().then((data) => {
|
||||||
if (data.error === 'PDF encrypted') {
|
if (data.error === 'PDF encrypted') {
|
||||||
this.baseFetch(`/api/templates/${this.templateId}/documents`, {
|
this.baseFetch(`/templates/${this.templateId}/documents`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ blobs, password: prompt('Enter PDF password') }),
|
body: JSON.stringify({ blobs, password: prompt('Enter PDF password') }),
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
@@ -151,7 +151,7 @@ export default {
|
|||||||
this.isProcessing = false
|
this.isProcessing = false
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.baseFetch(`/api/templates/${this.templateId}/documents`, {
|
this.baseFetch(`/templates/${this.templateId}/documents`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: new FormData(this.$refs.form)
|
body: new FormData(this.$refs.form)
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
@@ -167,7 +167,7 @@ export default {
|
|||||||
|
|
||||||
formData.append('password', prompt('Enter PDF password'))
|
formData.append('password', prompt('Enter PDF password'))
|
||||||
|
|
||||||
this.baseFetch(`/api/templates/${this.templateId}/documents`, {
|
this.baseFetch(`/templates/${this.templateId}/documents`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
}).then(async (resp) => {
|
}).then(async (resp) => {
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ class SubmitterMailer < ApplicationMailer
|
|||||||
to: @submitter.friendly_name,
|
to: @submitter.friendly_name,
|
||||||
from: from_address_for_submitter(submitter),
|
from: from_address_for_submitter(submitter),
|
||||||
subject:,
|
subject:,
|
||||||
reply_to: (submitter.submission.created_by_user || submitter.template.author)&.friendly_name&.sub(/\+\w+@/, '@')
|
reply_to: submitter.preferences['reply_to'].presence ||
|
||||||
|
(submitter.submission.created_by_user || submitter.template.author)&.friendly_name&.sub(/\+\w+@/, '@')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -84,6 +85,9 @@ class SubmitterMailer < ApplicationMailer
|
|||||||
|
|
||||||
mail(from: from_address_for_submitter(submitter),
|
mail(from: from_address_for_submitter(submitter),
|
||||||
to: to || @submitter.friendly_name,
|
to: to || @submitter.friendly_name,
|
||||||
|
reply_to: @submitter.preferences['reply_to'].presence ||
|
||||||
|
(@submitter.submission.created_by_user ||
|
||||||
|
@submitter.template.author)&.friendly_name&.sub(/\+\w+@/, '@'),
|
||||||
subject:)
|
subject:)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
<head>
|
<head>
|
||||||
<title></title>
|
<title></title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<style>
|
<style></style>
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body dir="<%= yield&.match?(TextUtils::RTL_REGEXP) ? 'rtl' : 'auto' %>">
|
<body dir="<%= TextUtils.rtl?(yield) ? 'rtl' : 'auto' %>">
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
<%= render partial: 'shared/mailer_attribution' %>
|
<%= render partial: 'shared/mailer_attribution' %>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
if (this.field.scrollHeight > this.field.clientHeight) {
|
if (this.field.scrollHeight > this.field.clientHeight) {
|
||||||
this.field.classList.remove('text-[1.5vw]', 'lg:text-base');
|
this.field.classList.remove('text-[1.5vw]', 'lg:text-base');
|
||||||
this.field.classList.add('text-[1.0vw]', 'lg:text-[0.70rem]');
|
this.field.classList.add('text-[1.0vw]', 'lg:text-[0.70rem]');
|
||||||
|
|
||||||
|
if (this.field.scrollHeight > this.field.clientHeight) {
|
||||||
|
this.field.classList.add('text-[0.8vw]', 'lg:text-[0.50rem]');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get field() {
|
get field() {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% if can?(:read, User) %>
|
<% if can?(:read, User) %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to 'Team', settings_users_path, class: 'text-base hover:bg-base-300' %>
|
<%= link_to 'Users', settings_users_path, class: 'text-base hover:bg-base-300' %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless Docuseal.multitenant? %>
|
<% unless Docuseal.multitenant? %>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<%= form_for '', url: template_submissions_path(template), html: { class: 'space-y-4', autocomplete: 'off' }, data: { turbo_frame: :_top } do |f| %>
|
<%= form_for '', url: template_submissions_path(template), html: { class: 'space-y-4', autocomplete: 'off' }, data: { turbo_frame: :_top } do |f| %>
|
||||||
<% if template.submitters.size == 1 %>
|
<% if template.submitters.size == 1 %>
|
||||||
<submitter-item class="form-control">
|
<submitter-item class="form-control">
|
||||||
<submitters-autocomplete data-field="email">
|
<emails-textarea data-bulk-enabled="<%= Docuseal.demo? || !Docuseal.multitenant? || can?(:manage, :bulk_send) %>" data-limit="<%= Docuseal.multitenant? ? (can?(:manage, :bulk_send) ? 50 : 1) : nil %>">
|
||||||
<autoresize-textarea>
|
<submitters-autocomplete data-field="email" class="block relative">
|
||||||
<%= f.text_area :emails, required: true, class: 'base-textarea w-full', placeholder: 'Type emails here...' %>
|
<autoresize-textarea>
|
||||||
</autoresize-textarea>
|
<%= f.text_area :emails, required: true, class: 'base-textarea w-full', placeholder: 'Type emails here...' %>
|
||||||
</submitters-autocomplete>
|
</autoresize-textarea>
|
||||||
|
</submitters-autocomplete>
|
||||||
|
</emails-textarea>
|
||||||
</submitter-item>
|
</submitter-item>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dynamic-list class="space-y-4">
|
<dynamic-list class="space-y-4">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<field-value dir="auto" class="flex absolute text-[1.5vw] lg:text-base" style="width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%">
|
<% align = field.dig('preferences', 'align') %>
|
||||||
|
<field-value dir="auto" class="flex absolute text-[1.5vw] lg:text-base <%= align == 'right' ? 'justify-end' : (align == 'center' ? 'justify-center' : '') %>" style="width: <%= area['w'] * 100 %>%; height: <%= area['h'] * 100 %>%; left: <%= area['x'] * 100 %>%; top: <%= area['y'] * 100 %>%">
|
||||||
<% if field['type'].in?(['signature', 'image', 'initials', 'stamp']) %>
|
<% if field['type'].in?(['signature', 'image', 'initials', 'stamp']) %>
|
||||||
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" loading="lazy">
|
<img class="object-contain mx-auto" src="<%= attachments_index[value].url %>" loading="lazy">
|
||||||
<% elsif field['type'].in?(['file', 'payment']) %>
|
<% elsif field['type'].in?(['file', 'payment']) %>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<%= render 'submissions/annotation', annot: %>
|
<%= render 'submissions/annotation', annot: %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% fields_index.dig(document.uuid, index)&.each do |(area, field)| %>
|
<% fields_index.dig(document.uuid, index)&.each do |(area, field)| %>
|
||||||
<% value = values[field['uuid']].presence || (field['readonly'] ? Submitters::SubmitValues.template_default_value_for_submitter(field['default_value'], @submitter.submission.submitters.find { |e| e.uuid == field['submitter_uuid'] }, with_time: false) : nil) %>
|
<% value = values[field['uuid']].presence || (field['default_value'].present? ? Submitters::SubmitValues.template_default_value_for_submitter(field['default_value'], @submitter.submission.submitters.find { |e| e.uuid == field['submitter_uuid'] }, with_time: false) : nil) %>
|
||||||
<% next if value.blank? %>
|
<% next if value.blank? %>
|
||||||
<% next if !field['readonly'] && field['submitter_uuid'] == @submitter.uuid %>
|
<% next if !field['readonly'] && field['submitter_uuid'] == @submitter.uuid %>
|
||||||
<% next if field.dig('preferences', 'formula') && field['submitter_uuid'] == @submitter.uuid %>
|
<% next if field.dig('preferences', 'formula') && field['submitter_uuid'] == @submitter.uuid %>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<%= auto_link(simple_format(h(local_assigns[:content]))) %>
|
<%= auto_link(simple_format(h(ReplaceEmailVariables.call(local_assigns[:content], submitter: local_assigns[:submitter], sig: local_assigns[:sig])))) %>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<% if @email_config %>
|
<% if @email_config %>
|
||||||
<%= render 'custom_content', content: ReplaceEmailVariables.call(@email_config.value['body'], submitter: @submitter) %>
|
<%= render 'custom_content', content: @email_config.value['body'], submitter: @submitter %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>Hi there,</p>
|
<p>Hi there,</p>
|
||||||
<p>"<%= @submitter.submission.template.name %>" form has been completed by <%= @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ') %>.</p>
|
<p>"<%= @submitter.submission.template.name %>" form has been completed by <%= @submitter.submission.submitters.order(:completed_at).map { |e| e.name || e.email || e.phone }.join(', ') %>.</p>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<% if @email_config %>
|
<% if @email_config %>
|
||||||
<%= render 'custom_content', content: ReplaceEmailVariables.call(@email_config.value['body'], submitter: @submitter, sig: @sig) %>
|
<%= render 'custom_content', content: @email_config.value['body'], submitter: @submitter, sig: @sig %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>Hi there,</p>
|
<p>Hi there,</p>
|
||||||
<p>Please check the copy of your "<%= @submitter.submission.template.name %>" submission in the email attachments.</p>
|
<p>Please check the copy of your "<%= @submitter.submission.template.name %>" submission in the email attachments.</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<% if @email_config || @body.present? %>
|
<% if @email_config || @body.present? %>
|
||||||
<% body = (@body.presence || @email_config.value['body']).to_s %>
|
<% body = (@body.presence || @email_config.value['body']).to_s %>
|
||||||
<%= render 'custom_content', content: ReplaceEmailVariables.call(body, submitter: @submitter) %>
|
<%= render 'custom_content', content: body, submitter: @submitter %>
|
||||||
<% if !body.include?(ReplaceEmailVariables::SUBMITTER_LINK) && !body.include?(ReplaceEmailVariables::SUBMITTER_ID) && !body.include?(ReplaceEmailVariables::SUBMISSION_LINK) && !body.include?(ReplaceEmailVariables::TEMPLATE_ID) && !@submitter.submission.source.in?(%w[api embed]) %>
|
<% if !body.include?(ReplaceEmailVariables::SUBMITTER_LINK) && !body.include?(ReplaceEmailVariables::SUBMITTER_ID) && !body.include?(ReplaceEmailVariables::SUBMISSION_LINK) && !body.include?(ReplaceEmailVariables::TEMPLATE_ID) && !@submitter.submission.source.in?(%w[api embed]) %>
|
||||||
<p><%= link_to nil, submit_form_url(slug: @submitter.slug, t: SubmissionEvents.build_tracking_param(@submitter, 'click_email')) %></p>
|
<p><%= link_to nil, submit_form_url(slug: @submitter.slug, t: SubmissionEvents.build_tracking_param(@submitter, 'click_email')) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,6 +3,11 @@
|
|||||||
<% if @base_template %>
|
<% if @base_template %>
|
||||||
<%= hidden_field_tag :base_template_id, @base_template.id %>
|
<%= hidden_field_tag :base_template_id, @base_template.id %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if @base_template && (can?(:manage, :tenants) || true_user != current_user) && true_user.account.account_linked_accounts.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' %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="form-control mt-6">
|
<div class="form-control mt-6">
|
||||||
<%= f.text_field :name, required: true, placeholder: 'Document Name', class: 'base-input', dir: 'auto' %>
|
<%= f.text_field :name, required: true, placeholder: 'Document Name', class: 'base-input', dir: 'auto' %>
|
||||||
</div>
|
</div>
|
||||||
@@ -17,11 +22,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</folder-autocomplete>
|
</folder-autocomplete>
|
||||||
</div>
|
</div>
|
||||||
<% if @base_template && (can?(:manage, :tenants) || true_user != current_user) && true_user.account.account_linked_accounts.exists?(account_type: :linked) %>
|
|
||||||
<div class="form-control mb-4">
|
|
||||||
<%= select_tag :account_id, options_for_select([true_user.account, *true_user.account.linked_accounts.where.not(id: true_user.account.testing_accounts)].map { |e| [e.name, e.id] }, current_account.id), required: true, class: 'base-select' %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<%= f.button button_title(title: @base_template ? 'Submit' : 'Create', disabled_with: 'Creating'), class: 'base-button' %>
|
<%= f.button button_title(title: @base_template ? 'Submit' : 'Create', disabled_with: 'Creating'), class: 'base-button' %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%= render 'shared/settings_nav' %>
|
<%= render 'shared/settings_nav' %>
|
||||||
<div class="md:flex-grow">
|
<div class="md:flex-grow">
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
<h1 class="text-4xl font-bold">Team</h1>
|
<h1 class="text-4xl font-bold">Users</h1>
|
||||||
<div class="flex items-center space-x-4">
|
<div class="flex items-center space-x-4">
|
||||||
<% if can?(:create, User.new(account: current_account)) %>
|
<% if can?(:create, User.new(account: current_account)) %>
|
||||||
<%= link_to new_user_path, class: 'btn btn-primary btn-md gap-2', data: { turbo_frame: 'modal' } do %>
|
<%= link_to new_user_path, class: 'btn btn-primary btn-md gap-2', data: { turbo_frame: 'modal' } do %>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ Rails.application.configure do
|
|||||||
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
|
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
|
||||||
|
|
||||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
config.force_ssl = ENV['FORCE_SSL'].present?
|
config.force_ssl = ENV['FORCE_SSL'].present? && ENV['FORCE_SSL'] != 'false'
|
||||||
|
|
||||||
# Include generic and useful information about system operation, but avoid logging too much
|
# Include generic and useful information about system operation, but avoid logging too much
|
||||||
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
||||||
@@ -128,7 +128,7 @@ Rails.application.configure do
|
|||||||
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
||||||
|
|
||||||
config.lograge.custom_payload do |controller|
|
config.lograge.custom_payload do |controller|
|
||||||
params = controller.request.params || {}
|
params = controller.request.try(:params) || {}
|
||||||
|
|
||||||
{
|
{
|
||||||
fwd: controller.request.ip,
|
fwd: controller.request.ip,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# fix NoMethodError: undefined method `field_value' for #<HexaPDF::Type::AcroForm::Field
|
|
||||||
module HexaPDF
|
module HexaPDF
|
||||||
module Type
|
module Type
|
||||||
|
# fix NoMethodError: undefined method `field_value' for #<HexaPDF::Type::AcroForm::Field
|
||||||
module AcroForm
|
module AcroForm
|
||||||
class Field
|
class Field
|
||||||
def field_value
|
def field_value
|
||||||
@@ -10,5 +10,34 @@ module HexaPDF
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# comparison of Integer with HexaPDF::PDFArray failed
|
||||||
|
class CIDFont < Font
|
||||||
|
private
|
||||||
|
|
||||||
|
def widths
|
||||||
|
cache(:widths) do
|
||||||
|
result = {}
|
||||||
|
index = 0
|
||||||
|
array = self[:W] || []
|
||||||
|
|
||||||
|
while index < array.size
|
||||||
|
entry = array[index]
|
||||||
|
value = array[index + 1]
|
||||||
|
|
||||||
|
if value.is_a?(Array) || value.is_a?(HexaPDF::PDFArray)
|
||||||
|
value.each_with_index { |width, i| result[entry + i] = width }
|
||||||
|
index += 2
|
||||||
|
else
|
||||||
|
width = array[index + 2]
|
||||||
|
entry.upto(value) { |cid| result[cid] = width }
|
||||||
|
index += 3
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
+1
-1
@@ -24,7 +24,7 @@ port ENV.fetch('PORT', 3000)
|
|||||||
environment ENV.fetch('RAILS_ENV', 'development')
|
environment ENV.fetch('RAILS_ENV', 'development')
|
||||||
|
|
||||||
# Specifies the `pidfile` that Puma will use.
|
# Specifies the `pidfile` that Puma will use.
|
||||||
pidfile ENV.fetch('PIDFILE', "#{Dir.tmpdir}/server.pid")
|
@options[:pidfile] = false
|
||||||
|
|
||||||
# Specifies the number of `workers` to boot in clustered mode.
|
# Specifies the number of `workers` to boot in clustered mode.
|
||||||
# Workers are forked web server processes. If using threads and workers together
|
# Workers are forked web server processes. If using threads and workers together
|
||||||
|
|||||||
+5
-4
@@ -24,8 +24,6 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
namespace :api, defaults: { format: :json } do
|
namespace :api, defaults: { format: :json } do
|
||||||
resources :attachments, only: %i[create]
|
resources :attachments, only: %i[create]
|
||||||
resources :submitters_autocomplete, only: %i[index]
|
|
||||||
resources :template_folders_autocomplete, only: %i[index]
|
|
||||||
resources :submitter_email_clicks, only: %i[create]
|
resources :submitter_email_clicks, only: %i[create]
|
||||||
resources :submitter_form_views, only: %i[create]
|
resources :submitter_form_views, only: %i[create]
|
||||||
resources :submitters, only: %i[index show update]
|
resources :submitters, only: %i[index show update]
|
||||||
@@ -37,7 +35,6 @@ Rails.application.routes.draw do
|
|||||||
resources :templates, only: %i[update show index destroy] do
|
resources :templates, only: %i[update show index destroy] do
|
||||||
resources :clone, only: %i[create], controller: 'templates_clone'
|
resources :clone, only: %i[create], controller: 'templates_clone'
|
||||||
resources :submissions, only: %i[index create]
|
resources :submissions, only: %i[index create]
|
||||||
resources :documents, only: %i[create], controller: 'templates_documents'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,8 +52,11 @@ Rails.application.routes.draw do
|
|||||||
resource :user_signature, only: %i[edit update destroy]
|
resource :user_signature, only: %i[edit update destroy]
|
||||||
resources :submissions, only: %i[show destroy]
|
resources :submissions, only: %i[show destroy]
|
||||||
resources :console_redirect, only: %i[index]
|
resources :console_redirect, only: %i[index]
|
||||||
|
resources :upgrade, only: %i[index], controller: 'console_redirect'
|
||||||
resource :testing_account, only: %i[show destroy]
|
resource :testing_account, only: %i[show destroy]
|
||||||
resources :testing_api_settings, only: %i[index]
|
resources :testing_api_settings, only: %i[index]
|
||||||
|
resources :submitters_autocomplete, only: %i[index]
|
||||||
|
resources :template_folders_autocomplete, only: %i[index]
|
||||||
resource :templates_upload, only: %i[create]
|
resource :templates_upload, only: %i[create]
|
||||||
authenticated do
|
authenticated do
|
||||||
resource :templates_upload, only: %i[show], path: 'new'
|
resource :templates_upload, only: %i[show], path: 'new'
|
||||||
@@ -64,7 +64,8 @@ Rails.application.routes.draw do
|
|||||||
resources :templates_archived, only: %i[index], path: 'archived'
|
resources :templates_archived, only: %i[index], path: 'archived'
|
||||||
resources :folders, only: %i[show edit update destroy], controller: 'template_folders'
|
resources :folders, only: %i[show edit update destroy], controller: 'template_folders'
|
||||||
resources :template_sharings_testing, only: %i[create]
|
resources :template_sharings_testing, only: %i[create]
|
||||||
resources :templates, only: %i[new create edit show destroy] do
|
resources :templates, only: %i[new create edit update show destroy] do
|
||||||
|
resources :documents, only: %i[create], controller: 'template_documents'
|
||||||
resources :restore, only: %i[create], controller: 'templates_restore'
|
resources :restore, only: %i[create], controller: 'templates_restore'
|
||||||
resources :archived, only: %i[index], controller: 'templates_archived_submissions'
|
resources :archived, only: %i[index], controller: 'templates_archived_submissions'
|
||||||
resources :submissions, only: %i[new create]
|
resources :submissions, only: %i[new create]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ queues:
|
|||||||
- [default, 1]
|
- [default, 1]
|
||||||
- [mailers, 1]
|
- [mailers, 1]
|
||||||
- [recurrent, 1]
|
- [recurrent, 1]
|
||||||
|
- [rollbar, 1]
|
||||||
|
|
||||||
production:
|
production:
|
||||||
:concurrency: 15
|
:concurrency: 15
|
||||||
+1
-1
@@ -32,7 +32,7 @@ module Accounts
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_or_create_testing_user(account)
|
def find_or_create_testing_user(account)
|
||||||
user = User.find_by(account: account.testing_accounts)
|
user = User.where(role: :admin).order(:id).find_by(account: account.testing_accounts)
|
||||||
|
|
||||||
return user if user
|
return user if user
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ module Params
|
|||||||
type(params, :order, String)
|
type(params, :order, String)
|
||||||
type(params, :completed_redirect_url, String)
|
type(params, :completed_redirect_url, String)
|
||||||
type(params, :bcc_completed, String)
|
type(params, :bcc_completed, String)
|
||||||
|
type(params, :reply_to, String)
|
||||||
type(params, :message, Hash)
|
type(params, :message, Hash)
|
||||||
type(params, :submitters, Array)
|
type(params, :submitters, Array)
|
||||||
|
|
||||||
@@ -69,6 +70,7 @@ module Params
|
|||||||
required(submitter_params, %i[email phone name])
|
required(submitter_params, %i[email phone name])
|
||||||
|
|
||||||
type(submitter_params, :name, String)
|
type(submitter_params, :name, String)
|
||||||
|
type(submitter_params, :reply_to, String)
|
||||||
type(submitter_params, :email, String)
|
type(submitter_params, :email, String)
|
||||||
format(submitter_params, :email, /@/, message: 'email is invalid')
|
format(submitter_params, :email, /@/, message: 'email is invalid')
|
||||||
type(submitter_params, :phone, String)
|
type(submitter_params, :phone, String)
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module RateLimit
|
||||||
|
LimitApproached = Class.new(StandardError)
|
||||||
|
|
||||||
|
STORE = ActiveSupport::Cache::MemoryStore.new
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def call(key, limit:, ttl:, enabled: Docuseal.multitenant?)
|
||||||
|
return true unless enabled
|
||||||
|
|
||||||
|
value = STORE.increment(key, 1, expires_in: ttl)
|
||||||
|
|
||||||
|
raise LimitApproached if value > limit
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -20,25 +20,25 @@ module ReplaceEmailVariables
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
# rubocop:disable Metrics
|
# rubocop:disable Metrics
|
||||||
def call(text, submitter:, tracking_event_type: 'click_email', sig: nil)
|
def call(text, submitter:, tracking_event_type: 'click_email', html_escape: false, sig: nil)
|
||||||
text = text.gsub(TEMPLATE_NAME) { submitter.template.name }
|
text = replace(text, TEMPLATE_NAME, html_escape:) { submitter.template.name }
|
||||||
text = text.gsub(TEMPLATE_ID) { submitter.template.id }
|
text = replace(text, TEMPLATE_ID, html_escape:) { submitter.template.id }
|
||||||
text = text.gsub(SUBMITTER_ID) { submitter.id }
|
text = replace(text, SUBMITTER_ID, html_escape:) { submitter.id }
|
||||||
text = text.gsub(SUBMITTER_SLUG) { submitter.slug }
|
text = replace(text, SUBMITTER_SLUG, html_escape:) { submitter.slug }
|
||||||
text = text.gsub(SUBMISSION_ID) { submitter.submission.id }
|
text = replace(text, SUBMISSION_ID, html_escape:) { submitter.submission.id }
|
||||||
text = text.gsub(SUBMITTER_EMAIL) { submitter.email }
|
text = replace(text, SUBMITTER_EMAIL, html_escape:) { submitter.email }
|
||||||
text = text.gsub(SUBMITTER_NAME) { submitter.name || submitter.email || submitter.phone }
|
text = replace(text, SUBMITTER_NAME, html_escape:) { submitter.name || submitter.email || submitter.phone }
|
||||||
text = text.gsub(SUBMITTER_LINK) { build_submitter_link(submitter, tracking_event_type) }
|
text = replace(text, SUBMITTER_LINK, html_escape:) { build_submitter_link(submitter, tracking_event_type) }
|
||||||
text = text.gsub(SUBMISSION_LINK) do
|
text = replace(text, SUBMISSION_LINK, html_escape:) do
|
||||||
submitter.submission ? build_submission_link(submitter.submission) : ''
|
submitter.submission ? build_submission_link(submitter.submission) : ''
|
||||||
end
|
end
|
||||||
text = text.gsub(SUBMISSION_SUBMITTERS) { build_submission_submitters(submitter.submission) }
|
text = replace(text, SUBMISSION_SUBMITTERS, html_escape:) { build_submission_submitters(submitter.submission) }
|
||||||
text = text.gsub(DOCUMENTS_LINKS) { build_documents_links_text(submitter, sig) }
|
text = replace(text, DOCUMENTS_LINKS, html_escape:) { build_documents_links_text(submitter, sig) }
|
||||||
text = text.gsub(DOCUMENTS_LINK) { build_documents_links_text(submitter, sig) }
|
text = replace(text, DOCUMENTS_LINK, html_escape:) { build_documents_links_text(submitter, sig) }
|
||||||
text = text.gsub(ACCOUNT_NAME) { submitter.account.name }
|
text = replace(text, ACCOUNT_NAME, html_escape:) { submitter.submission.account.name }
|
||||||
text = text.gsub(SENDER_NAME) { submitter.submission.created_by_user&.full_name }
|
text = replace(text, SENDER_NAME, html_escape:) { submitter.submission.created_by_user&.full_name }
|
||||||
|
|
||||||
text.gsub(SENDER_EMAIL) { submitter.submission.created_by_user&.email.to_s.sub(/\+\w+@/, '@') }
|
replace(text, SENDER_EMAIL, html_escape:) { submitter.submission.created_by_user&.email.to_s.sub(/\+\w+@/, '@') }
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics
|
# rubocop:enable Metrics
|
||||||
|
|
||||||
@@ -48,6 +48,16 @@ module ReplaceEmailVariables
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def replace(text, var, html_escape: false)
|
||||||
|
text.gsub(var) do
|
||||||
|
if html_escape
|
||||||
|
ERB::Util.html_escape(yield)
|
||||||
|
else
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def build_submitter_link(submitter, tracking_event_type)
|
def build_submitter_link(submitter, tracking_event_type)
|
||||||
if tracking_event_type == 'click_email'
|
if tracking_event_type == 'click_email'
|
||||||
Rails.application.routes.url_helpers.submit_form_url(
|
Rails.application.routes.url_helpers.submit_form_url(
|
||||||
|
|||||||
+3
-1
@@ -7,7 +7,7 @@ module Submissions
|
|||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def search(submissions, keyword)
|
def search(submissions, keyword, search_values: false)
|
||||||
return submissions if keyword.blank?
|
return submissions if keyword.blank?
|
||||||
|
|
||||||
term = "%#{keyword.downcase}%"
|
term = "%#{keyword.downcase}%"
|
||||||
@@ -18,6 +18,8 @@ module Submissions
|
|||||||
.or(arel_table[:phone].matches(term))
|
.or(arel_table[:phone].matches(term))
|
||||||
.or(arel_table[:name].lower.matches(term))
|
.or(arel_table[:name].lower.matches(term))
|
||||||
|
|
||||||
|
arel = arel.or(Arel::Table.new(:submitters)[:values].matches(term)) if search_values
|
||||||
|
|
||||||
submissions.joins(:submitters).where(arel).distinct
|
submissions.joins(:submitters).where(arel).distinct
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ module Submissions
|
|||||||
process_fields_param(submitter_attrs[:fields], template_fields, submitter_uuid)
|
process_fields_param(submitter_attrs[:fields], template_fields, submitter_uuid)
|
||||||
end
|
end
|
||||||
|
|
||||||
if template_fields != submission.template.fields
|
if template_fields != (submission.template_fields || submission.template.fields) ||
|
||||||
|
submitters_attrs.any? { |e| e[:completed].present? }
|
||||||
submission.template_fields = template_fields
|
submission.template_fields = template_fields
|
||||||
submission.template_schema = submission.template.schema
|
submission.template_schema = submission.template.schema
|
||||||
end
|
end
|
||||||
@@ -80,11 +81,15 @@ module Submissions
|
|||||||
next if f['type'].in?(%w[signature image initials file])
|
next if f['type'].in?(%w[signature image initials file])
|
||||||
next if f['submitter_uuid'] != submitter_uuid
|
next if f['submitter_uuid'] != submitter_uuid
|
||||||
|
|
||||||
|
next unless values.key?(f['uuid'])
|
||||||
|
|
||||||
value = values[f['uuid']]
|
value = values[f['uuid']]
|
||||||
|
|
||||||
next if value.blank?
|
if value.present?
|
||||||
|
f['default_value'] = value
|
||||||
f['default_value'] = value
|
else
|
||||||
|
f.delete('default_value')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -110,8 +115,12 @@ module Submissions
|
|||||||
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
||||||
field['required'] = attrs['required'] if attrs.key?('required')
|
field['required'] = attrs['required'] if attrs.key?('required')
|
||||||
|
|
||||||
if attrs['default_value'].present? && !field['type'].in?(%w[signature image initials file])
|
if attrs.key?('default_value') && !field['type'].in?(%w[signature image initials file])
|
||||||
field['default_value'] = Submitters::NormalizeValues.normalize_value(field, attrs['default_value'])
|
if attrs['default_value'].present?
|
||||||
|
field['default_value'] = Submitters::NormalizeValues.normalize_value(field, attrs['default_value'])
|
||||||
|
else
|
||||||
|
field.delete('default_value')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return field if attrs['validation_pattern'].blank?
|
return field if attrs['validation_pattern'].blank?
|
||||||
@@ -125,9 +134,10 @@ module Submissions
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_submitter_uuid(template, attrs, index)
|
def find_submitter_uuid(template, attrs, index)
|
||||||
attrs[:uuid].presence ||
|
uuid = attrs[:uuid].presence
|
||||||
template.submitters.find { |e| e['name'] == attrs[:role] }&.dig('uuid') ||
|
uuid ||= template.submitters.find { |e| e['name'].to_s.casecmp(attrs[:role].to_s).zero? }&.dig('uuid')
|
||||||
template.submitters[index]&.dig('uuid')
|
|
||||||
|
uuid || template.submitters[index]&.dig('uuid')
|
||||||
end
|
end
|
||||||
|
|
||||||
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:)
|
||||||
@@ -139,7 +149,7 @@ module Submissions
|
|||||||
phone: attrs[:phone].to_s.gsub(/[^0-9+]/, ''),
|
phone: attrs[:phone].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] ? 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: attrs[:values] || {},
|
||||||
metadata: attrs[:metadata] || {},
|
metadata: attrs[:metadata] || {},
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ module Submissions
|
|||||||
RTL_REGEXP = TextUtils::RTL_REGEXP
|
RTL_REGEXP = TextUtils::RTL_REGEXP
|
||||||
MAX_IMAGE_HEIGHT = 100
|
MAX_IMAGE_HEIGHT = 100
|
||||||
|
|
||||||
|
US_TIMEZONES = %w[EST CST MST PST HST AKDT].freeze
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
# rubocop:disable Metrics
|
# rubocop:disable Metrics
|
||||||
@@ -38,9 +40,17 @@ module Submissions
|
|||||||
pkcs = Accounts.load_signing_pkcs(account)
|
pkcs = Accounts.load_signing_pkcs(account)
|
||||||
tsa_url = Accounts.load_timeserver_url(account)
|
tsa_url = Accounts.load_timeserver_url(account)
|
||||||
verify_url = Rails.application.routes.url_helpers.settings_esign_url(**Docuseal.default_url_options)
|
verify_url = Rails.application.routes.url_helpers.settings_esign_url(**Docuseal.default_url_options)
|
||||||
|
page_size =
|
||||||
|
if TimeUtils.timezone_abbr(account.timezone, Time.current.beginning_of_year).in?(US_TIMEZONES)
|
||||||
|
:Letter
|
||||||
|
else
|
||||||
|
:A4
|
||||||
|
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.fonts.add(FONT_BOLD_NAME, variant: :bold)
|
||||||
|
composer.document.config['font.on_missing_glyph'] =
|
||||||
|
Submissions::GenerateResultAttachments.method(:on_missing_glyph).to_proc
|
||||||
|
|
||||||
divider = HexaPDF::Layout::Box.create(
|
divider = HexaPDF::Layout::Box.create(
|
||||||
margin: [0, 0, 15, 0],
|
margin: [0, 0, 15, 0],
|
||||||
@@ -51,7 +61,7 @@ module Submissions
|
|||||||
height: 1
|
height: 1
|
||||||
)
|
)
|
||||||
|
|
||||||
composer.page_style(:default, page_size: :A4) do |canvas, style|
|
composer.page_style(:default, page_size:) do |canvas, style|
|
||||||
box = canvas.context.box(:media)
|
box = canvas.context.box(:media)
|
||||||
canvas.save_graphics_state do
|
canvas.save_graphics_state do
|
||||||
canvas.fill_color('FAF7F5')
|
canvas.fill_color('FAF7F5')
|
||||||
@@ -245,7 +255,6 @@ module Submissions
|
|||||||
end
|
end
|
||||||
|
|
||||||
value = value.join(', ') if value.is_a?(Array)
|
value = value.join(', ') if value.is_a?(Array)
|
||||||
value = Submissions::GenerateResultAttachments::REPLACE_EMOJI[value] || value
|
|
||||||
|
|
||||||
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') }],
|
||||||
text_align: value.to_s.match?(RTL_REGEXP) ? :right : :left,
|
text_align: value.to_s.match?(RTL_REGEXP) ? :right : :left,
|
||||||
|
|||||||
@@ -21,9 +21,18 @@ module Submissions
|
|||||||
A4_SIZE = [595, 842].freeze
|
A4_SIZE = [595, 842].freeze
|
||||||
SUPPORTED_IMAGE_TYPES = ['image/png', 'image/jpeg'].freeze
|
SUPPORTED_IMAGE_TYPES = ['image/png', 'image/jpeg'].freeze
|
||||||
|
|
||||||
REPLACE_EMOJI = {
|
MISSING_GLYPH_REPLACE = {
|
||||||
|
'▪' => '-',
|
||||||
'✔️' => 'V',
|
'✔️' => 'V',
|
||||||
'✔' => 'V'
|
'✔' => 'V',
|
||||||
|
'✅' => 'V'
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
MISSING_GLYPH_REPLACE_TYPE1 = {
|
||||||
|
'▪' => :bullet,
|
||||||
|
'✔️' => :V,
|
||||||
|
'✔' => :V,
|
||||||
|
'✅' => :V
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
@@ -62,12 +71,14 @@ module Submissions
|
|||||||
|
|
||||||
width = page.box.width
|
width = page.box.width
|
||||||
height = page.box.height
|
height = page.box.height
|
||||||
font_size = ((page.box.width / A4_SIZE[0].to_f) * FONT_SIZE).to_i
|
font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * FONT_SIZE).to_i
|
||||||
|
|
||||||
value = submitter.values[field['uuid']]
|
value = submitter.values[field['uuid']]
|
||||||
|
|
||||||
layouter = HexaPDF::Layout::TextLayouter.new(text_valign: :center,
|
text_align = field.dig('preferences', 'align').to_s.to_sym.presence ||
|
||||||
text_align: value.to_s.match?(RTL_REGEXP) ? :right : :left,
|
(value.to_s.match?(RTL_REGEXP) ? :right : :left)
|
||||||
|
|
||||||
|
layouter = HexaPDF::Layout::TextLayouter.new(text_valign: :center, text_align:,
|
||||||
font: pdf.fonts.add(FONT_NAME), font_size:)
|
font: pdf.fonts.add(FONT_NAME), font_size:)
|
||||||
|
|
||||||
next if Array.wrap(value).compact_blank.blank?
|
next if Array.wrap(value).compact_blank.blank?
|
||||||
@@ -181,7 +192,6 @@ module Submissions
|
|||||||
end
|
end
|
||||||
|
|
||||||
value = TextUtils.maybe_rtl_reverse(Array.wrap(value).join(', '))
|
value = TextUtils.maybe_rtl_reverse(Array.wrap(value).join(', '))
|
||||||
value = REPLACE_EMOJI[value] || value
|
|
||||||
|
|
||||||
text = HexaPDF::Layout::TextFragment.create(value, font: pdf.fonts.add(FONT_NAME),
|
text = HexaPDF::Layout::TextFragment.create(value, font: pdf.fonts.add(FONT_NAME),
|
||||||
font_size:)
|
font_size:)
|
||||||
@@ -194,15 +204,33 @@ module Submissions
|
|||||||
font: pdf.fonts.add(FONT_NAME),
|
font: pdf.fonts.add(FONT_NAME),
|
||||||
font_size: (font_size / 1.4).to_i)
|
font_size: (font_size / 1.4).to_i)
|
||||||
|
|
||||||
lines = layouter.fit([text], area['w'] * width, height).lines
|
lines = layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width, height).lines
|
||||||
|
|
||||||
|
box_height = lines.sum(&:height)
|
||||||
|
end
|
||||||
|
|
||||||
|
if box_height > (area['h'] * height) + 1
|
||||||
|
text = HexaPDF::Layout::TextFragment.create(value,
|
||||||
|
font: pdf.fonts.add(FONT_NAME),
|
||||||
|
font_size: (font_size / 1.9).to_i)
|
||||||
|
|
||||||
|
lines = layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width, height).lines
|
||||||
|
|
||||||
box_height = lines.sum(&:height)
|
box_height = lines.sum(&:height)
|
||||||
end
|
end
|
||||||
|
|
||||||
height_diff = [0, box_height - (area['h'] * height)].max
|
height_diff = [0, box_height - (area['h'] * height)].max
|
||||||
|
|
||||||
layouter.fit([text], area['w'] * width, height_diff.positive? ? box_height : area['h'] * height)
|
right_align_x_adjustment =
|
||||||
.draw(canvas, (area['x'] * width) + TEXT_LEFT_MARGIN,
|
if field['type'].in?(%w[date number]) && text_align != :left
|
||||||
|
(width - (area['w'] * width)) / (text_align == :center ? 2.0 : 1)
|
||||||
|
else
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
|
layouter.fit([text], field['type'].in?(%w[date number]) ? width : area['w'] * width,
|
||||||
|
height_diff.positive? ? box_height : area['h'] * height)
|
||||||
|
.draw(canvas, (area['x'] * width) - right_align_x_adjustment + TEXT_LEFT_MARGIN,
|
||||||
height - (area['y'] * height) + height_diff - TEXT_TOP_MARGIN)
|
height - (area['y'] * height) + height_diff - TEXT_TOP_MARGIN)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -211,28 +239,28 @@ module Submissions
|
|||||||
image_pdfs = []
|
image_pdfs = []
|
||||||
original_documents = template.documents.preload(:blob)
|
original_documents = template.documents.preload(:blob)
|
||||||
|
|
||||||
results =
|
result_attachments =
|
||||||
submitter.submission.template_schema.map do |item|
|
submitter.submission.template_schema.map do |item|
|
||||||
pdf = pdfs_index[item['attachment_uuid']]
|
pdf = pdfs_index[item['attachment_uuid']]
|
||||||
|
|
||||||
attachment = save_pdf(pdf:, submitter:, pkcs:, tsa_url:,
|
attachment = build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
||||||
uuid: item['attachment_uuid'],
|
uuid: item['attachment_uuid'],
|
||||||
name: item['name'])
|
name: item['name'])
|
||||||
|
|
||||||
image_pdfs << pdf if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
image_pdfs << pdf if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
||||||
|
|
||||||
attachment
|
attachment
|
||||||
end
|
end
|
||||||
|
|
||||||
return results if image_pdfs.size < 2
|
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
|
||||||
|
|
||||||
images_pdf =
|
images_pdf =
|
||||||
image_pdfs.each_with_object(HexaPDF::Document.new) do |pdf, doc|
|
image_pdfs.each_with_object(HexaPDF::Document.new) do |pdf, doc|
|
||||||
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
||||||
end
|
end
|
||||||
|
|
||||||
images_pdf_result =
|
images_pdf_attachment =
|
||||||
save_pdf(
|
build_pdf_attachment(
|
||||||
pdf: images_pdf,
|
pdf: images_pdf,
|
||||||
submitter:,
|
submitter:,
|
||||||
tsa_url:,
|
tsa_url:,
|
||||||
@@ -241,11 +269,10 @@ module Submissions
|
|||||||
name: template.name
|
name: template.name
|
||||||
)
|
)
|
||||||
|
|
||||||
results + [images_pdf_result]
|
(result_attachments + [images_pdf_attachment]).map { |e| e.tap(&:save!) }
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics
|
|
||||||
|
|
||||||
def save_pdf(pdf:, submitter:, pkcs:, tsa_url:, uuid:, name:)
|
def build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:, uuid:, name:)
|
||||||
io = StringIO.new
|
io = StringIO.new
|
||||||
|
|
||||||
pdf.trailer.info[:Creator] = info_creator
|
pdf.trailer.info[:Creator] = info_creator
|
||||||
@@ -265,12 +292,25 @@ module Submissions
|
|||||||
sign_params[:signature_size] = 10_000
|
sign_params[:signature_size] = 10_000
|
||||||
end
|
end
|
||||||
|
|
||||||
pdf.sign(io, write_options: { validate: false }, **sign_params)
|
begin
|
||||||
else
|
pdf.sign(io, write_options: { validate: false }, **sign_params)
|
||||||
pdf.write(io, incremental: true, validate: false)
|
rescue HexaPDF::MalformedPDFError => e
|
||||||
end
|
Rollbar.error(e) if defined?(Rollbar)
|
||||||
|
|
||||||
ActiveStorage::Attachment.create!(
|
pdf.sign(io, write_options: { validate: false, incremental: false }, **sign_params)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
pdf.write(io, incremental: true, validate: false)
|
||||||
|
rescue HexaPDF::MalformedPDFError => e
|
||||||
|
Rollbar.error(e) if defined?(Rollbar)
|
||||||
|
|
||||||
|
pdf.write(io, incremental: false, validate: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# rubocop:enable Metrics
|
||||||
|
|
||||||
|
ActiveStorage::Attachment.new(
|
||||||
blob: ActiveStorage::Blob.create_and_upload!(io: StringIO.new(io.string), filename: "#{name}.pdf"),
|
blob: ActiveStorage::Blob.create_and_upload!(io: StringIO.new(io.string), filename: "#{name}.pdf"),
|
||||||
metadata: { original_uuid: uuid,
|
metadata: { original_uuid: uuid,
|
||||||
analyzed: true,
|
analyzed: true,
|
||||||
@@ -306,10 +346,25 @@ module Submissions
|
|||||||
Rollbar.error(e) if defined?(Rollbar)
|
Rollbar.error(e) if defined?(Rollbar)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pdf.config['font.on_missing_glyph'] = method(:on_missing_glyph).to_proc
|
||||||
|
|
||||||
[attachment.metadata['original_uuid'] || attachment.uuid, pdf]
|
[attachment.metadata['original_uuid'] || attachment.uuid, pdf]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def on_missing_glyph(character, font_wrapper)
|
||||||
|
Rollbar.error("Missing glyph: #{character}") if character.present? && defined?(Rollbar)
|
||||||
|
|
||||||
|
replace_with =
|
||||||
|
if font_wrapper.font_type == :Type1
|
||||||
|
MISSING_GLYPH_REPLACE_TYPE1[character] || :space
|
||||||
|
else
|
||||||
|
(MISSING_GLYPH_REPLACE[character] || ' ').bytes.first - 29
|
||||||
|
end
|
||||||
|
|
||||||
|
font_wrapper.custom_glyph(replace_with, character)
|
||||||
|
end
|
||||||
|
|
||||||
def find_last_submitter(submitter)
|
def find_last_submitter(submitter)
|
||||||
submitter.submission.submitters
|
submitter.submission.submitters
|
||||||
.select(&:completed_at?)
|
.select(&:completed_at?)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ module Submissions
|
|||||||
default_values = submitter_params[:values] || {}
|
default_values = submitter_params[:values] || {}
|
||||||
|
|
||||||
submitter_params[:fields]&.each do |f|
|
submitter_params[:fields]&.each do |f|
|
||||||
default_values[f[:name]] = f[:default_value] if f[:default_value].present?
|
default_values[f[:name]] = f[:default_value] if f.key?(:default_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
return submitter_params if default_values.blank?
|
return submitter_params if default_values.blank?
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ module Submitters
|
|||||||
preferences['send_email'] = params['send_email'].in?(TRUE_VALUES) if params.key?('send_email')
|
preferences['send_email'] = params['send_email'].in?(TRUE_VALUES) if params.key?('send_email')
|
||||||
preferences['send_sms'] = params['send_sms'].in?(TRUE_VALUES) if params.key?('send_sms')
|
preferences['send_sms'] = params['send_sms'].in?(TRUE_VALUES) if params.key?('send_sms')
|
||||||
preferences['bcc_completed'] = params['bcc_completed'] if params.key?('bcc_completed')
|
preferences['bcc_completed'] = params['bcc_completed'] if params.key?('bcc_completed')
|
||||||
|
preferences['reply_to'] = params['reply_to'] if params.key?('reply_to')
|
||||||
preferences['completed_redirect_url'] = params['completed_redirect_url'] if params.key?('completed_redirect_url')
|
preferences['completed_redirect_url'] = params['completed_redirect_url'] if params.key?('completed_redirect_url')
|
||||||
|
|
||||||
preferences
|
preferences
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ module Submitters
|
|||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(submitter)
|
def call(submitter, with_logo: true)
|
||||||
image = generate_stamp_image(submitter)
|
image = generate_stamp_image(submitter, with_logo:)
|
||||||
|
|
||||||
image_data = image.write_to_buffer('.png')
|
image_data = image.write_to_buffer('.png')
|
||||||
|
|
||||||
@@ -30,8 +30,13 @@ module Submitters
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_stamp_image(submitter)
|
def generate_stamp_image(submitter, with_logo: true)
|
||||||
logo = Vips::Image.new_from_buffer(load_logo(submitter).read, '')
|
logo =
|
||||||
|
if with_logo
|
||||||
|
Vips::Image.new_from_buffer(load_logo(submitter).read, '')
|
||||||
|
else
|
||||||
|
Vips::Image.new_from_buffer(TRANSPARENT_PIXEL, '').resize(WIDTH)
|
||||||
|
end
|
||||||
|
|
||||||
logo = logo.resize([WIDTH / logo.width.to_f, HEIGHT / logo.height.to_f].min)
|
logo = logo.resize([WIDTH / logo.width.to_f, HEIGHT / logo.height.to_f].min)
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ module Submitters
|
|||||||
next if field['submitter_uuid'] != submitter.uuid
|
next if field['submitter_uuid'] != submitter.uuid
|
||||||
|
|
||||||
if field['type'] == 'stamp'
|
if field['type'] == 'stamp'
|
||||||
acc[field['uuid']] ||= Submitters::CreateStampAttachment.call(submitter).uuid
|
acc[field['uuid']] ||=
|
||||||
|
Submitters::CreateStampAttachment.call(submitter,
|
||||||
|
with_logo: field.dig('preferences', 'with_logo') != false).uuid
|
||||||
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@@ -129,6 +131,8 @@ module Submitters
|
|||||||
|
|
||||||
value.to_s.gsub(VARIABLE_REGEXP) do |e|
|
value.to_s.gsub(VARIABLE_REGEXP) do |e|
|
||||||
case key = ::Regexp.last_match(1)
|
case key = ::Regexp.last_match(1)
|
||||||
|
when 'id'
|
||||||
|
attrs['submission_id']
|
||||||
when 'time'
|
when 'time'
|
||||||
if with_time
|
if with_time
|
||||||
I18n.l(Time.current.in_time_zone(template.account.timezone), format: :long, locale: template.account.locale)
|
I18n.l(Time.current.in_time_zone(template.account.timezone), format: :long, locale: template.account.locale)
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ module Templates
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(data)
|
def call(data)
|
||||||
pdf = PDF::Reader.new(StringIO.new(data))
|
pdf = HexaPDF::Document.new(io: StringIO.new(data))
|
||||||
|
|
||||||
pdf.pages.flat_map.with_index do |page, index|
|
pdf.pages.flat_map.with_index do |page, index|
|
||||||
annotations = page.objects.deref!(page.attributes[:Annots]) || []
|
(page[:Annots] || []).filter_map do |annot|
|
||||||
annotations.filter_map do |annot|
|
next if annot.blank?
|
||||||
next if annot.nil?
|
|
||||||
next if annot[:A].blank? || annot[:A][:URI].blank?
|
next if annot[:A].blank? || annot[:A][:URI].blank?
|
||||||
next unless annot[:Subtype] == :Link
|
next unless annot[:Subtype] == :Link
|
||||||
next if !annot[:A][:URI].starts_with?('https://') && !annot[:A][:URI].starts_with?('http://')
|
next if !annot[:A][:URI].starts_with?('https://') && !annot[:A][:URI].starts_with?('http://')
|
||||||
@@ -30,10 +29,10 @@ module Templates
|
|||||||
{
|
{
|
||||||
'type' => 'external_link',
|
'type' => 'external_link',
|
||||||
'value' => annot[:A][:URI],
|
'value' => annot[:A][:URI],
|
||||||
'x' => left / page.width.to_f,
|
'x' => left / page.box.width.to_f,
|
||||||
'y' => (page.height - top) / page.height.to_f,
|
'y' => (page.box.height - top) / page.box.height.to_f,
|
||||||
'w' => (right - left) / page.width.to_f,
|
'w' => (right - left) / page.box.width.to_f,
|
||||||
'h' => (top - bottom) / page.height.to_f
|
'h' => (top - bottom) / page.box.height.to_f
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,14 @@ module TextUtils
|
|||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
def rtl?(text)
|
||||||
|
return false if text.blank?
|
||||||
|
|
||||||
|
text.match?(TextUtils::RTL_REGEXP)
|
||||||
|
rescue Encoding::CompatibilityError
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def maybe_rtl_reverse(text)
|
def maybe_rtl_reverse(text)
|
||||||
if text.match?(RTL_REGEXP)
|
if text.match?(RTL_REGEXP)
|
||||||
TwitterCldr::Shared::Bidi
|
TwitterCldr::Shared::Bidi
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ module.exports = {
|
|||||||
'./app/views/start_form/**/*.erb',
|
'./app/views/start_form/**/*.erb',
|
||||||
'./app/views/shared/_button_title.html.erb',
|
'./app/views/shared/_button_title.html.erb',
|
||||||
'./app/views/shared/_attribution.html.erb',
|
'./app/views/shared/_attribution.html.erb',
|
||||||
|
'./app/views/scripts/_autosize_field.html.erb',
|
||||||
'./app/views/send_submission_email/**/*.erb'
|
'./app/views/send_submission_email/**/*.erb'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user