mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 22:42:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f3a8bf391 | ||
|
|
a0a0fdd1b5 | ||
|
|
7a6f901b09 | ||
|
|
c4f05fbd9e | ||
|
|
50c342ec5c | ||
|
|
a9cfd2bcfc | ||
|
|
e2bdb2acee | ||
|
|
b8828b503c | ||
|
|
d63f62109b | ||
|
|
c04483f0ea | ||
|
|
1efaf30fb7 | ||
|
|
2e462e9633 | ||
|
|
838df5f41d | ||
|
|
32445f0e19 | ||
|
|
5f9067baee | ||
|
|
ad56d5ee14 | ||
|
|
a091d121d9 | ||
|
|
cd9c3ee3c1 | ||
|
|
534c3a2e10 | ||
|
|
7bc8e194df | ||
|
|
de5c4d5bcd |
No files matched your search
@@ -107,6 +107,8 @@ jobs:
|
|||||||
node-version: 20.9.0
|
node-version: 20.9.0
|
||||||
- name: Install Chrome
|
- name: Install Chrome
|
||||||
uses: browser-actions/setup-chrome@latest
|
uses: browser-actions/setup-chrome@latest
|
||||||
|
with:
|
||||||
|
chrome-version: 125
|
||||||
- name: Cache node_modules
|
- name: Cache node_modules
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ FROM ruby:3.3.3-alpine as fonts
|
|||||||
|
|
||||||
WORKDIR /fonts
|
WORKDIR /fonts
|
||||||
|
|
||||||
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/v2031/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 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")'
|
RUN fontforge -lang=py -c 'font1 = fontforge.open("FreeSans.ttf"); font2 = fontforge.open("NotoSansSymbols2-Regular.ttf"); font1.mergeFonts(font2); font1.generate("FreeSans.ttf")'
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ gem 'image_processing'
|
|||||||
gem 'jwt'
|
gem 'jwt'
|
||||||
gem 'lograge'
|
gem 'lograge'
|
||||||
gem 'mysql2', require: false
|
gem 'mysql2', require: false
|
||||||
|
gem 'net-smtp', '0.4.0'
|
||||||
gem 'oj'
|
gem 'oj'
|
||||||
gem 'pagy'
|
gem 'pagy'
|
||||||
gem 'pg', require: false
|
gem 'pg', require: false
|
||||||
|
|||||||
+2
-1
@@ -326,7 +326,7 @@ GEM
|
|||||||
net-pop (0.1.2)
|
net-pop (0.1.2)
|
||||||
net-protocol (0.2.2)
|
net-protocol (0.2.2)
|
||||||
timeout
|
timeout
|
||||||
net-smtp (0.5.0)
|
net-smtp (0.4.0)
|
||||||
net-protocol
|
net-protocol
|
||||||
nio4r (2.7.1)
|
nio4r (2.7.1)
|
||||||
nokogiri (1.16.7)
|
nokogiri (1.16.7)
|
||||||
@@ -591,6 +591,7 @@ DEPENDENCIES
|
|||||||
letter_opener_web
|
letter_opener_web
|
||||||
lograge
|
lograge
|
||||||
mysql2
|
mysql2
|
||||||
|
net-smtp (= 0.4.0)
|
||||||
oj
|
oj
|
||||||
pagy
|
pagy
|
||||||
pg
|
pg
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Api
|
||||||
|
class SubmissionEventsController < ApiBaseController
|
||||||
|
load_and_authorize_resource :submission, parent: false
|
||||||
|
|
||||||
|
def index
|
||||||
|
submissions = build_completed_query(@submissions)
|
||||||
|
|
||||||
|
params[:after] = Time.zone.at(params[:after].to_i) if params[:after].present?
|
||||||
|
params[:before] = Time.zone.at(params[:before].to_i) if params[:before].present?
|
||||||
|
|
||||||
|
submissions = paginate(submissions.preload(
|
||||||
|
:created_by_user, :submission_events,
|
||||||
|
template: :folder,
|
||||||
|
submitters: { documents_attachments: :blob, attachments_attachments: :blob },
|
||||||
|
audit_trail_attachment: :blob
|
||||||
|
),
|
||||||
|
field: :completed_at)
|
||||||
|
|
||||||
|
render json: {
|
||||||
|
data: submissions.map do |s|
|
||||||
|
{
|
||||||
|
event_type: 'submission.completed',
|
||||||
|
timestamp: s.completed_at,
|
||||||
|
data: Submissions::SerializeForApi.call(s, s.submitters)
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
pagination: {
|
||||||
|
count: submissions.size,
|
||||||
|
next: submissions.last&.completed_at&.to_i,
|
||||||
|
prev: submissions.first&.completed_at&.to_i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def build_completed_query(submissions)
|
||||||
|
submissions = submissions.where(
|
||||||
|
Submitter.where(completed_at: nil).where(
|
||||||
|
Submitter.arel_table[:submission_id].eq(Submission.arel_table[:id])
|
||||||
|
).select(1).arel.exists.not
|
||||||
|
)
|
||||||
|
|
||||||
|
submissions.joins(:submitters)
|
||||||
|
.group(:id)
|
||||||
|
.select(Submission.arel_table[Arel.star],
|
||||||
|
Submitter.arel_table[:completed_at].maximum.as('completed_at'))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -95,6 +95,7 @@ module Api
|
|||||||
def template_params
|
def template_params
|
||||||
permitted_params = [
|
permitted_params = [
|
||||||
:name,
|
:name,
|
||||||
|
:external_id,
|
||||||
{
|
{
|
||||||
submitters: [%i[name uuid]],
|
submitters: [%i[name uuid]],
|
||||||
fields: [[:uuid, :submitter_uuid, :name, :type,
|
fields: [[:uuid, :submitter_uuid, :name, :type,
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ class StartFormController < ApplicationController
|
|||||||
template_submitters: template.submitters,
|
template_submitters: template.submitters,
|
||||||
source: :link)
|
source: :link)
|
||||||
|
|
||||||
|
submitter.account_id = submitter.submission.account_id
|
||||||
|
|
||||||
submitter
|
submitter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import PromptPassword from './elements/prompt_password'
|
|||||||
import EmailsTextarea from './elements/emails_textarea'
|
import EmailsTextarea from './elements/emails_textarea'
|
||||||
import ToggleOnSubmit from './elements/toggle_on_submit'
|
import ToggleOnSubmit from './elements/toggle_on_submit'
|
||||||
import PasswordInput from './elements/password_input'
|
import PasswordInput from './elements/password_input'
|
||||||
|
import SearchInput from './elements/search_input'
|
||||||
|
|
||||||
import * as TurboInstantClick from './lib/turbo_instant_click'
|
import * as TurboInstantClick from './lib/turbo_instant_click'
|
||||||
|
|
||||||
@@ -87,6 +88,7 @@ safeRegisterElement('emails-textarea', EmailsTextarea)
|
|||||||
safeRegisterElement('toggle-cookies', ToggleCookies)
|
safeRegisterElement('toggle-cookies', ToggleCookies)
|
||||||
safeRegisterElement('toggle-on-submit', ToggleOnSubmit)
|
safeRegisterElement('toggle-on-submit', ToggleOnSubmit)
|
||||||
safeRegisterElement('password-input', PasswordInput)
|
safeRegisterElement('password-input', PasswordInput)
|
||||||
|
safeRegisterElement('search-input', SearchInput)
|
||||||
|
|
||||||
safeRegisterElement('template-builder', class extends HTMLElement {
|
safeRegisterElement('template-builder', class extends HTMLElement {
|
||||||
connectedCallback () {
|
connectedCallback () {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
export default class extends HTMLElement {
|
||||||
|
connectedCallback () {
|
||||||
|
this.input.addEventListener('focus', () => {
|
||||||
|
if (this.title) {
|
||||||
|
this.title.classList.add('hidden', 'md:block')
|
||||||
|
this.input.classList.add('w-60')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.input.addEventListener('blur', (e) => {
|
||||||
|
if (this.title && !e.target.value) {
|
||||||
|
this.title.classList.remove('hidden')
|
||||||
|
this.input.classList.remove('w-60')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
get input () {
|
||||||
|
return this.querySelector('input')
|
||||||
|
}
|
||||||
|
|
||||||
|
get title () {
|
||||||
|
return document.querySelector(this.dataset.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -925,7 +925,7 @@ export default {
|
|||||||
return field.conditions.reduce((acc, c) => {
|
return field.conditions.reduce((acc, c) => {
|
||||||
const field = this.fieldsUuidIndex[c.field_uuid]
|
const field = this.fieldsUuidIndex[c.field_uuid]
|
||||||
|
|
||||||
if (['not_empty', 'checked', 'equal', 'contains'].includes(c.action) && !this.checkFieldConditions(field)) {
|
if (['not_empty', 'checked', 'equal', 'contains'].includes(c.action) && field && !this.checkFieldConditions(field)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<template
|
<template
|
||||||
v-for="(icon, type) in fieldIcons"
|
v-for="(icon, type) in fieldIconsSorted"
|
||||||
:key="type"
|
:key="type"
|
||||||
>
|
>
|
||||||
<li v-if="(fieldTypes.length === 0 || fieldTypes.includes(type)) && (withPhone || type != 'phone') && (withPayment || type != 'payment')">
|
<li v-if="(fieldTypes.length === 0 || fieldTypes.includes(type)) && (withPhone || type != 'phone') && (withPayment || type != 'payment')">
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ class ProcessSubmitterCompletionJob
|
|||||||
enqueue_completed_emails(submitter)
|
enqueue_completed_emails(submitter)
|
||||||
end
|
end
|
||||||
|
|
||||||
enqueue_completed_webhooks(submitter)
|
enqueue_completed_webhooks(submitter, is_all_completed:)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_completed_webhooks(submitter)
|
def enqueue_completed_webhooks(submitter, is_all_completed: false)
|
||||||
webhook_config = Accounts.load_webhook_config(submitter.account)
|
webhook_config = Accounts.load_webhook_config(submitter.account)
|
||||||
|
|
||||||
if webhook_config
|
if webhook_config
|
||||||
@@ -31,13 +31,26 @@ class ProcessSubmitterCompletionJob
|
|||||||
'encrypted_config_id' => webhook_config.id })
|
'encrypted_config_id' => webhook_config.id })
|
||||||
end
|
end
|
||||||
|
|
||||||
webhook_ids = submitter.account.webhook_urls.where(
|
webhook_urls = submitter.account.webhook_urls
|
||||||
Arel::Table.new(:webhook_urls)[:events].matches('%"form.completed"%')
|
|
||||||
).pluck(:id)
|
|
||||||
|
|
||||||
webhook_ids.each do |webhook_id|
|
webhook_urls = webhook_urls.where(
|
||||||
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id,
|
Arel::Table.new(:webhook_urls)[:events].matches('%"form.completed"%')
|
||||||
'webhook_url_id' => webhook_id })
|
).or(
|
||||||
|
webhook_urls.where(
|
||||||
|
Arel::Table.new(:webhook_urls)[:events].matches('%"submission.completed"%')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
webhook_urls.each do |webhook|
|
||||||
|
if webhook.events.include?('form.completed')
|
||||||
|
SendFormCompletedWebhookRequestJob.perform_async({ 'submitter_id' => submitter.id,
|
||||||
|
'webhook_url_id' => webhook.id })
|
||||||
|
end
|
||||||
|
|
||||||
|
if webhook.events.include?('submission.completed') && is_all_completed
|
||||||
|
SendSubmissionCompletedWebhookRequestJob.perform_async({ 'submission_id' => submitter.submission_id,
|
||||||
|
'webhook_url_id' => webhook.id })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SendSubmissionCompletedWebhookRequestJob
|
||||||
|
include Sidekiq::Job
|
||||||
|
|
||||||
|
sidekiq_options queue: :webhooks
|
||||||
|
|
||||||
|
USER_AGENT = 'DocuSeal.co Webhook'
|
||||||
|
|
||||||
|
MAX_ATTEMPTS = 10
|
||||||
|
|
||||||
|
def perform(params = {})
|
||||||
|
submission = Submission.find(params['submission_id'])
|
||||||
|
|
||||||
|
attempt = params['attempt'].to_i
|
||||||
|
|
||||||
|
webhook_url = submission.account.webhook_urls.find(params['webhook_url_id'])
|
||||||
|
|
||||||
|
url = webhook_url.url if webhook_url.events.include?('submission.completed')
|
||||||
|
|
||||||
|
return if url.blank?
|
||||||
|
|
||||||
|
resp = begin
|
||||||
|
Faraday.post(url,
|
||||||
|
{
|
||||||
|
event_type: 'submission.completed',
|
||||||
|
timestamp: Time.current,
|
||||||
|
data: Submissions::SerializeForApi.call(submission)
|
||||||
|
}.to_json,
|
||||||
|
**EncryptedConfig.find_or_initialize_by(account_id: submission.account_id,
|
||||||
|
key: EncryptedConfig::WEBHOOK_SECRET_KEY)&.value.to_h,
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'User-Agent' => USER_AGENT)
|
||||||
|
rescue Faraday::Error
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if (resp.nil? || resp.status.to_i >= 400) && attempt <= MAX_ATTEMPTS &&
|
||||||
|
(!Docuseal.multitenant? || submission.account.account_configs.exists?(key: :plan))
|
||||||
|
SendSubmissionCompletedWebhookRequestJob.perform_in((2**attempt).minutes, {
|
||||||
|
**params,
|
||||||
|
'attempt' => attempt + 1,
|
||||||
|
'last_status' => resp&.status.to_i
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -29,7 +29,7 @@ class Account < ApplicationRecord
|
|||||||
has_one :default_template_folder, -> { where(name: TemplateFolder::DEFAULT_NAME) },
|
has_one :default_template_folder, -> { where(name: TemplateFolder::DEFAULT_NAME) },
|
||||||
class_name: 'TemplateFolder', dependent: :destroy, inverse_of: :account
|
class_name: 'TemplateFolder', dependent: :destroy, inverse_of: :account
|
||||||
has_many :submissions, dependent: :destroy
|
has_many :submissions, dependent: :destroy
|
||||||
has_many :submitters, through: :submissions
|
has_many :submitters, dependent: :destroy
|
||||||
has_many :account_linked_accounts, dependent: :destroy
|
has_many :account_linked_accounts, dependent: :destroy
|
||||||
has_many :email_events, dependent: :destroy
|
has_many :email_events, dependent: :destroy
|
||||||
has_many :webhook_urls, dependent: :destroy
|
has_many :webhook_urls, dependent: :destroy
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_submissions_on_account_id (account_id)
|
# index_submissions_on_account_id_and_id (account_id,id)
|
||||||
# index_submissions_on_created_by_user_id (created_by_user_id)
|
# index_submissions_on_created_by_user_id (created_by_user_id)
|
||||||
# index_submissions_on_slug (slug) UNIQUE
|
# index_submissions_on_slug (slug) UNIQUE
|
||||||
# index_submissions_on_template_id (template_id)
|
# index_submissions_on_template_id (template_id)
|
||||||
|
|||||||
@@ -20,15 +20,17 @@
|
|||||||
# values :text not null
|
# values :text not null
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
# account_id :bigint not null
|
||||||
# external_id :string
|
# external_id :string
|
||||||
# submission_id :bigint not null
|
# submission_id :bigint not null
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_submitters_on_email (email)
|
# index_submitters_on_account_id_and_id (account_id,id)
|
||||||
# index_submitters_on_external_id (external_id)
|
# index_submitters_on_email (email)
|
||||||
# index_submitters_on_slug (slug) UNIQUE
|
# index_submitters_on_external_id (external_id)
|
||||||
# index_submitters_on_submission_id (submission_id)
|
# index_submitters_on_slug (slug) UNIQUE
|
||||||
|
# index_submitters_on_submission_id (submission_id)
|
||||||
#
|
#
|
||||||
# Foreign Keys
|
# Foreign Keys
|
||||||
#
|
#
|
||||||
@@ -36,8 +38,8 @@
|
|||||||
#
|
#
|
||||||
class Submitter < ApplicationRecord
|
class Submitter < ApplicationRecord
|
||||||
belongs_to :submission
|
belongs_to :submission
|
||||||
|
belongs_to :account
|
||||||
has_one :template, through: :submission
|
has_one :template, through: :submission
|
||||||
has_one :account, through: :submission
|
|
||||||
|
|
||||||
attribute :values, :string, default: -> { {} }
|
attribute :values, :string, default: -> { {} }
|
||||||
attribute :preferences, :string, default: -> { {} }
|
attribute :preferences, :string, default: -> { {} }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<form action="<%= root_path %>" method="get" class="bg-base-200 px-1.5 rounded-xl py-1">
|
<form action="<%= root_path %>" method="get" class="bg-base-200 px-1.5 rounded-xl py-1 whitespace-nowrap">
|
||||||
<toggle-cookies data-value="templates" data-key="dashboard_view" class="sm:tooltip tooltip-top" data-tip="Templates">
|
<toggle-cookies data-value="templates" data-key="dashboard_view" class="sm:tooltip tooltip-top" data-tip="Templates">
|
||||||
<button class="<%= local_assigns[:selected] == 'submissions' ? 'btn !border !rounded-lg btn-square !p-0 !btn-sm !h-8 !w-9' : 'btn btn-neutral !rounded-lg btn-square !p-0 hover:text-neutral-300 !btn-sm !h-8 !w-9 disabled:btn-neutral' %>">
|
<button class="<%= local_assigns[:selected] == 'submissions' ? 'btn !border !rounded-lg btn-square !p-0 !btn-sm !h-8 !w-9' : 'btn btn-neutral !rounded-lg btn-square !p-0 hover:text-neutral-300 !btn-sm !h-8 !w-9 disabled:btn-neutral' %>">
|
||||||
<%= svg_icon('layout_grid', class: 'w-6 h-6 stroke-2') %>
|
<%= svg_icon('layout_grid', class: 'w-6 h-6 stroke-2') %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html data-theme="docuseal" lang="<%= I18n.locale %>">
|
<html data-theme="docuseal" lang="<%= I18n.locale %>">
|
||||||
<head>
|
<head>
|
||||||
<%= render 'layouts/head_tags' %>
|
<%= render 'layouts/head_tags' %>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= csp_meta_tag %>
|
<%= csp_meta_tag %>
|
||||||
<% if ENV['ROLLBAR_CLIENT_TOKEN'] %>
|
<% if ENV['ROLLBAR_CLIENT_TOKEN'] %>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<form action="<%= url_for %>" method="get" class="items-center hidden md:flex">
|
<form action="<%= url_for %>" method="get" class="items-center flex">
|
||||||
<% if params[:status].present? %>
|
<% if params[:status].present? %>
|
||||||
<input name="status" value="<%= params[:status] %>" class="hidden">
|
<input name="status" value="<%= params[:status] %>" class="hidden">
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -9,7 +9,9 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<input id="search" name="q" value="<%= params[:q] %>" class="input input-ghost text-lg pr-10 -mr-12 <%= 'pl-8 input-outlined' if params[:q].present? %>" placeholder="<%= local_assigns[:placeholder] %>">
|
<search-input data-title="<%= local_assigns[:title_selector] || 'h1' %>">
|
||||||
|
<input id="search" name="q" value="<%= params[:q] %>" class="input input-ghost text-lg pr-10 -mr-12 w-0 md:w-64 <%= 'pl-8 input-outlined w-64' if params[:q].present? %>" placeholder="<%= local_assigns[:placeholder] %>">
|
||||||
|
</search-input>
|
||||||
<button type="submit" title="Search" class="btn btn-ghost btn-circle" onclick="window.search.value || document.activeElement === window.search ? null : [event.preventDefault(), window.search.focus()]">
|
<button type="submit" title="Search" class="btn btn-ghost btn-circle" onclick="window.search.value || document.activeElement === window.search ? null : [event.preventDefault(), window.search.focus()]">
|
||||||
<span class="enabled">
|
<span class="enabled">
|
||||||
<%= svg_icon('search', class: 'w-6 h-6 stroke-2') %>
|
<%= svg_icon('search', class: 'w-6 h-6 stroke-2') %>
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mb-4 items-center">
|
<div class="flex justify-between mb-4 items-center">
|
||||||
<h1 class="text-4xl font-bold">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
<div>
|
||||||
|
<h1 class="text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||||
|
</div>
|
||||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||||
<%= render 'shared/search_input', placeholder: 'Search...' %>
|
<%= render 'shared/search_input', placeholder: 'Search...' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<div class="mr-2">
|
<div class="mr-2">
|
||||||
<%= render 'dashboard/toggle_view', selected: 'submissions' %>
|
<%= render 'dashboard/toggle_view', selected: 'submissions' %>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="text-3xl sm:text-4xl font-bold">Submissions</h1>
|
<h1 class="text-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex space-x-2">
|
<div class="flex space-x-2">
|
||||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mb-4 items-center">
|
<div class="flex justify-between mb-4 items-center">
|
||||||
<h1 class="text-4xl font-bold flex items-center space-x-2">
|
<h1 class="text-4xl font-bold flex items-center space-x-2 md:flex <%= 'hidden' if params[:q].present? %>">
|
||||||
<%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %>
|
<%= svg_icon('folder', class: 'w-9 h-9 flex-shrink-0') %>
|
||||||
<span class="peer">
|
<span class="peer">
|
||||||
<%= @template_folder.name %>
|
<%= @template_folder.name %>
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
<div class="font-medium items-start w-full group-hover:link text-sm flex space-x-1">
|
<div class="font-medium items-start w-full group-hover:link text-sm flex space-x-1">
|
||||||
<%= svg_icon('file_text', class: 'w-4 h-4 mt-0.5 flex-shrink-0') %>
|
<%= svg_icon('file_text', class: 'w-4 h-4 mt-0.5 flex-shrink-0') %>
|
||||||
<span style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
<span style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||||
<%= template.name %>
|
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
||||||
<%= svg_icon('arrow_right', class: 'w-4 h-4 sm:inline group-hover:visible invisible hidden') %>
|
<%= svg_icon('arrow_right', class: 'w-4 h-4 sm:inline group-hover:visible invisible hidden') %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-shrink-0 sm:mt-2">
|
<div class="flex-shrink-0 sm:mt-2 max-w-[50%] md:max-w-full">
|
||||||
<div class="flex text-xs flex-col text-base-content/60 space-y-0.5">
|
<div class="flex text-xs flex-col text-base-content/60 space-y-0.5">
|
||||||
<span class="flex items-center space-x-1">
|
<span class="flex items-center space-x-1">
|
||||||
<%= svg_icon('user', class: 'w-4 h-4 flex-shrink-0') %>
|
<%= svg_icon('user', class: 'w-4 h-4 flex-shrink-0') %>
|
||||||
@@ -195,6 +195,11 @@
|
|||||||
<%= button_to button_title(title: nil, disabled_with: 'Arch', icon: svg_icon('archive', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Archive', method: :delete, onclick: 'event.stopPropagation()' %>
|
<%= button_to button_title(title: nil, disabled_with: 'Arch', icon: svg_icon('archive', class: 'w-6 h-6')), submission_path(submission), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Archive', method: :delete, onclick: 'event.stopPropagation()' %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if local_assigns[:archived] && can?(:destroy, submission) %>
|
||||||
|
<span data-tip="Remove" class="sm:tooltip tooltip-top">
|
||||||
|
<%= button_to button_title(title: nil, disabled_with: 'Rem', icon: svg_icon('trash', class: 'w-6 h-6')), submission_path(submission, permanently: true), class: 'btn btn-outline btn-sm w-full md:w-fit', form: { class: 'flex' }, title: 'Remove', method: :delete, data: { turbo_confirm: 'Submission deletion is irreversible and will permanently remove all associated signed documents with it. Are you sure?' }, onclick: 'event.stopPropagation()' %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="h-36 relative group">
|
<div class="h-36 relative group">
|
||||||
<a href="<%= template_path(template) %>" class="flex h-full flex-col justify-between rounded-2xl pt-6 px-7 w-full bg-base-200 peer">
|
<a href="<%= template_path(template) %>" class="flex h-full flex-col justify-between rounded-2xl pt-6 px-7 w-full bg-base-200 peer">
|
||||||
<div class="pb-4 text-xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
<div class="pb-4 text-xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||||
<%= template.name %>
|
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="pb-6 pt-1 space-y-1">
|
<div class="pb-6 pt-1 space-y-1">
|
||||||
<p class="flex items-center space-x-1 text-xs text-base-content/60">
|
<p class="flex items-center space-x-1 text-xs text-base-content/60">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="flex flex-col items-start md:flex-row space-y-2 md:space-y-0 md:space-x-2 md:justify-between md:items-start mb-6 md:mb-3">
|
<div class="flex flex-col items-start md:flex-row space-y-2 md:space-y-0 md:space-x-2 md:justify-between md:items-start mb-6 md:mb-3">
|
||||||
<div class="relative flex items-start justify-between w-full space-x-0">
|
<div class="relative flex items-start justify-between w-full space-x-0">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-4xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
<h1 class="text-3xl md:text-4xl font-semibold" style="overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;">
|
||||||
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
<% template.name.split(/(_)/).each do |item| %><%= item %><wbr><% end %>
|
||||||
<% if template.archived_at? %>
|
<% if template.archived_at? %>
|
||||||
<span class="ml-1 badge badge-outline badge-lg align-middle">Archived</span>
|
<span class="ml-1 badge badge-outline badge-lg align-middle">Archived</span>
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
<% if !@pagy.count.zero? || params[:q].present? || params[:status].present? %>
|
<% if !@pagy.count.zero? || params[:q].present? || params[:status].present? %>
|
||||||
<div class="<%= is_show_tabs ? 'mb-4' : 'mb-6' %>">
|
<div class="<%= is_show_tabs ? 'mb-4' : 'mb-6' %>">
|
||||||
<div class="flex justify-between items-center md:items-end">
|
<div class="flex justify-between items-center md:items-end">
|
||||||
<p class="text-3xl font-bold">Submissions</p>
|
<div>
|
||||||
|
<h2 class="text-3xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h2>
|
||||||
|
</div>
|
||||||
<div class="flex justify-end space-x-2">
|
<div class="flex justify-end space-x-2">
|
||||||
<% if params[:q].present? || params[:status].present? || @pagy.pages > 1 %>
|
<% if params[:q].present? || params[:status].present? || @pagy.pages > 1 %>
|
||||||
<%= render 'shared/search_input' %>
|
<%= render 'shared/search_input', title_selector: 'h2' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to new_template_submissions_export_path(@template), class: 'hidden md:flex btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
|
<%= link_to new_template_submissions_export_path(@template), class: 'hidden md:flex btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
|
||||||
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
|
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mb-4 items-center">
|
<div class="flex justify-between mb-4 items-center">
|
||||||
<h1 class="text-4xl font-bold"><span class="hidden md:inline">Document</span> Templates <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
<div>
|
||||||
|
<h1 class="text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>"><span class="hidden md:inline">Document</span> Templates <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||||
|
</div>
|
||||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
<% if params[:q].present? || @pagy.pages > 1 %>
|
||||||
<%= render 'shared/search_input', placeholder: 'Search...' %>
|
<%= render 'shared/search_input', placeholder: 'Search...' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between mb-6 md:items-end flex-col md:flex-row">
|
<div class="flex justify-between mb-6 md:items-end flex-col md:flex-row">
|
||||||
<p class="text-3xl font-bold">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></p>
|
<div>
|
||||||
<div class="flex space-x-2 mt-3 md:mt-0">
|
<h1 class="text-3xl font-bold md:block">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
|
||||||
<% if params[:q].present? || @pagy.pages > 1 %>
|
</div>
|
||||||
<%= render 'shared/search_input' %>
|
<div class="flex space-x-2 mt-3 md:mt-0 justify-end">
|
||||||
<% end %>
|
<%= render 'shared/search_input' %>
|
||||||
<%= link_to new_template_submissions_export_path(@template), class: 'order-3 md:order-1 btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
|
<%= link_to new_template_submissions_export_path(@template), class: 'order-3 md:order-1 btn btn-ghost text-base', data: { turbo_frame: 'modal' } do %>
|
||||||
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
|
<%= svg_icon('download', class: 'w-6 h-6 stroke-2') %>
|
||||||
<span>Export</span>
|
<span>Export</span>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<%= render 'dashboard/toggle_view', selected: 'templates' %>
|
<%= render 'dashboard/toggle_view', selected: 'templates' %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<h1 class="text-3xl sm:text-4xl font-bold"><span class="hidden md:inline">Document</span> Templates</h1>
|
<h1 class="text-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>"><span class="hidden md:inline">Document</span> Templates</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex space-x-2">
|
<div class="flex space-x-2">
|
||||||
<% if params[:q].present? || @pagy.pages > 1 || @template_folders.present? %>
|
<% if params[:q].present? || @pagy.pages > 1 || @template_folders.present? %>
|
||||||
|
|||||||
@@ -126,39 +126,32 @@ Rails.application.configure do
|
|||||||
config.lograge.enabled = true
|
config.lograge.enabled = true
|
||||||
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']
|
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']
|
||||||
|
|
||||||
if ENV['MULTITENANT'] == 'true'
|
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 =
|
params =
|
||||||
begin
|
begin
|
||||||
controller.request.try(:params) || {}
|
controller.request.try(:params) || {}
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
fwd: controller.request.remote_ip,
|
fwd: controller.request.remote_ip,
|
||||||
params: {
|
params: {
|
||||||
id: params[:id],
|
id: params[:id],
|
||||||
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
|
template_id: params[:template_id],
|
||||||
slug: (params[:slug] ||
|
submission_id: params[:submission_id],
|
||||||
params[:submitter_slug] ||
|
submitter_id: params[:submitter_id],
|
||||||
params[:submission_slug] ||
|
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
|
||||||
params[:submit_form_slug] ||
|
slug: (params[:slug] ||
|
||||||
params[:template_slug]).to_s.last(5)
|
params[:submitter_slug] ||
|
||||||
}.compact_blank,
|
params[:submission_slug] ||
|
||||||
host: controller.request.host,
|
params[:submit_form_slug] ||
|
||||||
uid: controller.instance_variable_get(:@current_user).try(:id)
|
params[:template_slug]).to_s.first(5)
|
||||||
}
|
}.compact_blank,
|
||||||
end
|
host: controller.request.host,
|
||||||
else
|
uid: controller.instance_variable_get(:@current_user).try(:id)
|
||||||
config.lograge.formatter = Lograge::Formatters::Json.new
|
}
|
||||||
|
|
||||||
config.lograge.custom_payload do |controller|
|
|
||||||
{
|
|
||||||
fwd: controller.request.remote_ip
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -49,6 +49,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
scope 'events' do
|
scope 'events' do
|
||||||
resources :form_events, only: %i[index], path: 'form/:type'
|
resources :form_events, only: %i[index], path: 'form/:type'
|
||||||
|
resources :submission_events, only: %i[index], path: 'submission/:type'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,4 +7,4 @@ queues:
|
|||||||
|
|
||||||
production:
|
production:
|
||||||
:concurrency: 15
|
:concurrency: 15
|
||||||
:max_retries: 5
|
:max_retries: 3
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddAccountIdToSubmitters < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
add_reference :submitters, :account, index: false, null: true
|
||||||
|
|
||||||
|
add_index :submitters, %i[account_id id]
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class PopulateSubmitterAccountId < ActiveRecord::Migration[7.1]
|
||||||
|
disable_ddl_transaction
|
||||||
|
|
||||||
|
class MigrationSubmitter < ApplicationRecord
|
||||||
|
self.table_name = 'submitters'
|
||||||
|
belongs_to :submission, class_name: 'MigrationSubmission'
|
||||||
|
end
|
||||||
|
|
||||||
|
class MigrationSubmission < ApplicationRecord
|
||||||
|
self.table_name = 'submissions'
|
||||||
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
MigrationSubmitter.where(account_id: nil).preload(:submission).find_each do |submitter|
|
||||||
|
submitter.update_columns(account_id: submitter.submission.account_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
if MigrationSubmitter.exists?(account_id: nil)
|
||||||
|
MigrationSubmitter.where(account_id: nil).preload(:submission).find_each do |submitter|
|
||||||
|
submitter.update_columns(account_id: submitter.submission.account_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
change_column_null :submitters, :account_id, false
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class UpdateSubmissionAccountIdIndex < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
add_index :submissions, %i[account_id id]
|
||||||
|
remove_index :submissions, :account_id
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RemoveActiveStorageUniqIndex < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
remove_index :active_storage_attachments, %i[record_type record_id name blob_id],
|
||||||
|
unique: true,
|
||||||
|
name: 'index_active_storage_attachments_uniqueness'
|
||||||
|
|
||||||
|
add_index :active_storage_attachments, %i[record_type record_id name blob_id]
|
||||||
|
end
|
||||||
|
end
|
||||||
+5
-3
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
ActiveRecord::Schema[7.1].define(version: 2024_08_16_121641) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
|||||||
t.bigint "blob_id", null: false
|
t.bigint "blob_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
||||||
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
t.index ["record_type", "record_id", "name", "blob_id"], name: "idx_on_record_type_record_id_name_blob_id_0be5805727"
|
||||||
t.index ["uuid"], name: "index_active_storage_attachments_on_uuid"
|
t.index ["uuid"], name: "index_active_storage_attachments_on_uuid"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
|||||||
t.text "preferences", null: false
|
t.text "preferences", null: false
|
||||||
t.bigint "account_id", null: false
|
t.bigint "account_id", null: false
|
||||||
t.datetime "expire_at"
|
t.datetime "expire_at"
|
||||||
t.index ["account_id"], name: "index_submissions_on_account_id"
|
t.index ["account_id", "id"], name: "index_submissions_on_account_id_and_id"
|
||||||
t.index ["created_by_user_id"], name: "index_submissions_on_created_by_user_id"
|
t.index ["created_by_user_id"], name: "index_submissions_on_created_by_user_id"
|
||||||
t.index ["slug"], name: "index_submissions_on_slug", unique: true
|
t.index ["slug"], name: "index_submissions_on_slug", unique: true
|
||||||
t.index ["template_id"], name: "index_submissions_on_template_id"
|
t.index ["template_id"], name: "index_submissions_on_template_id"
|
||||||
@@ -243,6 +243,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_01_125558) do
|
|||||||
t.string "external_id"
|
t.string "external_id"
|
||||||
t.text "preferences", null: false
|
t.text "preferences", null: false
|
||||||
t.text "metadata", null: false
|
t.text "metadata", null: false
|
||||||
|
t.bigint "account_id", null: false
|
||||||
|
t.index ["account_id", "id"], name: "index_submitters_on_account_id_and_id"
|
||||||
t.index ["email"], name: "index_submitters_on_email"
|
t.index ["email"], name: "index_submitters_on_email"
|
||||||
t.index ["external_id"], name: "index_submitters_on_external_id"
|
t.index ["external_id"], name: "index_submitters_on_external_id"
|
||||||
t.index ["slug"], name: "index_submitters_on_slug", unique: true
|
t.index ["slug"], name: "index_submitters_on_slug", unique: true
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ class Ability
|
|||||||
can :manage, TemplateFolder, account_id: user.account_id
|
can :manage, TemplateFolder, account_id: user.account_id
|
||||||
can :manage, TemplateSharing, template: { account_id: user.account_id }
|
can :manage, TemplateSharing, template: { account_id: user.account_id }
|
||||||
can :manage, Submission, account_id: user.account_id
|
can :manage, Submission, account_id: user.account_id
|
||||||
can :manage, Submitter, submission: { account_id: user.account_id }
|
can :manage, Submitter, account_id: user.account_id
|
||||||
can :manage, User, account_id: user.account_id
|
can :manage, User, account_id: user.account_id
|
||||||
can :manage, EncryptedConfig, account_id: user.account_id
|
can :manage, EncryptedConfig, account_id: user.account_id
|
||||||
can :manage, EncryptedUserConfig, user_id: user.id
|
can :manage, EncryptedUserConfig, user_id: user.id
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ActionMailerConfigsInterceptor
|
module ActionMailerConfigsInterceptor
|
||||||
OPEN_TIMEOUT = 15
|
OPEN_TIMEOUT = ENV.fetch('SMTP_OPEN_TIMEOUT', '15').to_i
|
||||||
READ_TIMEOUT = 25
|
READ_TIMEOUT = ENV.fetch('SMTP_READ_TIMEOUT', '25').to_i
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ module Submissions
|
|||||||
|
|
||||||
submission.submitters.new(email: normalize_email(email),
|
submission.submitters.new(email: normalize_email(email),
|
||||||
uuid: template.submitters.first['uuid'],
|
uuid: template.submitters.first['uuid'],
|
||||||
|
account_id: user.account_id,
|
||||||
preferences:,
|
preferences:,
|
||||||
sent_at: mark_as_sent ? Time.current : nil)
|
sent_at: mark_as_sent ? Time.current : nil)
|
||||||
|
|
||||||
|
|||||||
@@ -155,16 +155,14 @@ module Submissions
|
|||||||
submitter_preferences = Submitters.normalize_preferences(submission.account, user, attrs)
|
submitter_preferences = Submitters.normalize_preferences(submission.account, user, attrs)
|
||||||
values = attrs[:values] || {}
|
values = attrs[:values] || {}
|
||||||
|
|
||||||
phone_field_uuid =
|
phone_field_uuid = find_phone_field(submission, values)&.dig('uuid')
|
||||||
(submission.template_fields || submission.template.fields).find do |f|
|
|
||||||
values[f['uuid']].present? && f['type'] == 'phone'
|
|
||||||
end&.dig('uuid')
|
|
||||||
|
|
||||||
submitter =
|
submitter =
|
||||||
submission.submitters.new(
|
submission.submitters.new(
|
||||||
email:,
|
email:,
|
||||||
phone: (attrs[:phone] || values[phone_field_uuid]).to_s.gsub(/[^0-9+]/, ''),
|
phone: (attrs[:phone] || values[phone_field_uuid]).to_s.gsub(/[^0-9+]/, ''),
|
||||||
name: attrs[:name],
|
name: attrs[:name],
|
||||||
|
account_id: user.account_id,
|
||||||
external_id: attrs[:external_id].presence || attrs[:application_key],
|
external_id: attrs[:external_id].presence || attrs[:application_key],
|
||||||
completed_at: attrs[:completed].present? ? Time.current : nil,
|
completed_at: attrs[:completed].present? ? Time.current : nil,
|
||||||
values: values.except(phone_field_uuid),
|
values: values.except(phone_field_uuid),
|
||||||
@@ -183,6 +181,12 @@ module Submissions
|
|||||||
submitter
|
submitter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_phone_field(submission, values)
|
||||||
|
(submission.template_fields || submission.template.fields).find do |f|
|
||||||
|
values[f['uuid']].present? && f['type'] == 'phone'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def assign_completed_attributes(submitter)
|
def assign_completed_attributes(submitter)
|
||||||
submitter.values = Submitters::SubmitValues.merge_default_values(submitter)
|
submitter.values = Submitters::SubmitValues.merge_default_values(submitter)
|
||||||
submitter.values = Submitters::SubmitValues.merge_formula_values(submitter)
|
submitter.values = Submitters::SubmitValues.merge_formula_values(submitter)
|
||||||
|
|||||||
@@ -58,13 +58,15 @@ module Submissions
|
|||||||
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 = build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
||||||
uuid: item['attachment_uuid'],
|
pdf = normalize_image_pdf(pdf)
|
||||||
name: item['name'])
|
|
||||||
|
|
||||||
image_pdfs << pdf if original_documents.find { |a| a.uuid == item['attachment_uuid'] }.image?
|
image_pdfs << pdf
|
||||||
|
end
|
||||||
|
|
||||||
attachment
|
build_pdf_attachment(pdf:, submitter:, pkcs:, tsa_url:,
|
||||||
|
uuid: item['attachment_uuid'],
|
||||||
|
name: item['name'])
|
||||||
end
|
end
|
||||||
|
|
||||||
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
|
return result_attachments.map { |e| e.tap(&:save!) } if image_pdfs.size < 2
|
||||||
@@ -74,6 +76,8 @@ module Submissions
|
|||||||
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
pdf.pages.each { |page| doc.pages << doc.import(page) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
images_pdf = normalize_image_pdf(images_pdf)
|
||||||
|
|
||||||
images_pdf_attachment =
|
images_pdf_attachment =
|
||||||
build_pdf_attachment(
|
build_pdf_attachment(
|
||||||
pdf: images_pdf,
|
pdf: images_pdf,
|
||||||
@@ -590,6 +594,14 @@ module Submissions
|
|||||||
pdf
|
pdf
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize_image_pdf(pdf)
|
||||||
|
io = StringIO.new
|
||||||
|
pdf.write(io)
|
||||||
|
io.rewind
|
||||||
|
|
||||||
|
HexaPDF::Document.new(io:)
|
||||||
|
end
|
||||||
|
|
||||||
def sign_reason(name)
|
def sign_reason(name)
|
||||||
format(SIGN_REASON, name:)
|
format(SIGN_REASON, name:)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,5 +4,9 @@ FactoryBot.define do
|
|||||||
factory :submitter do
|
factory :submitter do
|
||||||
submission
|
submission
|
||||||
email { Faker::Internet.email }
|
email { Faker::Internet.email }
|
||||||
|
|
||||||
|
before(:create) do |submitter, _|
|
||||||
|
submitter.account_id = submitter.submission.account_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user