mirror of
https://github.com/docusealco/docuseal
synced 2026-11-05 06:42:32 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d813e184b | ||
|
|
fd23674e87 | ||
|
|
3b9d35acf1 | ||
|
|
17fc6e2f1c | ||
|
|
2e132d8b5a | ||
|
|
53bef85a63 | ||
|
|
99ad6e36ac | ||
|
|
bfa41ac35f | ||
|
|
bc4414a368 | ||
|
|
26ae5f1d80 | ||
|
|
be4962a02a | ||
|
|
e72090c2e0 | ||
|
|
ad8bca8bf4 | ||
|
|
22be3b37cf | ||
|
|
cfc32ee522 | ||
|
|
10fbdf6612 | ||
|
|
3604fb6461 | ||
|
|
24392d0258 | ||
|
|
4ab1065773 | ||
|
|
50b0f7e5ed |
No files matched your search
@@ -68,6 +68,9 @@ RSpec/ExampleLength:
|
|||||||
RSpec/MultipleMemoizedHelpers:
|
RSpec/MultipleMemoizedHelpers:
|
||||||
Max: 6
|
Max: 6
|
||||||
|
|
||||||
|
Metrics/BlockNesting:
|
||||||
|
Max: 4
|
||||||
|
|
||||||
Rails/I18nLocaleTexts:
|
Rails/I18nLocaleTexts:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ module Api
|
|||||||
:completed, :phone, :application_key, :external_id, :reply_to, :go_to_last,
|
:completed, :phone, :application_key, :external_id, :reply_to, :go_to_last,
|
||||||
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
||||||
fields: [:name, :uuid, :default_value, :value, :title, :description,
|
fields: [:name, :uuid, :default_value, :value, :title, :description,
|
||||||
:readonly, :redacted, :validation_pattern, :invalid_message,
|
:readonly, :validation_pattern, :invalid_message,
|
||||||
{ default_value: [], value: [], preferences: {} }] }]]
|
{ default_value: [], value: [], preferences: {} }] }]]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ module Api
|
|||||||
:completed, :phone, :application_key, :external_id, :go_to_last,
|
:completed, :phone, :application_key, :external_id, :go_to_last,
|
||||||
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
|
||||||
fields: [[:name, :uuid, :default_value, :value,
|
fields: [[:name, :uuid, :default_value, :value,
|
||||||
:readonly, :redacted, :validation_pattern, :invalid_message,
|
:readonly, :validation_pattern, :invalid_message,
|
||||||
{ default_value: [], value: [], preferences: {} }]] }
|
{ default_value: [], value: [], preferences: {} }]] }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ module Api
|
|||||||
|
|
||||||
preview_image_attachments =
|
preview_image_attachments =
|
||||||
ActiveStorage::Attachment.joins(:blob)
|
ActiveStorage::Attachment.joins(:blob)
|
||||||
.where(blob: { filename: '0.jpg' })
|
.where(blob: { filename: ['0.png', '0.jpg'] })
|
||||||
.where(record_id: schema_documents.map(&:id),
|
.where(record_id: schema_documents.map(&:id),
|
||||||
record_type: 'ActiveStorage::Attachment',
|
record_type: 'ActiveStorage::Attachment',
|
||||||
name: :preview_images)
|
name: :preview_images)
|
||||||
@@ -97,7 +97,7 @@ module Api
|
|||||||
:name,
|
:name,
|
||||||
:external_id,
|
:external_id,
|
||||||
{
|
{
|
||||||
submitters: [%i[name uuid is_requester linked_to_uuid email]],
|
submitters: [%i[name uuid is_requester invite_by_uuid invite_by_uuid linked_to_uuid email]],
|
||||||
fields: [[:uuid, :submitter_uuid, :name, :type,
|
fields: [[:uuid, :submitter_uuid, :name, :type,
|
||||||
:required, :readonly, :default_value,
|
:required, :readonly, :default_value,
|
||||||
:title, :description,
|
:title, :description,
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ class StartFormController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@submitter = @template.submissions.new(account_id: @template.account_id)
|
@submitter = @template.submissions.new(account_id: @template.account_id)
|
||||||
.submitters.new(uuid: filter_undefined_submitters(@template).first['uuid'])
|
.submitters.new(uuid: (filter_undefined_submitters(@template).first ||
|
||||||
|
@template.submitters.first)['uuid'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -22,7 +23,7 @@ class StartFormController < ApplicationController
|
|||||||
if @submitter.completed_at?
|
if @submitter.completed_at?
|
||||||
redirect_to start_form_completed_path(@template.slug, email: submitter_params[:email])
|
redirect_to start_form_completed_path(@template.slug, email: submitter_params[:email])
|
||||||
else
|
else
|
||||||
if filter_undefined_submitters(@template).size > 2 && @submitter.new_record?
|
if filter_undefined_submitters(@template).size > 1 && @submitter.new_record?
|
||||||
@error_message = 'Not found'
|
@error_message = 'Not found'
|
||||||
|
|
||||||
return render :show
|
return render :show
|
||||||
@@ -68,7 +69,7 @@ class StartFormController < ApplicationController
|
|||||||
(Submitter.where(submission: template.submissions).find_by(slug: params[:resubmit]) if params[:resubmit].present?)
|
(Submitter.where(submission: template.submissions).find_by(slug: params[:resubmit]) if params[:resubmit].present?)
|
||||||
|
|
||||||
submitter.assign_attributes(
|
submitter.assign_attributes(
|
||||||
uuid: filter_undefined_submitters(template).first['uuid'],
|
uuid: (filter_undefined_submitters(template).first || @template.submitters.first)['uuid'],
|
||||||
ip: request.remote_ip,
|
ip: request.remote_ip,
|
||||||
ua: request.user_agent,
|
ua: request.user_agent,
|
||||||
values: resubmit_submitter&.preferences&.fetch('default_values', nil) || {},
|
values: resubmit_submitter&.preferences&.fetch('default_values', nil) || {},
|
||||||
@@ -94,9 +95,7 @@ class StartFormController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def filter_undefined_submitters(template)
|
def filter_undefined_submitters(template)
|
||||||
template.submitters.select do |item|
|
Templates.filter_undefined_submitters(template)
|
||||||
item['linked_to_uuid'].blank? && item['is_requester'].blank? && item['email'].blank?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def submitter_params
|
def submitter_params
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class SubmitFormInviteController < ApplicationController
|
||||||
|
skip_before_action :authenticate_user!
|
||||||
|
skip_authorization_check
|
||||||
|
|
||||||
|
def create
|
||||||
|
submitter = Submitter.find_by!(slug: params[:submit_form_slug])
|
||||||
|
|
||||||
|
return head :unprocessable_entity unless can_invite?(submitter)
|
||||||
|
|
||||||
|
invite_submitters = filter_invite_submitters(submitter)
|
||||||
|
|
||||||
|
ApplicationRecord.transaction do
|
||||||
|
invite_submitters.each do |item|
|
||||||
|
attrs = submitters_attributes.find { |e| e[:uuid] == item['uuid'] }
|
||||||
|
|
||||||
|
next unless attrs
|
||||||
|
|
||||||
|
submitter.submission.submitters.create!(**attrs, account_id: submitter.account_id)
|
||||||
|
|
||||||
|
SubmissionEvents.create_with_tracking_data(submitter, 'invite_party', request, { uuid: submitter.uuid })
|
||||||
|
end
|
||||||
|
|
||||||
|
submitter.submission.update!(submitters_order: :preserved)
|
||||||
|
end
|
||||||
|
|
||||||
|
submitter.submission.submitters.reload
|
||||||
|
|
||||||
|
if invite_submitters.all? { |s| submitter.submission.submitters.any? { |e| e.uuid == s['uuid'] } }
|
||||||
|
Submitters::SubmitValues.call(submitter, ActionController::Parameters.new(completed: 'true'), request)
|
||||||
|
|
||||||
|
head :ok
|
||||||
|
else
|
||||||
|
head :unprocessable_entity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def can_invite?(submitter)
|
||||||
|
!submitter.declined_at? &&
|
||||||
|
!submitter.completed_at? &&
|
||||||
|
!submitter.submission.archived_at? &&
|
||||||
|
!submitter.submission.expired? &&
|
||||||
|
!submitter.submission.template.archived_at?
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter_invite_submitters(submitter)
|
||||||
|
(submitter.submission.template_submitters || submitter.submission.template.submitters).select do |s|
|
||||||
|
s['invite_by_uuid'] == submitter.uuid && submitter.submission.submitters.none? { |e| e.uuid == s['uuid'] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def submitters_attributes
|
||||||
|
params.require(:submission).permit(submitters: [%i[uuid email]]).fetch(:submitters, [])
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -103,7 +103,7 @@ class TemplatesController < ApplicationController
|
|||||||
params.require(:template).permit(
|
params.require(:template).permit(
|
||||||
:name,
|
:name,
|
||||||
{ schema: [%i[attachment_uuid name]],
|
{ schema: [%i[attachment_uuid name]],
|
||||||
submitters: [%i[name uuid is_requester linked_to_uuid email]],
|
submitters: [%i[name uuid is_requester linked_to_uuid invite_by_uuid email]],
|
||||||
fields: [[:uuid, :submitter_uuid, :name, :type,
|
fields: [[:uuid, :submitter_uuid, :name, :type,
|
||||||
:required, :readonly, :default_value,
|
:required, :readonly, :default_value,
|
||||||
:title, :description,
|
:title, :description,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class TemplatesPreferencesController < ApplicationController
|
|||||||
authorize!(:update, @template)
|
authorize!(:update, @template)
|
||||||
|
|
||||||
@template.preferences = @template.preferences.merge(template_params[:preferences])
|
@template.preferences = @template.preferences.merge(template_params[:preferences])
|
||||||
@template.preferences = @template.preferences.reject { |_, v| v.is_a?(String) && v.blank? }
|
@template.preferences = @template.preferences.reject { |_, v| (v.is_a?(String) || v.is_a?(Hash)) && v.blank? }
|
||||||
@template.save!
|
@template.save!
|
||||||
|
|
||||||
head :ok
|
head :ok
|
||||||
@@ -23,12 +23,16 @@ class TemplatesPreferencesController < ApplicationController
|
|||||||
documents_copy_email_subject documents_copy_email_body
|
documents_copy_email_subject documents_copy_email_body
|
||||||
documents_copy_email_enabled documents_copy_email_attach_audit
|
documents_copy_email_enabled documents_copy_email_attach_audit
|
||||||
completed_notification_email_attach_documents
|
completed_notification_email_attach_documents
|
||||||
|
completed_redirect_url
|
||||||
completed_notification_email_subject completed_notification_email_body
|
completed_notification_email_subject completed_notification_email_body
|
||||||
completed_notification_email_enabled completed_notification_email_attach_audit]
|
completed_notification_email_enabled completed_notification_email_attach_audit] +
|
||||||
|
[completed_message: %i[title body]]
|
||||||
).tap do |attrs|
|
).tap do |attrs|
|
||||||
attrs[:preferences] = attrs[:preferences].transform_values do |value|
|
attrs[:preferences] = attrs[:preferences].transform_values do |value|
|
||||||
if %w[true false].include?(value)
|
if %w[true false].include?(value)
|
||||||
value == 'true'
|
value == 'true'
|
||||||
|
elsif value.respond_to?(:compact_blank)
|
||||||
|
value.compact_blank
|
||||||
else
|
else
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,16 +18,18 @@ class TemplatesRecipientsController < ApplicationController
|
|||||||
|
|
||||||
def submitters_params
|
def submitters_params
|
||||||
params.require(:template).permit(
|
params.require(:template).permit(
|
||||||
submitters: [%i[name uuid is_requester linked_to_uuid email option]]
|
submitters: [%i[name uuid is_requester invite_by_uuid linked_to_uuid email option]]
|
||||||
).fetch(:submitters, {}).values.filter_map do |s|
|
).fetch(:submitters, {}).values.filter_map do |s|
|
||||||
next if s[:uuid].blank?
|
next if s[:uuid].blank?
|
||||||
|
|
||||||
if s[:is_requester] == '1'
|
if s[:is_requester] == '1' && s[:invite_by_uuid].blank?
|
||||||
s[:is_requester] = true
|
s[:is_requester] = true
|
||||||
else
|
else
|
||||||
s.delete(:is_requester)
|
s.delete(:is_requester)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
s.delete(:invite_by_uuid) if s[:invite_by_uuid].blank?
|
||||||
|
|
||||||
option = s.delete(:option)
|
option = s.delete(:option)
|
||||||
|
|
||||||
if option.present?
|
if option.present?
|
||||||
@@ -38,8 +40,11 @@ class TemplatesRecipientsController < ApplicationController
|
|||||||
s.delete(:is_requester)
|
s.delete(:is_requester)
|
||||||
s.delete(:email)
|
s.delete(:email)
|
||||||
s.delete(:linked_to_uuid)
|
s.delete(:linked_to_uuid)
|
||||||
|
s.delete(:invite_by_uuid)
|
||||||
when /\Alinked_to_(.*)\z/
|
when /\Alinked_to_(.*)\z/
|
||||||
s[:linked_to_uuid] = ::Regexp.last_match(-1)
|
s[:linked_to_uuid] = ::Regexp.last_match(-1)
|
||||||
|
when /\Ainvite_by_(.*)\z/
|
||||||
|
s[:invite_by_uuid] = ::Regexp.last_match(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import PasswordInput from './elements/password_input'
|
|||||||
import SearchInput from './elements/search_input'
|
import SearchInput from './elements/search_input'
|
||||||
import ToggleAttribute from './elements/toggle_attribute'
|
import ToggleAttribute from './elements/toggle_attribute'
|
||||||
import LinkedInput from './elements/linked_input'
|
import LinkedInput from './elements/linked_input'
|
||||||
|
import CheckboxGroup from './elements/checkbox_group'
|
||||||
|
|
||||||
import * as TurboInstantClick from './lib/turbo_instant_click'
|
import * as TurboInstantClick from './lib/turbo_instant_click'
|
||||||
|
|
||||||
@@ -93,6 +94,7 @@ safeRegisterElement('password-input', PasswordInput)
|
|||||||
safeRegisterElement('search-input', SearchInput)
|
safeRegisterElement('search-input', SearchInput)
|
||||||
safeRegisterElement('toggle-attribute', ToggleAttribute)
|
safeRegisterElement('toggle-attribute', ToggleAttribute)
|
||||||
safeRegisterElement('linked-input', LinkedInput)
|
safeRegisterElement('linked-input', LinkedInput)
|
||||||
|
safeRegisterElement('checkbox-group', CheckboxGroup)
|
||||||
|
|
||||||
safeRegisterElement('template-builder', class extends HTMLElement {
|
safeRegisterElement('template-builder', class extends HTMLElement {
|
||||||
connectedCallback () {
|
connectedCallback () {
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ button[disabled] .enabled {
|
|||||||
@apply input input-bordered bg-white;
|
@apply input input-bordered bg-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.base-input-slim {
|
||||||
|
@apply input input-bordered bg-white h-10;
|
||||||
|
}
|
||||||
|
|
||||||
.base-textarea {
|
.base-textarea {
|
||||||
@apply textarea textarea-bordered bg-white rounded-3xl;
|
@apply textarea textarea-bordered bg-white rounded-3xl;
|
||||||
}
|
}
|
||||||
@@ -100,7 +104,7 @@ button[disabled] .enabled {
|
|||||||
.autocomplete {
|
.autocomplete {
|
||||||
background: white;
|
background: white;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
font: 14px/22px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
font: 16px/25px "-apple-system", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@apply border border-base-300 mt-1 rounded-md;
|
@apply border border-base-300 mt-1 rounded-md;
|
||||||
@@ -111,7 +115,7 @@ button[disabled] .enabled {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.autocomplete > div {
|
.autocomplete > div {
|
||||||
@apply px-2 py-1 font-normal text-sm;
|
@apply px-2 py-1.5 font-normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.autocomplete .group {
|
.autocomplete .group {
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
export default class extends HTMLElement {
|
||||||
|
connectedCallback () {
|
||||||
|
this.items.forEach((item) => {
|
||||||
|
item.addEventListener('change', (e) => {
|
||||||
|
this.items.forEach((item) => {
|
||||||
|
item.checked = item === e.target && e.target.checked
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
get items () {
|
||||||
|
return this.querySelectorAll('input[type="checkbox"]')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ safeRegisterElement('submission-form', class extends HTMLElement {
|
|||||||
|
|
||||||
this.app = createApp(Form, {
|
this.app = createApp(Form, {
|
||||||
submitter: JSON.parse(this.dataset.submitter),
|
submitter: JSON.parse(this.dataset.submitter),
|
||||||
|
inviteSubmitters: JSON.parse(this.dataset.inviteSubmitters),
|
||||||
canSendEmail: this.dataset.canSendEmail === 'true',
|
canSendEmail: this.dataset.canSendEmail === 'true',
|
||||||
previousSignatureValue: this.dataset.previousSignatureValue,
|
previousSignatureValue: this.dataset.previousSignatureValue,
|
||||||
goToLast: this.dataset.goToLast === 'true',
|
goToLast: this.dataset.goToLast === 'true',
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
:class="{ 'md:px-4': isBreakpointMd }"
|
:class="{ 'md:px-4': isBreakpointMd }"
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
v-if="!isCompleted"
|
v-if="!isCompleted && !isInvite"
|
||||||
ref="form"
|
ref="form"
|
||||||
:action="submitPath"
|
:action="submitPath"
|
||||||
method="post"
|
method="post"
|
||||||
@@ -436,6 +436,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<InviteForm
|
||||||
|
v-else-if="isInvite"
|
||||||
|
:submitters="inviteSubmitters"
|
||||||
|
:submitter-slug="submitterSlug"
|
||||||
|
:authenticity-token="authenticityToken"
|
||||||
|
:url="baseUrl + submitPath + '/invite'"
|
||||||
|
:style="{ maxWidth: isBreakpointMd ? '582px' : '' }"
|
||||||
|
@success="[isInvite = false, performComplete($event)]"
|
||||||
|
/>
|
||||||
<FormCompleted
|
<FormCompleted
|
||||||
v-else
|
v-else
|
||||||
:is-demo="isDemo"
|
:is-demo="isDemo"
|
||||||
@@ -485,6 +494,7 @@ import TextStep from './text_step'
|
|||||||
import NumberStep from './number_step'
|
import NumberStep from './number_step'
|
||||||
import DateStep from './date_step'
|
import DateStep from './date_step'
|
||||||
import MarkdownContent from './markdown_content'
|
import MarkdownContent from './markdown_content'
|
||||||
|
import InviteForm from './invite_form'
|
||||||
import FormCompleted from './completed'
|
import FormCompleted from './completed'
|
||||||
import { IconInnerShadowTop, IconArrowsDiagonal, IconWritingSign, IconArrowsDiagonalMinimize2 } from '@tabler/icons-vue'
|
import { IconInnerShadowTop, IconArrowsDiagonal, IconWritingSign, IconArrowsDiagonalMinimize2 } from '@tabler/icons-vue'
|
||||||
import AppearsOn from './appears_on'
|
import AppearsOn from './appears_on'
|
||||||
@@ -522,6 +532,7 @@ export default {
|
|||||||
IconWritingSign,
|
IconWritingSign,
|
||||||
AttachmentStep,
|
AttachmentStep,
|
||||||
InitialsStep,
|
InitialsStep,
|
||||||
|
InviteForm,
|
||||||
MultiSelectStep,
|
MultiSelectStep,
|
||||||
IconInnerShadowTop,
|
IconInnerShadowTop,
|
||||||
DateStep,
|
DateStep,
|
||||||
@@ -548,6 +559,11 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
inviteSubmitters: {
|
||||||
|
type: Array,
|
||||||
|
required: false,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
withSignatureId: {
|
withSignatureId: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -739,6 +755,7 @@ export default {
|
|||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
isCompleted: false,
|
isCompleted: false,
|
||||||
|
isInvite: false,
|
||||||
isFormVisible: this.expand !== false,
|
isFormVisible: this.expand !== false,
|
||||||
showFillAllRequiredFields: false,
|
showFillAllRequiredFields: false,
|
||||||
currentStep: 0,
|
currentStep: 0,
|
||||||
@@ -1119,7 +1136,7 @@ export default {
|
|||||||
const formData = new FormData(this.$refs.form)
|
const formData = new FormData(this.$refs.form)
|
||||||
const isLastStep = this.currentStep === this.stepFields.length - 1
|
const isLastStep = this.currentStep === this.stepFields.length - 1
|
||||||
|
|
||||||
if (isLastStep && !emptyRequiredField) {
|
if (isLastStep && !emptyRequiredField && !this.inviteSubmitters.length) {
|
||||||
formData.append('completed', 'true')
|
formData.append('completed', 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,18 +1175,10 @@ export default {
|
|||||||
if (emptyRequiredField === nextStep) {
|
if (emptyRequiredField === nextStep) {
|
||||||
this.showFillAllRequiredFields = true
|
this.showFillAllRequiredFields = true
|
||||||
}
|
}
|
||||||
|
} else if (this.inviteSubmitters.length) {
|
||||||
|
this.isInvite = true
|
||||||
} else {
|
} else {
|
||||||
this.isCompleted = true
|
this.performComplete(response)
|
||||||
|
|
||||||
const respData = await response.text()
|
|
||||||
|
|
||||||
if (respData) {
|
|
||||||
this.onComplete(JSON.parse(respData))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.completedRedirectUrl) {
|
|
||||||
window.location.href = this.completedRedirectUrl
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@@ -1185,6 +1194,21 @@ export default {
|
|||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isSubmitting = false
|
this.isSubmitting = false
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
async performComplete (resp) {
|
||||||
|
this.isCompleted = true
|
||||||
|
|
||||||
|
if (resp) {
|
||||||
|
const respData = await resp.text()
|
||||||
|
|
||||||
|
if (respData) {
|
||||||
|
this.onComplete(JSON.parse(respData))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.completedRedirectUrl) {
|
||||||
|
window.location.href = this.completedRedirectUrl
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const en = {
|
|||||||
reviewed: 'Reviewed',
|
reviewed: 'Reviewed',
|
||||||
other: 'Other',
|
other: 'Other',
|
||||||
authored_by_me: 'Authored by me',
|
authored_by_me: 'Authored by me',
|
||||||
|
invite: 'Invite',
|
||||||
|
email: 'Email',
|
||||||
approved_by: 'Approved by',
|
approved_by: 'Approved by',
|
||||||
reviewed_by: 'Reviewed by',
|
reviewed_by: 'Reviewed by',
|
||||||
authored_by: 'Authored by',
|
authored_by: 'Authored by',
|
||||||
@@ -85,6 +87,8 @@ const en = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const es = {
|
const es = {
|
||||||
|
invite: 'Invitar',
|
||||||
|
email: 'Correo electrónico',
|
||||||
approved: 'Aprobado',
|
approved: 'Aprobado',
|
||||||
reviewed: 'Revisado',
|
reviewed: 'Revisado',
|
||||||
other: 'Otro',
|
other: 'Otro',
|
||||||
@@ -170,6 +174,8 @@ const es = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const it = {
|
const it = {
|
||||||
|
invite: 'Invita',
|
||||||
|
email: 'Email',
|
||||||
approved: 'Approvato',
|
approved: 'Approvato',
|
||||||
reviewed: 'Revisionato',
|
reviewed: 'Revisionato',
|
||||||
other: 'Altro',
|
other: 'Altro',
|
||||||
@@ -255,6 +261,8 @@ const it = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const de = {
|
const de = {
|
||||||
|
invite: 'Einladen',
|
||||||
|
email: 'E-Mail',
|
||||||
approved: 'Genehmigt',
|
approved: 'Genehmigt',
|
||||||
reviewed: 'Überprüft',
|
reviewed: 'Überprüft',
|
||||||
other: 'Andere',
|
other: 'Andere',
|
||||||
@@ -340,6 +348,8 @@ const de = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fr = {
|
const fr = {
|
||||||
|
invite: 'Inviter',
|
||||||
|
email: 'Courriel',
|
||||||
approved: 'Approuvé',
|
approved: 'Approuvé',
|
||||||
reviewed: 'Révisé',
|
reviewed: 'Révisé',
|
||||||
other: 'Autre',
|
other: 'Autre',
|
||||||
@@ -425,6 +435,8 @@ const fr = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pl = {
|
const pl = {
|
||||||
|
invite: 'Zaproś',
|
||||||
|
email: 'E-mail',
|
||||||
approved: 'Zaakceptowany',
|
approved: 'Zaakceptowany',
|
||||||
reviewed: 'Przejrzany',
|
reviewed: 'Przejrzany',
|
||||||
other: 'Inny',
|
other: 'Inny',
|
||||||
@@ -510,6 +522,8 @@ const pl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uk = {
|
const uk = {
|
||||||
|
invite: 'Запросити',
|
||||||
|
email: 'Електронна пошта',
|
||||||
approved: 'Затверджено',
|
approved: 'Затверджено',
|
||||||
reviewed: 'Переглянуто',
|
reviewed: 'Переглянуто',
|
||||||
other: 'Інше',
|
other: 'Інше',
|
||||||
@@ -595,6 +609,8 @@ const uk = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cs = {
|
const cs = {
|
||||||
|
invite: 'Pozvat',
|
||||||
|
email: 'E-mail',
|
||||||
approved: 'Schváleno',
|
approved: 'Schváleno',
|
||||||
reviewed: 'Zkontrolováno',
|
reviewed: 'Zkontrolováno',
|
||||||
other: 'Jiné',
|
other: 'Jiné',
|
||||||
@@ -680,6 +696,8 @@ const cs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pt = {
|
const pt = {
|
||||||
|
invite: 'Convidar',
|
||||||
|
email: 'E-mail',
|
||||||
approved: 'Aprovado',
|
approved: 'Aprovado',
|
||||||
reviewed: 'Revisado',
|
reviewed: 'Revisado',
|
||||||
other: 'Outro',
|
other: 'Outro',
|
||||||
@@ -765,6 +783,8 @@ const pt = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const he = {
|
const he = {
|
||||||
|
invite: 'הזמן',
|
||||||
|
email: 'דוא"ל',
|
||||||
approved: 'מאושר',
|
approved: 'מאושר',
|
||||||
reviewed: 'נסקר',
|
reviewed: 'נסקר',
|
||||||
other: 'אחר',
|
other: 'אחר',
|
||||||
@@ -851,6 +871,8 @@ const he = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nl = {
|
const nl = {
|
||||||
|
invite: 'Uitnodigen',
|
||||||
|
email: 'E-mail',
|
||||||
approved: 'Goedgekeurd',
|
approved: 'Goedgekeurd',
|
||||||
reviewed: 'Beoordeeld',
|
reviewed: 'Beoordeeld',
|
||||||
other: 'Anders',
|
other: 'Anders',
|
||||||
@@ -937,6 +959,8 @@ const nl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ar = {
|
const ar = {
|
||||||
|
invite: 'دعوة',
|
||||||
|
email: 'البريد الإلكتروني',
|
||||||
approved: 'موافق عليه',
|
approved: 'موافق عليه',
|
||||||
reviewed: 'تمت مراجعته',
|
reviewed: 'تمت مراجعته',
|
||||||
other: 'آخر',
|
other: 'آخر',
|
||||||
@@ -1022,6 +1046,8 @@ const ar = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ko = {
|
const ko = {
|
||||||
|
invite: '초대하기',
|
||||||
|
email: '이메일',
|
||||||
approved: '승인됨',
|
approved: '승인됨',
|
||||||
reviewed: '검토됨',
|
reviewed: '검토됨',
|
||||||
other: '기타',
|
other: '기타',
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<template>
|
||||||
|
<form
|
||||||
|
ref="form"
|
||||||
|
action="post"
|
||||||
|
method="post"
|
||||||
|
class="mx-auto"
|
||||||
|
@submit.prevent="submit"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="authenticity_token"
|
||||||
|
:value="authenticityToken"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(submitter, index) in submitters"
|
||||||
|
:key="submitter.uuid"
|
||||||
|
:class="{ 'mt-4': index !== 0 }"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
:value="submitter.uuid"
|
||||||
|
hidden
|
||||||
|
name="submission[submitters][][uuid]"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
:for="submitter.uuid"
|
||||||
|
dir="auto"
|
||||||
|
class="label text-2xl"
|
||||||
|
>
|
||||||
|
{{ t('invite') }} {{ submitter.name }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
:id="submitter.uuid"
|
||||||
|
dir="auto"
|
||||||
|
class="base-input !text-2xl w-full"
|
||||||
|
:placeholder="t('email')"
|
||||||
|
type="email"
|
||||||
|
required
|
||||||
|
autofocus="true"
|
||||||
|
name="submission[submitters][][email]"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="mt-6 md:mt-8"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="base-button w-full flex justify-center"
|
||||||
|
:disabled="isSubmitting"
|
||||||
|
>
|
||||||
|
<span class="flex">
|
||||||
|
<IconInnerShadowTop
|
||||||
|
v-if="isSubmitting"
|
||||||
|
class="mr-1 animate-spin"
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
{{ t('submit') }}
|
||||||
|
</span><span
|
||||||
|
v-if="isSubmitting"
|
||||||
|
class="w-6 flex justify-start mr-1"
|
||||||
|
><span>...</span></span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { IconInnerShadowTop } from '@tabler/icons-vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'InviteForm',
|
||||||
|
components: {
|
||||||
|
IconInnerShadowTop
|
||||||
|
},
|
||||||
|
inject: ['t'],
|
||||||
|
props: {
|
||||||
|
submitters: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
authenticityToken: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
submitterSlug: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ['success'],
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isSubmitting: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submit () {
|
||||||
|
this.isSubmitting = true
|
||||||
|
|
||||||
|
return fetch(this.url, {
|
||||||
|
method: 'POST',
|
||||||
|
body: new FormData(this.$refs.form)
|
||||||
|
}).then((response) => {
|
||||||
|
if (response.status === 200) {
|
||||||
|
this.$emit('success')
|
||||||
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
this.isSubmitting = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -147,7 +147,7 @@ export default {
|
|||||||
const textarea = this.$refs.textarea
|
const textarea = this.$refs.textarea
|
||||||
|
|
||||||
textarea.style.height = 'auto'
|
textarea.style.height = 'auto'
|
||||||
textarea.style.height = textarea.scrollHeight + 'px'
|
textarea.style.height = Math.min(250, textarea.scrollHeight) + 'px'
|
||||||
},
|
},
|
||||||
toggleTextArea () {
|
toggleTextArea () {
|
||||||
this.isTextArea = true
|
this.isTextArea = true
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class SubmissionEvent < ApplicationRecord
|
|||||||
phone_verified: 'phone_verified',
|
phone_verified: 'phone_verified',
|
||||||
start_form: 'start_form',
|
start_form: 'start_form',
|
||||||
view_form: 'view_form',
|
view_form: 'view_form',
|
||||||
|
invite_party: 'invite_party',
|
||||||
complete_form: 'complete_form',
|
complete_form: 'complete_form',
|
||||||
decline_form: 'decline_form',
|
decline_form: 'decline_form',
|
||||||
api_complete_form: 'api_complete_form'
|
api_complete_form: 'api_complete_form'
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<%= button_to button_title(title: t('send_copy_to_email'), disabled_with: t('sending'), icon: svg_icon('mail_forward', class: 'w-6 h-6')), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, class: 'base-button w-full' %>
|
<%= button_to button_title(title: t('send_copy_to_email'), disabled_with: t('sending'), icon: svg_icon('mail_forward', class: 'w-6 h-6')), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, class: 'base-button w-full' %>
|
||||||
</toggle-submit>
|
</toggle-submit>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @template.submitters.to_a.size == 1 && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false %>
|
<% if Templates.filter_undefined_submitters(@template).size == 1 && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false %>
|
||||||
<toggle-submit class="block">
|
<toggle-submit class="block">
|
||||||
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@template.slug), params: { submitter: { email: params[:email] }, resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
|
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@template.slug), params: { submitter: { email: params[:email] }, resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
|
||||||
</toggle-submit>
|
</toggle-submit>
|
||||||
|
|||||||
@@ -1,36 +1,37 @@
|
|||||||
<%= 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| %>
|
||||||
|
<% submitters = template.submitters.reject { |e| e['invite_by_uuid'].present? } %>
|
||||||
<dynamic-list class="space-y-4">
|
<dynamic-list class="space-y-4">
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<div class="card card-compact bg-base-200" data-targets="dynamic-list.items">
|
<div class="card card-compact bg-base-300/40" data-targets="dynamic-list.items">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="absolute right-4 top-5">
|
<div class="absolute right-4 top-5">
|
||||||
<a href="#" data-action="click:dynamic-list#removeItem" class="<%= template.submitters.size == 1 ? 'right-2' : '-top-3' %> relative block w-6 h-6 rounded-lg text-neutral-700 text-center bg-base-300 p-1 hidden hover:bg-neutral hover:text-white">
|
<a href="#" data-action="click:dynamic-list#removeItem" class="<%= submitters.size == 1 ? 'right-2 top-1' : '-top-3' %> relative block w-6 h-6 rounded-lg text-neutral-700 text-center bg-base-300 p-1 hidden hover:bg-neutral hover:text-white">
|
||||||
<%= svg_icon('trash', class: 'w-4 h-4') %>
|
<%= svg_icon('trash', class: 'w-4 h-4') %>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid <%= 'md:grid-cols-2' if template.submitters.size > 1 %> gap-4">
|
<div class="grid <%= 'md:grid-cols-2' if submitters.size > 1 %> gap-4">
|
||||||
<% template.submitters.each_with_index do |item, index| %>
|
<% submitters.each_with_index do |item, index| %>
|
||||||
<submitter-item class="form-control">
|
<submitter-item class="form-control">
|
||||||
<% if template.submitters.size > 1 %>
|
<% if submitters.size > 1 %>
|
||||||
<label class="label pt-0 pb-1 text-xs">
|
<label class="label pt-0 pb-1">
|
||||||
<span class="label-text"> <%= item['name'] %></span>
|
<span class="label-text"> <%= item['name'] %></span>
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
|
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
|
||||||
<submitters-autocomplete data-field="name">
|
<submitters-autocomplete data-field="name">
|
||||||
<linked-input data-target-id="<%= "detailed_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "detailed_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<%= tag.input type: 'text', name: 'submission[1][submitters][][name]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Name', required: index.zero?, value: (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '', dir: 'auto', id: "detailed_name_#{item['uuid']}" %>
|
<%= tag.input type: 'text', name: 'submission[1][submitters][][name]', autocomplete: 'off', class: 'base-input-slim w-full', placeholder: 'Name', required: index.zero?, value: (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '', dir: 'auto', id: "detailed_name_#{item['uuid']}" %>
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
<div class="grid <%= 'md:grid-cols-2 gap-1' if template.submitters.size == 1 %>">
|
<div class="grid <%= 'md:grid-cols-2 gap-1' if submitters.size == 1 %>">
|
||||||
<submitters-autocomplete data-field="email">
|
<submitters-autocomplete data-field="email">
|
||||||
<linked-input data-target-id="<%= "detailed_email_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "detailed_email_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<input type="email" multiple name="submission[1][submitters][][email]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Email (optional)" value="<%= item['email'].presence || ((params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.email : '') %>" id="detailed_email_<%= item['uuid'] %>">
|
<input type="email" multiple name="submission[1][submitters][][email]" autocomplete="off" class="base-input-slim mt-1.5 w-full" placeholder="Email (optional)" value="<%= item['email'].presence || ((params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.email : '') %>" id="detailed_email_<%= item['uuid'] %>">
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
<submitters-autocomplete data-field="phone">
|
<submitters-autocomplete data-field="phone">
|
||||||
<linked-input data-target-id="<%= "detailed_phone_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "detailed_phone_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<input type="tel" pattern="^\+[0-9\s\-]+$" oninvalid="this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''" oninput="this.setCustomValidity('')" name="submission[1][submitters][][phone]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Phone (optional)" id="detailed_phone_<%= item['uuid'] %>">
|
<input type="tel" pattern="^\+[0-9\s\-]+$" oninvalid="this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''" oninput="this.setCustomValidity('')" name="submission[1][submitters][][phone]" autocomplete="off" class="base-input-slim mt-1.5 w-full" placeholder="Phone (optional)" id="detailed_phone_<%= item['uuid'] %>">
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<%= 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 %>
|
<% submitters = template.submitters.reject { |e| e['invite_by_uuid'].present? } %>
|
||||||
|
<% if submitters.size == 1 %>
|
||||||
<submitter-item class="form-control">
|
<submitter-item class="form-control">
|
||||||
<emails-textarea data-bulk-enabled="<%= Docuseal.demo? || !Docuseal.multitenant? || can?(:manage, :bulk_send) %>" data-limit="<%= Docuseal.multitenant? ? (can?(:manage, :bulk_send) ? 40 : 1) : nil %>">
|
<emails-textarea data-bulk-enabled="<%= Docuseal.demo? || !Docuseal.multitenant? || can?(:manage, :bulk_send) %>" data-limit="<%= Docuseal.multitenant? ? (can?(:manage, :bulk_send) ? 40 : 1) : nil %>">
|
||||||
<submitters-autocomplete data-field="email" class="block relative">
|
<submitters-autocomplete data-field="email" class="block relative">
|
||||||
<autoresize-textarea>
|
<autoresize-textarea>
|
||||||
<%= f.text_area :emails, required: true, class: 'base-textarea w-full', placeholder: 'Type emails here...' %>
|
<%= f.text_area :emails, required: true, class: 'base-textarea w-full !text-lg', placeholder: 'Type emails here...', rows: 2 %>
|
||||||
</autoresize-textarea>
|
</autoresize-textarea>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
</emails-textarea>
|
</emails-textarea>
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<dynamic-list class="space-y-4">
|
<dynamic-list class="space-y-4">
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<div class="card card-compact bg-base-200" data-targets="dynamic-list.items">
|
<div class="card card-compact bg-base-300/40" data-targets="dynamic-list.items">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="absolute right-4 top-5">
|
<div class="absolute right-4 top-5">
|
||||||
<a href="#" data-action="click:dynamic-list#removeItem" class="-top-3 relative block w-6 h-6 rounded-lg text-neutral-700 text-center bg-base-300 p-1 hidden hover:bg-neutral hover:text-white">
|
<a href="#" data-action="click:dynamic-list#removeItem" class="-top-3 relative block w-6 h-6 rounded-lg text-neutral-700 text-center bg-base-300 p-1 hidden hover:bg-neutral hover:text-white">
|
||||||
@@ -20,15 +21,15 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid md:grid-cols-2 gap-4">
|
<div class="grid md:grid-cols-2 gap-4">
|
||||||
<% template.submitters.each_with_index do |item, index| %>
|
<% submitters.each_with_index do |item, index| %>
|
||||||
<submitter-item class="form-control">
|
<submitter-item class="form-control">
|
||||||
<label class="label pt-0 pb-1 text-xs">
|
<label class="label pt-0 pb-1">
|
||||||
<span class="label-text"> <%= item['name'] %></span>
|
<span class="label-text"> <%= item['name'] %></span>
|
||||||
</label>
|
</label>
|
||||||
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
|
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
|
||||||
<submitters-autocomplete data-field="email">
|
<submitters-autocomplete data-field="email">
|
||||||
<linked-input data-target-id="<%= "email_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "email_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<%= tag.input type: 'email', multiple: true, name: 'submission[1][submitters][][email]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Email', required: index.zero?, value: item['email'].presence || ((params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.email : ''), id: "email_#{item['uuid']}" %>
|
<%= tag.input type: 'email', multiple: true, name: 'submission[1][submitters][][email]', autocomplete: 'off', class: 'base-input-slim w-full', placeholder: 'Email', required: index.zero?, value: item['email'].presence || ((params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.email : ''), id: "email_#{item['uuid']}" %>
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
</submitter-item>
|
</submitter-item>
|
||||||
|
|||||||
@@ -1,41 +1,42 @@
|
|||||||
<%= 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| %>
|
||||||
|
<% submitters = template.submitters.reject { |e| e['invite_by_uuid'].present? } %>
|
||||||
<dynamic-list class="space-y-4">
|
<dynamic-list class="space-y-4">
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
<div class="card card-compact bg-base-200" data-targets="dynamic-list.items">
|
<div class="card card-compact bg-base-300/40" data-targets="dynamic-list.items">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="absolute right-4 top-5">
|
<div class="absolute right-4 top-5">
|
||||||
<a href="#" data-action="click:dynamic-list#removeItem" class="<%= template.submitters.size == 1 ? 'right-2' : '-top-3' %> relative block w-6 h-6 rounded-lg text-neutral-700 text-center bg-base-300 p-1 hidden hover:bg-neutral hover:text-white">
|
<a href="#" data-action="click:dynamic-list#removeItem" class="<%= submitters.size == 1 ? 'right-2 top-1' : '-top-3' %> relative block w-6 h-6 rounded-lg text-neutral-700 text-center bg-base-300 p-1 hidden hover:bg-neutral hover:text-white">
|
||||||
<%= svg_icon('trash', class: 'w-4 h-4') %>
|
<%= svg_icon('trash', class: 'w-4 h-4') %>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid <%= template.submitters.size > 1 ? 'md:grid-cols-2 gap-4' : 'gap-1' %>">
|
<div class="grid <%= submitters.size > 1 ? 'md:grid-cols-2 gap-4' : 'gap-1' %>">
|
||||||
<% template.submitters.each_with_index do |item, index| %>
|
<% submitters.each_with_index do |item, index| %>
|
||||||
<submitter-item class="grid <%= template.submitters.size > 1 ? 'gap-4' : 'md:grid-cols-2 gap-1' %>">
|
<submitter-item class="grid <%= submitters.size > 1 ? 'gap-4' : 'md:grid-cols-2 gap-1' %>">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<% if template.submitters.size > 1 %>
|
<% if submitters.size > 1 %>
|
||||||
<label class="label pt-0 pb-1 text-xs">
|
<label class="label pt-0 pb-1">
|
||||||
<span class="label-text"> <%= item['name'] %></span>
|
<span class="label-text"> <%= item['name'] %></span>
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
|
<input type="hidden" name="submission[1][submitters][][uuid]" value="<%= item['uuid'] %>">
|
||||||
<submitters-autocomplete data-field="phone">
|
<submitters-autocomplete data-field="phone">
|
||||||
<linked-input data-target-id="<%= "phone_phone_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "phone_phone_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<%= tag.input type: 'tel', pattern: '^\+[0-9\s\-]+$', oninvalid: "this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''", oninput: "this.setCustomValidity('')", name: 'submission[1][submitters][][phone]', autocomplete: 'off', class: 'input input-sm input-bordered w-full', placeholder: 'Phone', required: index.zero?, id: "phone_phone_#{item['uuid']}" %>
|
<%= tag.input type: 'tel', pattern: '^\+[0-9\s\-]+$', oninvalid: "this.value ? this.setCustomValidity('Use internatioanl format: +1xxx...') : ''", oninput: "this.setCustomValidity('')", name: 'submission[1][submitters][][phone]', autocomplete: 'off', class: 'base-input-slim w-full', placeholder: 'Phone', required: index.zero?, id: "phone_phone_#{item['uuid']}" %>
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
<% if template.submitters.size > 1 %>
|
<% if submitters.size > 1 %>
|
||||||
<submitters-autocomplete data-field="name">
|
<submitters-autocomplete data-field="name">
|
||||||
<linked-input data-target-id="<%= "phone_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "phone_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="input input-sm input-bordered mt-1.5 w-full" placeholder="Name (optional)" value="<%= (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '' %>" dir="auto" id="phone_name_<%= item['uuid'] %>">
|
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="base-input-slim mt-1.5 w-full" placeholder="Name (optional)" value="<%= (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '' %>" dir="auto" id="phone_name_<%= item['uuid'] %>">
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if template.submitters.size == 1 %>
|
<% if submitters.size == 1 %>
|
||||||
<div class="form-control flex">
|
<div class="form-control flex">
|
||||||
<submitters-autocomplete data-field="name">
|
<submitters-autocomplete data-field="name">
|
||||||
<linked-input data-target-id="<%= "phone_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
<linked-input data-target-id="<%= "phone_name_#{item['linked_to_uuid']}" if item['linked_to_uuid'].present? %>">
|
||||||
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="input input-sm input-bordered w-full" placeholder="Name (optional)" value="<%= (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '' %>" dir="auto" id="phone_name_<%= item['uuid'] %>">
|
<input type="text" name="submission[1][submitters][][name]" autocomplete="off" class="base-input-slim w-full" placeholder="Name (optional)" value="<%= (params[:selfsign] && index.zero?) || item['is_requester'] ? current_user.full_name : '' %>" dir="auto" id="phone_name_<%= item['uuid'] %>">
|
||||||
</linked-input>
|
</linked-input>
|
||||||
</submitters-autocomplete>
|
</submitters-autocomplete>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% config = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY) %>
|
<% config = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY) %>
|
||||||
<div id="message_field" class="card card-compact bg-base-200 hidden">
|
<div id="message_field" class="card card-compact bg-base-300/40 hidden">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-control space-y-2">
|
<div class="form-control space-y-2">
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<%= render 'shared/turbo_modal', title: params[:selfsign] ? 'Add Recipients' : 'Add New Recipients' do %>
|
<%= render 'shared/turbo_modal_large', title: params[:selfsign] ? 'Add Recipients' : 'Add New Recipients' do %>
|
||||||
<% options = [['via Email', 'email'], ['via Phone', 'phone'], %w[Detailed detailed], ['Upload List', 'list']].compact %>
|
<% options = [['via Email', 'email'], ['via Phone', 'phone'], %w[Detailed detailed], ['Upload List', 'list']].compact %>
|
||||||
<toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center mt-4 block">
|
<toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center px-2 mt-4 block">
|
||||||
<div class="join">
|
<div class="join">
|
||||||
<% options.each_with_index do |(label, value), index| %>
|
<% options.each_with_index do |(label, value), index| %>
|
||||||
<span>
|
<span>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</toggle-visible>
|
</toggle-visible>
|
||||||
<div class="mt-4">
|
<div class="px-5 mb-5 mt-4">
|
||||||
<div id="email">
|
<div id="email">
|
||||||
<%= render 'email_form', template: @template %>
|
<%= render 'email_form', template: @template %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -145,8 +145,10 @@
|
|||||||
<span>
|
<span>
|
||||||
<% if submitter&.declined_at? %>
|
<% if submitter&.declined_at? %>
|
||||||
Declined on <%= l(submitter.declined_at.in_time_zone(@submission.account.timezone), format: :short, locale: @submission.account.locale) %>
|
Declined on <%= l(submitter.declined_at.in_time_zone(@submission.account.timezone), format: :short, locale: @submission.account.locale) %>
|
||||||
|
<% elsif submitter %>
|
||||||
|
<%= submitter.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : 'Not completed yet' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= submitter&.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : 'Not completed yet' %>
|
Not invited yet
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
<% data_attachments = attachments_index.values.select { |e| e.record_id == submitter.id }.to_json(only: %i[uuid created_at], methods: %i[url filename content_type]) %>
|
<% data_attachments = attachments_index.values.select { |e| e.record_id == submitter.id }.to_json(only: %i[uuid created_at], methods: %i[url filename content_type]) %>
|
||||||
<% data_fields = (submitter.submission.template_fields || submitter.submission.template.fields).select { |f| f['submitter_uuid'] == submitter.uuid }.to_json %>
|
<% data_fields = (submitter.submission.template_fields || submitter.submission.template.fields).select { |f| f['submitter_uuid'] == submitter.uuid }.to_json %>
|
||||||
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-require-signing-reason="<%= configs[:require_signing_reason] %>" data-with-signature-id="<%= configs[:with_signature_id] %>" data-with-confetti="<%= configs[:with_confetti] %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'] %>" data-completed-message="<%= configs[:completed_message].to_json %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.preferences.key?('go_to_last') ? submitter.preferences['go_to_last'] : submitter.opened_at? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Accounts.can_send_emails?(submitter.submission.account) %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>" data-previous-signature-value="<%= local_assigns[:signature_attachment]&.uuid %>" data-remember-signature="<%= configs[:prefill_signature] %>" data-dry-run="<%= local_assigns[:dry_run] %>" data-expand="<%= local_assigns[:expand] %>" data-scroll-padding="<%= local_assigns[:scroll_padding] %>"></submission-form>
|
<% invite_submitters = (submitter.submission.template_submitters || submitter.submission.template.submitters).select { |s| s['invite_by_uuid'] == submitter.uuid && submitter.submission.submitters.none? { |e| e.uuid == s['uuid'] } }.to_json %>
|
||||||
|
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-require-signing-reason="<%= configs[:require_signing_reason] %>" data-with-signature-id="<%= configs[:with_signature_id] %>" data-with-confetti="<%= configs[:with_confetti] %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'].presence || submitter.submission.template.preferences['completed_redirect_url'] %>" data-completed-message="<%= (configs[:completed_message]&.compact_blank.presence || submitter.submission.template.preferences['completed_message'] || {}).to_json %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.preferences.key?('go_to_last') ? submitter.preferences['go_to_last'] : submitter.opened_at? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Accounts.can_send_emails?(submitter.submission.account) %>" data-invite-submitters="<%= invite_submitters %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>" data-previous-signature-value="<%= local_assigns[:signature_attachment]&.uuid %>" data-remember-signature="<%= configs[:prefill_signature] %>" data-dry-run="<%= local_assigns[:dry_run] %>" data-expand="<%= local_assigns[:expand] %>" data-scroll-padding="<%= local_assigns[:scroll_padding] %>"></submission-form>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<toggle-submit>
|
<toggle-submit>
|
||||||
<%= button_to button_title(title: t('send_copy_to_email'), disabled_with: t('sending'), icon: svg_icon('mail_forward', class: 'w-6 h-6')), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, class: 'white-button w-full' %>
|
<%= button_to button_title(title: t('send_copy_to_email'), disabled_with: t('sending'), icon: svg_icon('mail_forward', class: 'w-6 h-6')), send_submission_email_index_path, params: { submitter_slug: @submitter.slug }, class: 'white-button w-full' %>
|
||||||
</toggle-submit>
|
</toggle-submit>
|
||||||
<% if @submitter.submission.template.submitters.size != 1 %>
|
<% if Templates.filter_undefined_submitters(@submitter.submission.template).size != 1 %>
|
||||||
<div class="divider uppercase"><%= t('or') %></div>
|
<div class="divider uppercase"><%= t('or') %></div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="py-2"></div>
|
<div class="py-2"></div>
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
</download-button>
|
</download-button>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if @submitter.submission.template.submitters.size == 1 && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && !@submitter.template.archived_at? %>
|
<% if Templates.filter_undefined_submitters(@submitter.submission.template).size == 1 && %w[api embed].exclude?(@submitter.submission.source) && @submitter.account.account_configs.find_or_initialize_by(key: AccountConfig::ALLOW_TO_RESUBMIT).value != false && !@submitter.template.archived_at? %>
|
||||||
<div class="divider uppercase"><%= t('or') %></div>
|
<div class="divider uppercase"><%= t('or') %></div>
|
||||||
<toggle-submit class="block">
|
<toggle-submit class="block">
|
||||||
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@submitter.submission.template.slug), params: { submitter: { email: @submitter.email, phone: @submitter.phone, name: @submitter.name }, resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
|
<%= button_to button_title(title: t('resubmit'), disabled_with: t('resubmit'), icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@submitter.submission.template.slug), params: { submitter: { email: @submitter.email, phone: @submitter.phone, name: @submitter.name }, resubmit: @submitter.slug }, method: :put, class: 'white-button w-full' %>
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
<% 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) %>
|
<% 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['redacted'] && field['submitter_uuid'] != @submitter.uuid %>
|
|
||||||
<% next if value == '{{date}}' && field['submitter_uuid'] != @submitter.uuid %>
|
<% next if value == '{{date}}' && field['submitter_uuid'] != @submitter.uuid %>
|
||||||
<% next if field['conditions'].present? && values[field['uuid']].blank? && field['submitter_uuid'] != @submitter.uuid %>
|
<% next if field['conditions'].present? && values[field['uuid']].blank? && field['submitter_uuid'] != @submitter.uuid %>
|
||||||
<% next if field['conditions'].present? && field['submitter_uuid'] == @submitter.uuid %>
|
<% next if field['conditions'].present? && field['submitter_uuid'] == @submitter.uuid %>
|
||||||
|
|||||||
@@ -41,6 +41,38 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= render 'templates_code_modal/preferences' %>
|
<%= render 'templates_code_modal/preferences' %>
|
||||||
|
<div class="collapse collapse-arrow join-item border border-base-300 mb-2">
|
||||||
|
<input type="checkbox" name="accordion">
|
||||||
|
<div class="collapse-title text-xl font-medium">
|
||||||
|
Form preferences
|
||||||
|
</div>
|
||||||
|
<div class="collapse-content">
|
||||||
|
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %>
|
||||||
|
<toggle-on-submit data-element-id="form_saved_alert"></toggle-on-submit>
|
||||||
|
<% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY).value %>
|
||||||
|
<%= f.fields_for :preferences, Struct.new(:completed_redirect_url, :completed_message).new(@template.preferences['completed_redirect_url'].presence, Struct.new(:title, :body).new(*(@template.preferences['completed_message'] || {}).values_at('title', 'body'))) do |ff| %>
|
||||||
|
<div class="form-control mb-2">
|
||||||
|
<%= ff.label :completed_redirect_url, 'Redirect on completion URL', class: 'label' %>
|
||||||
|
<%= ff.url_field :completed_redirect_url, required: false, class: 'base-input', dir: 'auto' %>
|
||||||
|
</div>
|
||||||
|
<%= ff.fields_for :completed_message, ff.object.completed_message do |fff| %>
|
||||||
|
<div class="form-control mb-2 border-t mt-4">
|
||||||
|
<%= fff.label :body, 'Completion message', class: 'label' %>
|
||||||
|
<autoresize-textarea>
|
||||||
|
<%= fff.text_area :body, required: false, class: 'base-input w-full py-2', dir: 'auto' %>
|
||||||
|
</autoresize-textarea>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<div class="form-control pt-2">
|
||||||
|
<%= f.button button_title(title: 'Save', disabled_with: 'Saving'), class: 'base-button' %>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<span id="form_saved_alert" class="text-sm invisible font-normal mt-0.5">Changes have been saved</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="join join-vertical w-full !rounded-2xl mb-1.5 mt-2.5">
|
<div class="join join-vertical w-full !rounded-2xl mb-1.5 mt-2.5">
|
||||||
<div class="collapse collapse-arrow join-item border border-base-300">
|
<div class="collapse collapse-arrow join-item border border-base-300">
|
||||||
<input type="checkbox" name="accordion">
|
<input type="checkbox" name="accordion">
|
||||||
@@ -184,22 +216,22 @@
|
|||||||
<div class="space-y-3 divide-y">
|
<div class="space-y-3 divide-y">
|
||||||
<% @template.submitters.each_with_index do |submitter, index| %>
|
<% @template.submitters.each_with_index do |submitter, index| %>
|
||||||
<div class="pt-3">
|
<div class="pt-3">
|
||||||
<%= f.fields_for :submitters, item = Struct.new(:name, :uuid, :is_requester, :email, :linked_to_uuid, :option).new(*submitter.values_at('name', 'uuid', 'is_requester', 'email', 'linked_to_uuid')), index: do |ff| %>
|
<%= f.fields_for :submitters, item = Struct.new(:name, :uuid, :is_requester, :email, :invite_by_uuid, :linked_to_uuid, :option).new(*submitter.values_at('name', 'uuid', 'is_requester', 'email', 'invite_by_uuid', 'linked_to_uuid')), index: do |ff| %>
|
||||||
<% item.option = item.is_requester.present? ? 'is_requester' : (item.email.present? ? 'email' : (item.linked_to_uuid.present? ? "linked_to_#{item.linked_to_uuid}" : '')) %>
|
<% item.option = item.is_requester.present? ? 'is_requester' : (item.email.present? ? 'email' : (item.linked_to_uuid.present? ? "linked_to_#{item.linked_to_uuid}" : (item.invite_by_uuid.present? ? "invite_by_#{item.invite_by_uuid}" : ''))) %>
|
||||||
<%= ff.hidden_field :uuid %>
|
<%= ff.hidden_field :uuid %>
|
||||||
<div class="form-control">
|
<div class="form-control">
|
||||||
<%= ff.text_field :name, class: 'w-full outline-none border-transparent focus:border-transparent focus:ring-0 bg-base-100 px-1 peer mb-2', autocomplete: 'off', placeholder: "#{index + 1}#{(index + 1).ordinal} Party", required: true %>
|
<%= ff.text_field :name, class: 'w-full outline-none border-transparent focus:border-transparent focus:ring-0 bg-base-100 px-1 peer mb-2', autocomplete: 'off', placeholder: "#{index + 1}#{(index + 1).ordinal} Party", required: true %>
|
||||||
<% if @template.submitters.size == 2 %>
|
<% if @template.submitters.size == 2 %>
|
||||||
<%= ff.email_field :email, class: 'base-input', autocomplete: 'off', placeholder: 'Default Email', disabled: ff.object.is_requester, id: field_uuid = SecureRandom.uuid %>
|
<%= ff.email_field :email, class: 'base-input', autocomplete: 'off', placeholder: 'Default Email', disabled: ff.object.is_requester || ff.object.invite_by_uuid.present?, id: field_uuid = SecureRandom.uuid %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<toggle-attribute data-target-id="<%= email_field_uuid = SecureRandom.uuid %>" data-class-name="hidden" data-value="email">
|
<toggle-attribute data-target-id="<%= email_field_uuid = SecureRandom.uuid %>" data-class-name="hidden" data-value="email">
|
||||||
<%= ff.select :option, [['Not specified', 'not_set'], ['Submission requester', 'is_requester'], ['Specified email', 'email'], *(@template.submitters - [submitter]).map { |e| ["Same as #{e['name']}", "linked_to_#{e['uuid']}"] }], {}, class: 'base-select mb-3' %>
|
<%= ff.select :option, [['Not specified', 'not_set'], ['Submission requester', 'is_requester'], ['Specified email', 'email'], *(@template.submitters - [submitter]).map { |e| ["Invite by #{e['name']}", "invite_by_#{e['uuid']}"] }, *(@template.submitters - [submitter]).map { |e| ["Same as #{e['name']}", "linked_to_#{e['uuid']}"] }], {}, class: 'base-select mb-3' %>
|
||||||
</toggle-attribute>
|
</toggle-attribute>
|
||||||
<%= ff.email_field :email, class: "base-input #{'hidden' if item.option != 'email'}", autocomplete: 'off', placeholder: 'Default Email', id: email_field_uuid %>
|
<%= ff.email_field :email, class: "base-input #{'hidden' if item.option != 'email'}", autocomplete: 'off', placeholder: 'Default Email', id: email_field_uuid %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% if @template.submitters.size == 2 %>
|
<% if @template.submitters.size == 2 %>
|
||||||
<div class="mt-3">
|
<checkbox-group class="mt-3 flex items-center space-x-4">
|
||||||
<label class="flex items-center space-x-2 cursor-pointer">
|
<label class="flex items-center space-x-2 cursor-pointer">
|
||||||
<toggle-attribute data-target-id="<%= field_uuid %>" class="flex" data-attribute="disabled">
|
<toggle-attribute data-target-id="<%= field_uuid %>" class="flex" data-attribute="disabled">
|
||||||
<%= ff.check_box :is_requester, class: 'base-checkbox' %>
|
<%= ff.check_box :is_requester, class: 'base-checkbox' %>
|
||||||
@@ -208,7 +240,17 @@
|
|||||||
Submission requester
|
Submission requester
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
<% if index == 1 %>
|
||||||
|
<label class="flex items-center space-x-2 cursor-pointer">
|
||||||
|
<toggle-attribute data-target-id="<%= field_uuid %>" class="flex" data-attribute="disabled">
|
||||||
|
<%= ff.check_box :invite_by_uuid, { class: 'base-checkbox' }, @template.submitters.first['uuid'], '' %>
|
||||||
|
</toggle-attribute>
|
||||||
|
<span class="select-none">
|
||||||
|
Invite by <%= @template.submitters.first['name'] %>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</checkbox-group>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ Rails.application.routes.draw do
|
|||||||
resources :values, only: %i[index], controller: 'submit_form_values'
|
resources :values, only: %i[index], controller: 'submit_form_values'
|
||||||
resources :download, only: %i[index], controller: 'submit_form_download'
|
resources :download, only: %i[index], controller: 'submit_form_download'
|
||||||
resources :decline, only: %i[create], controller: 'submit_form_decline'
|
resources :decline, only: %i[create], controller: 'submit_form_decline'
|
||||||
|
resources :invite, only: %i[create], controller: 'submit_form_invite'
|
||||||
get :completed
|
get :completed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ module Accounts
|
|||||||
|
|
||||||
data
|
data
|
||||||
else
|
else
|
||||||
|
return Docuseal.default_pkcs if Docuseal::CERTS.present?
|
||||||
|
|
||||||
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value ||
|
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value ||
|
||||||
EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY).value
|
EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY).value
|
||||||
end
|
end
|
||||||
@@ -143,6 +145,8 @@ module Accounts
|
|||||||
value = EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {}
|
value = EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {}
|
||||||
|
|
||||||
Docuseal::CERTS.merge(value)
|
Docuseal::CERTS.merge(value)
|
||||||
|
elsif Docuseal::CERTS.present?
|
||||||
|
Docuseal::CERTS
|
||||||
else
|
else
|
||||||
EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {}
|
EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ module SubmissionEvents
|
|||||||
phone_verified: 'Phone verified',
|
phone_verified: 'Phone verified',
|
||||||
start_form: 'Submission started',
|
start_form: 'Submission started',
|
||||||
view_form: 'Form viewed',
|
view_form: 'Form viewed',
|
||||||
|
invite_party: 'Invited',
|
||||||
complete_form: 'Submission completed',
|
complete_form: 'Submission completed',
|
||||||
api_complete_form: 'Submission completed via API'
|
api_complete_form: 'Submission completed via API'
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ module Submissions
|
|||||||
return email.downcase if email.to_s.include?('.om')
|
return email.downcase if email.to_s.include?('.om')
|
||||||
return email.downcase if email.to_s.include?('.mm')
|
return email.downcase if email.to_s.include?('.mm')
|
||||||
return email.downcase if email.to_s.include?('.cm')
|
return email.downcase if email.to_s.include?('.cm')
|
||||||
|
return email.downcase if email.to_s.include?('.et')
|
||||||
return email.downcase unless email.to_s.include?('.')
|
return email.downcase unless email.to_s.include?('.')
|
||||||
|
|
||||||
fixed_email = EmailTypo.call(email.delete_prefix('<'))
|
fixed_email = EmailTypo.call(email.delete_prefix('<'))
|
||||||
|
|||||||
@@ -10,20 +10,13 @@ module Submissions
|
|||||||
assign_defined_submitters(submission)
|
assign_defined_submitters(submission)
|
||||||
assign_linked_submitters(submission)
|
assign_linked_submitters(submission)
|
||||||
|
|
||||||
if submission.submitters.size == 1 && submission.template.submitters.size == 2
|
|
||||||
submission.submitters.new(
|
|
||||||
account_id: submission.account_id,
|
|
||||||
uuid: submission.template.submitters.second['uuid'],
|
|
||||||
email: submission.template.author.email
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
submission
|
submission
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_defined_submitters(submission)
|
def assign_defined_submitters(submission)
|
||||||
submission.template.submitters.to_a.select do |item|
|
submission.template.submitters.to_a.select do |item|
|
||||||
next if item['email'].blank? && item['is_requester'].blank?
|
next if item['email'].blank? && item['is_requester'].blank?
|
||||||
|
next if submission.submitters.any? { |e| e.uuid == item['uuid'] }
|
||||||
|
|
||||||
submission.submitters.new(
|
submission.submitters.new(
|
||||||
account_id: submission.account_id,
|
account_id: submission.account_id,
|
||||||
@@ -36,6 +29,7 @@ module Submissions
|
|||||||
def assign_linked_submitters(submission)
|
def assign_linked_submitters(submission)
|
||||||
submission.template.submitters.to_a.select do |item|
|
submission.template.submitters.to_a.select do |item|
|
||||||
next if item['linked_to_uuid'].blank?
|
next if item['linked_to_uuid'].blank?
|
||||||
|
next if submission.submitters.any? { |e| e.uuid == item['uuid'] }
|
||||||
|
|
||||||
email = submission.submitters.find { |s| s.uuid == item['linked_to_uuid'] }&.email
|
email = submission.submitters.find { |s| s.uuid == item['linked_to_uuid'] }&.email
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,21 @@ module Submissions
|
|||||||
|
|
||||||
next if submission.submitters.blank?
|
next if submission.submitters.blank?
|
||||||
|
|
||||||
|
maybe_add_invite_submitters(submission, template)
|
||||||
|
|
||||||
submission.tap(&:save!)
|
submission.tap(&:save!)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def maybe_add_invite_submitters(submission, template)
|
||||||
|
template.submitters.each do |item|
|
||||||
|
next if item['invite_by_uuid'].blank? ||
|
||||||
|
submission.template_submitters.any? { |e| e['uuid'] == item['uuid'] }
|
||||||
|
|
||||||
|
submission.template_submitters << item
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def maybe_set_template_fields(submission, submitters_attrs, default_submitter_uuid: nil)
|
def maybe_set_template_fields(submission, submitters_attrs, default_submitter_uuid: nil)
|
||||||
template_fields = (submission.template_fields || submission.template.fields).deep_dup
|
template_fields = (submission.template_fields || submission.template.fields).deep_dup
|
||||||
|
|
||||||
@@ -120,7 +131,6 @@ module Submissions
|
|||||||
field['title'] = attrs['title'] if attrs['title'].present?
|
field['title'] = attrs['title'] if attrs['title'].present?
|
||||||
field['description'] = attrs['description'] if attrs['description'].present?
|
field['description'] = attrs['description'] if attrs['description'].present?
|
||||||
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
||||||
field['redacted'] = attrs['redacted'] if attrs.key?('redacted')
|
|
||||||
field['required'] = attrs['required'] if attrs.key?('required')
|
field['required'] = attrs['required'] if attrs.key?('required')
|
||||||
|
|
||||||
if attrs.key?('default_value') && !field['type'].in?(%w[signature image initials file])
|
if attrs.key?('default_value') && !field['type'].in?(%w[signature image initials file])
|
||||||
|
|||||||
@@ -348,13 +348,21 @@ module Submissions
|
|||||||
|
|
||||||
events_data = submission.submission_events.sort_by(&:event_timestamp).map do |event|
|
events_data = submission.submission_events.sort_by(&:event_timestamp).map do |event|
|
||||||
submitter = submission.submitters.find { |e| e.id == event.submitter_id }
|
submitter = submission.submitters.find { |e| e.id == event.submitter_id }
|
||||||
|
|
||||||
|
text = SubmissionEvents::EVENT_NAMES[event.event_type.to_sym]
|
||||||
|
|
||||||
|
if event.event_type == 'invite_party' &&
|
||||||
|
(invited_submitter = submission.submitters.find { |e| e.uuid == event.data['uuid'] }) &&
|
||||||
|
(name = submission.template_submitters.find { |e| e['uuid'] == event.data['uuid'] }&.dig('name'))
|
||||||
|
text += ['', invited_submitter.name || invited_submitter.email || invited_submitter.phone, name].join(' ')
|
||||||
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
"#{I18n.l(event.event_timestamp.in_time_zone(account.timezone), format: :long, locale: account.locale)} " \
|
"#{I18n.l(event.event_timestamp.in_time_zone(account.timezone), format: :long, locale: account.locale)} " \
|
||||||
"#{TimeUtils.timezone_abbr(account.timezone, event.event_timestamp)}",
|
"#{TimeUtils.timezone_abbr(account.timezone, event.event_timestamp)}",
|
||||||
composer.document.layout.formatted_text_box(
|
composer.document.layout.formatted_text_box(
|
||||||
[
|
[
|
||||||
{ text: SubmissionEvents::EVENT_NAMES[event.event_type.to_sym],
|
{ text:, font: [FONT_NAME, { variant: :bold }] },
|
||||||
font: [FONT_NAME, { variant: :bold }] },
|
|
||||||
event.event_type.include?('send_') ? ' to ' : ' by ',
|
event.event_type.include?('send_') ? ' to ' : ' by ',
|
||||||
if event.event_type.include?('sms') || event.event_type.include?('phone')
|
if event.event_type.include?('sms') || event.event_type.include?('phone')
|
||||||
event.data['phone'] || submitter.phone
|
event.data['phone'] || submitter.phone
|
||||||
|
|||||||
@@ -22,8 +22,12 @@ module Submitters
|
|||||||
submitter_name = (submitter.submission.template_submitters ||
|
submitter_name = (submitter.submission.template_submitters ||
|
||||||
submitter.submission.template.submitters).find { |e| e['uuid'] == submitter.uuid }['name']
|
submitter.submission.template.submitters).find { |e| e['uuid'] == submitter.uuid }['name']
|
||||||
|
|
||||||
|
decline_reason =
|
||||||
|
submitter.declined_at? ? submitter.submission_events.find_by(event_type: :decline_form).data['reason'] : nil
|
||||||
|
|
||||||
submitter.as_json(SERIALIZE_PARAMS)
|
submitter.as_json(SERIALIZE_PARAMS)
|
||||||
.merge('role' => submitter_name,
|
.merge('decline_reason' => decline_reason,
|
||||||
|
'role' => submitter_name,
|
||||||
'preferences' => submitter.preferences.except('default_values'),
|
'preferences' => submitter.preferences.except('default_values'),
|
||||||
'values' => values,
|
'values' => values,
|
||||||
'documents' => documents,
|
'documents' => documents,
|
||||||
@@ -79,7 +83,7 @@ module Submitters
|
|||||||
|
|
||||||
value = fetch_field_value(field, submitter.values[field['uuid']], attachments_index)
|
value = fetch_field_value(field, submitter.values[field['uuid']], attachments_index)
|
||||||
|
|
||||||
{ name: field_name, uuid: field['uuid'], value: }
|
{ name: field_name, uuid: field['uuid'], value:, readonly: field['readonly'] == true }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,11 @@ module Templates
|
|||||||
|
|
||||||
templates.where(Template.arel_table[:name].lower.matches("%#{keyword.downcase}%"))
|
templates.where(Template.arel_table[:name].lower.matches("%#{keyword.downcase}%"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filter_undefined_submitters(template)
|
||||||
|
template.submitters.to_a.select do |item|
|
||||||
|
item['invite_by_uuid'].blank? && item['linked_to_uuid'].blank? &&
|
||||||
|
item['is_requester'].blank? && item['email'].blank?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -3,11 +3,13 @@
|
|||||||
module Templates
|
module Templates
|
||||||
module ProcessDocument
|
module ProcessDocument
|
||||||
DPI = 200
|
DPI = 200
|
||||||
FORMAT = '.jpg'
|
FORMAT = '.png'
|
||||||
ATTACHMENT_NAME = 'preview_images'
|
ATTACHMENT_NAME = 'preview_images'
|
||||||
|
|
||||||
PDF_CONTENT_TYPE = 'application/pdf'
|
PDF_CONTENT_TYPE = 'application/pdf'
|
||||||
Q = ENV.fetch('PAGE_QUALITY', '35').to_i
|
CONCURRENCY = 2
|
||||||
|
Q = 95
|
||||||
|
JPEG_Q = ENV.fetch('PAGE_QUALITY', '35').to_i
|
||||||
MAX_WIDTH = 1400
|
MAX_WIDTH = 1400
|
||||||
MAX_NUMBER_OF_PAGES_PROCESSED = 15
|
MAX_NUMBER_OF_PAGES_PROCESSED = 15
|
||||||
MAX_FLATTEN_FILE_SIZE = 20.megabytes
|
MAX_FLATTEN_FILE_SIZE = 20.megabytes
|
||||||
@@ -15,7 +17,7 @@ module Templates
|
|||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def call(attachment, data, extract_fields: false, image_quality: nil)
|
def call(attachment, data, extract_fields: false)
|
||||||
if attachment.content_type == PDF_CONTENT_TYPE
|
if attachment.content_type == PDF_CONTENT_TYPE
|
||||||
if extract_fields && data.size < MAX_FLATTEN_FILE_SIZE
|
if extract_fields && data.size < MAX_FLATTEN_FILE_SIZE
|
||||||
pdf = HexaPDF::Document.new(io: StringIO.new(data))
|
pdf = HexaPDF::Document.new(io: StringIO.new(data))
|
||||||
@@ -23,23 +25,26 @@ module Templates
|
|||||||
fields = Templates::FindAcroFields.call(pdf, attachment)
|
fields = Templates::FindAcroFields.call(pdf, attachment)
|
||||||
end
|
end
|
||||||
|
|
||||||
generate_pdf_preview_images(attachment, data, pdf, image_quality:)
|
generate_pdf_preview_images(attachment, data, pdf)
|
||||||
|
|
||||||
attachment.metadata['pdf']['fields'] = fields if fields
|
attachment.metadata['pdf']['fields'] = fields if fields
|
||||||
elsif attachment.image?
|
elsif attachment.image?
|
||||||
generate_preview_image(attachment, data, image_quality:)
|
generate_preview_image(attachment, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
attachment
|
attachment
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_preview_image(attachment, data, image_quality: nil)
|
def generate_preview_image(attachment, data)
|
||||||
ActiveStorage::Attachment.where(name: ATTACHMENT_NAME, record: attachment).destroy_all
|
ActiveStorage::Attachment.where(name: ATTACHMENT_NAME, record: attachment).destroy_all
|
||||||
|
|
||||||
image = Vips::Image.new_from_buffer(data, '')
|
image = Vips::Image.new_from_buffer(data, '')
|
||||||
image = image.autorot.resize(MAX_WIDTH / image.width.to_f)
|
image = image.autorot.resize(MAX_WIDTH / image.width.to_f)
|
||||||
|
|
||||||
io = StringIO.new(image.write_to_buffer(FORMAT, Q: image_quality || Q, interlace: true))
|
bitdepth = 2**image.stats.to_a[1..3].pluck(2).uniq.size
|
||||||
|
|
||||||
|
io = StringIO.new(image.write_to_buffer(FORMAT, compression: 7, filter: 0, bitdepth:,
|
||||||
|
palette: true, Q: Q, dither: 0))
|
||||||
|
|
||||||
ActiveStorage::Attachment.create!(
|
ActiveStorage::Attachment.create!(
|
||||||
blob: ActiveStorage::Blob.create_and_upload!(
|
blob: ActiveStorage::Blob.create_and_upload!(
|
||||||
@@ -51,7 +56,7 @@ module Templates
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_pdf_preview_images(attachment, data, pdf = nil, image_quality: nil)
|
def generate_pdf_preview_images(attachment, data, pdf = nil)
|
||||||
ActiveStorage::Attachment.where(name: ATTACHMENT_NAME, record: attachment).destroy_all
|
ActiveStorage::Attachment.where(name: ATTACHMENT_NAME, record: attachment).destroy_all
|
||||||
|
|
||||||
pdf ||= HexaPDF::Document.new(io: StringIO.new(data))
|
pdf ||= HexaPDF::Document.new(io: StringIO.new(data))
|
||||||
@@ -62,27 +67,49 @@ module Templates
|
|||||||
attachment.metadata['pdf'] ||= {}
|
attachment.metadata['pdf'] ||= {}
|
||||||
attachment.metadata['pdf']['number_of_pages'] = number_of_pages
|
attachment.metadata['pdf']['number_of_pages'] = number_of_pages
|
||||||
|
|
||||||
attachment.save!
|
ApplicationRecord.no_touching do
|
||||||
|
attachment.save!
|
||||||
|
end
|
||||||
|
|
||||||
max_pages_to_process = data.size < GENERATE_PREVIEW_SIZE_LIMIT ? MAX_NUMBER_OF_PAGES_PROCESSED : 1
|
max_pages_to_process = data.size < GENERATE_PREVIEW_SIZE_LIMIT ? MAX_NUMBER_OF_PAGES_PROCESSED : 1
|
||||||
|
|
||||||
(0..[number_of_pages - 1, max_pages_to_process].min).each do |page_number|
|
pool = Concurrent::FixedThreadPool.new(CONCURRENCY)
|
||||||
page = Vips::Image.new_from_buffer(data, '', dpi: DPI, page: page_number)
|
|
||||||
page = page.resize(MAX_WIDTH / page.width.to_f)
|
|
||||||
|
|
||||||
io = StringIO.new(page.write_to_buffer(FORMAT, Q: image_quality || Q, interlace: true))
|
promises =
|
||||||
|
(0..[number_of_pages - 1, max_pages_to_process].min).map do |page_number|
|
||||||
|
Concurrent::Promise.execute(executor: pool) { build_and_upload_blob(data, page_number) }
|
||||||
|
end
|
||||||
|
|
||||||
|
Concurrent::Promise.zip(*promises).value!.each do |blob|
|
||||||
ApplicationRecord.no_touching do
|
ApplicationRecord.no_touching do
|
||||||
ActiveStorage::Attachment.create!(
|
ActiveStorage::Attachment.create!(
|
||||||
blob: ActiveStorage::Blob.create_and_upload!(
|
blob:,
|
||||||
io:, filename: "#{page_number}#{FORMAT}",
|
|
||||||
metadata: { analyzed: true, identified: true, width: page.width, height: page.height }
|
|
||||||
),
|
|
||||||
name: ATTACHMENT_NAME,
|
name: ATTACHMENT_NAME,
|
||||||
record: attachment
|
record: attachment
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pool.kill
|
||||||
|
end
|
||||||
|
|
||||||
|
def build_and_upload_blob(data, page_number)
|
||||||
|
page = Vips::Image.new_from_buffer(data, '', dpi: DPI, page: page_number)
|
||||||
|
page = page.resize(MAX_WIDTH / page.width.to_f)
|
||||||
|
|
||||||
|
bitdepth = 2**page.stats.to_a[1..3].pluck(2).uniq.size
|
||||||
|
|
||||||
|
io = StringIO.new(page.write_to_buffer(FORMAT, compression: 7, filter: 0, bitdepth:,
|
||||||
|
palette: true, Q: Q, dither: 0))
|
||||||
|
|
||||||
|
blob = ActiveStorage::Blob.new(
|
||||||
|
filename: "#{page_number}#{FORMAT}",
|
||||||
|
metadata: { analyzed: true, identified: true, width: page.width, height: page.height }
|
||||||
|
)
|
||||||
|
|
||||||
|
blob.upload(io)
|
||||||
|
|
||||||
|
blob
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_flatten_form(data, pdf)
|
def maybe_flatten_form(data, pdf)
|
||||||
@@ -115,11 +142,11 @@ module Templates
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_pdf_preview_from_file(attachment, file_path, page_number, image_quality: nil)
|
def generate_pdf_preview_from_file(attachment, file_path, page_number)
|
||||||
io = StringIO.new
|
io = StringIO.new
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
'pdftocairo', '-jpeg', '-jpegopt', "progressive=y,quality=#{image_quality || Q},optimize=y",
|
'pdftocairo', '-jpeg', '-jpegopt', "progressive=y,quality=#{JPEG_Q},optimize=y",
|
||||||
'-scale-to-x', MAX_WIDTH, '-scale-to-y', '-1',
|
'-scale-to-x', MAX_WIDTH, '-scale-to-y', '-1',
|
||||||
'-r', DPI, '-f', page_number + 1, '-l', page_number + 1,
|
'-r', DPI, '-f', page_number + 1, '-l', page_number + 1,
|
||||||
'-singlefile', Shellwords.escape(file_path), '-'
|
'-singlefile', Shellwords.escape(file_path), '-'
|
||||||
@@ -138,7 +165,7 @@ module Templates
|
|||||||
ApplicationRecord.no_touching do
|
ApplicationRecord.no_touching do
|
||||||
ActiveStorage::Attachment.create!(
|
ActiveStorage::Attachment.create!(
|
||||||
blob: ActiveStorage::Blob.create_and_upload!(
|
blob: ActiveStorage::Blob.create_and_upload!(
|
||||||
io:, filename: "#{page_number}#{FORMAT}",
|
io:, filename: "#{page_number}.jpg",
|
||||||
metadata: { analyzed: true, identified: true, width: page.width, height: page.height }
|
metadata: { analyzed: true, identified: true, width: page.width, height: page.height }
|
||||||
),
|
),
|
||||||
name: ATTACHMENT_NAME,
|
name: ATTACHMENT_NAME,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Templates
|
|||||||
|
|
||||||
preview_image_attachments ||=
|
preview_image_attachments ||=
|
||||||
ActiveStorage::Attachment.joins(:blob)
|
ActiveStorage::Attachment.joins(:blob)
|
||||||
.where(blob: { filename: '0.jpg' })
|
.where(blob: { filename: ['0.jpg', '0.png'] })
|
||||||
.where(record_id: schema_documents.map(&:id),
|
.where(record_id: schema_documents.map(&:id),
|
||||||
record_type: 'ActiveStorage::Attachment',
|
record_type: 'ActiveStorage::Attachment',
|
||||||
name: :preview_images)
|
name: :preview_images)
|
||||||
@@ -29,7 +29,7 @@ module Templates
|
|||||||
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
|
attachment = schema_documents.find { |e| e.uuid == item['attachment_uuid'] }
|
||||||
|
|
||||||
first_page_blob = preview_image_attachments.find { |e| e.record_id == attachment.id }&.blob
|
first_page_blob = preview_image_attachments.find { |e| e.record_id == attachment.id }&.blob
|
||||||
first_page_blob ||= attachment.preview_images.joins(:blob).find_by(blob: { filename: '0.jpg' })&.blob
|
first_page_blob ||= attachment.preview_images.joins(:blob).find_by(blob: { filename: ['0.jpg', '0.png'] })&.blob
|
||||||
|
|
||||||
{
|
{
|
||||||
id: attachment.id,
|
id: attachment.id,
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ describe 'Templates API', type: :request do
|
|||||||
attachment = template.schema_documents.preload(:blob).find { |e| e.uuid == template_attachment_uuid }
|
attachment = template.schema_documents.preload(:blob).find { |e| e.uuid == template_attachment_uuid }
|
||||||
first_page_blob =
|
first_page_blob =
|
||||||
ActiveStorage::Attachment.joins(:blob)
|
ActiveStorage::Attachment.joins(:blob)
|
||||||
.where(blob: { filename: '0.jpg' })
|
.where(blob: { filename: '0.png' })
|
||||||
.where(record_id: template.schema_documents.map(&:id),
|
.where(record_id: template.schema_documents.map(&:id),
|
||||||
record_type: 'ActiveStorage::Attachment',
|
record_type: 'ActiveStorage::Attachment',
|
||||||
name: :preview_images)
|
name: :preview_images)
|
||||||
|
|||||||
@@ -9,9 +9,10 @@ RSpec.describe 'Submission Preview' do
|
|||||||
|
|
||||||
context 'when not submitted' do
|
context 'when not submitted' do
|
||||||
let(:submission) { create(:submission, template:, created_by_user: user) }
|
let(:submission) { create(:submission, template:, created_by_user: user) }
|
||||||
let(:submitters) { template.submitters.map { |s| create(:submitter, submission:, uuid: s['uuid']) } }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
template.submitters.map { |s| create(:submitter, submission:, uuid: s['uuid']) }
|
||||||
|
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
|
||||||
visit submissions_preview_path(slug: submission.slug)
|
visit submissions_preview_path(slug: submission.slug)
|
||||||
|
|||||||
Reference in new issue
Block a user