mirror of
https://github.com/docusealco/docuseal.git
synced 2026-06-23 04:10:11 +00:00
add shared link form fields preferences
This commit is contained in:
committed by
Pete Matsyburka
parent
b4f80422eb
commit
18ee2d5316
@@ -33,7 +33,7 @@ class StartFormController < ApplicationController
|
||||
@submitter = find_or_initialize_submitter(@template, submitter_params)
|
||||
|
||||
if @submitter.completed_at?
|
||||
redirect_to start_form_completed_path(@template.slug, email: submitter_params[:email])
|
||||
redirect_to start_form_completed_path(@template.slug, submitter_params.compact_blank)
|
||||
else
|
||||
if filter_undefined_submitters(@template).size > 1 && @submitter.new_record?
|
||||
@error_message = multiple_submitters_error_message
|
||||
@@ -49,7 +49,7 @@ class StartFormController < ApplicationController
|
||||
@submitter.assign_attributes(ip: request.remote_ip, ua: request.user_agent)
|
||||
end
|
||||
|
||||
if @submitter.save
|
||||
if @submitter.errors.blank? && @submitter.save
|
||||
if is_new_record
|
||||
enqueue_submission_create_webhooks(@submitter)
|
||||
|
||||
@@ -71,9 +71,20 @@ class StartFormController < ApplicationController
|
||||
def completed
|
||||
return redirect_to start_form_path(@template.slug) if !@template.shared_link? || @template.archived_at?
|
||||
|
||||
submitter_params = params.permit(:name, :email, :phone).tap do |attrs|
|
||||
attrs[:email] = Submissions.normalize_email(attrs[:email])
|
||||
end
|
||||
|
||||
required_fields = @template.preferences.fetch('link_form_fields', ['email'])
|
||||
|
||||
required_params = required_fields.index_with { |key| submitter_params[key] }
|
||||
|
||||
raise ActionController::RoutingError, I18n.t('not_found') if required_params.any? { |_, v| v.blank? } ||
|
||||
required_params.except('name').compact_blank.blank?
|
||||
|
||||
@submitter = Submitter.where(submission: @template.submissions)
|
||||
.where.not(completed_at: nil)
|
||||
.find_by!(email: params[:email])
|
||||
.find_by!(required_params)
|
||||
end
|
||||
|
||||
private
|
||||
@@ -104,7 +115,16 @@ class StartFormController < ApplicationController
|
||||
end
|
||||
|
||||
def find_or_initialize_submitter(template, submitter_params)
|
||||
Submitter
|
||||
required_fields = template.preferences.fetch('link_form_fields', ['email'])
|
||||
|
||||
required_params = required_fields.index_with { |key| submitter_params[key] }
|
||||
|
||||
find_params = required_params.except('name')
|
||||
|
||||
submitter = Submitter.new if find_params.compact_blank.blank?
|
||||
|
||||
submitter ||=
|
||||
Submitter
|
||||
.where(submission: template.submissions.where(expire_at: Time.current..)
|
||||
.or(template.submissions.where(expire_at: nil)).where(archived_at: nil))
|
||||
.order(id: :desc)
|
||||
@@ -112,7 +132,15 @@ class StartFormController < ApplicationController
|
||||
.where(external_id: nil)
|
||||
.where(ip: [nil, request.remote_ip])
|
||||
.then { |rel| params[:resubmit].present? || params[:selfsign].present? ? rel.where(completed_at: nil) : rel }
|
||||
.find_or_initialize_by(email: submitter_params[:email], **submitter_params.compact_blank)
|
||||
.find_or_initialize_by(find_params)
|
||||
|
||||
submitter.name = required_params['name'] if submitter.new_record?
|
||||
|
||||
required_params.each do |key, value|
|
||||
submitter.errors.add(key.to_sym, :blank) if value.blank?
|
||||
end
|
||||
|
||||
submitter
|
||||
end
|
||||
|
||||
def assign_submission_attributes(submitter, template)
|
||||
|
||||
@@ -31,7 +31,7 @@ class TemplatesPreferencesController < ApplicationController
|
||||
completed_notification_email_subject completed_notification_email_body
|
||||
completed_notification_email_enabled completed_notification_email_attach_audit] +
|
||||
[completed_message: %i[title body],
|
||||
submitters: [%i[uuid request_email_subject request_email_body]]]
|
||||
submitters: [%i[uuid request_email_subject request_email_body]], link_form_fields: []]
|
||||
).tap do |attrs|
|
||||
attrs[:preferences].delete(:submitters) if params[:request_email_per_submitter] != '1'
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import SetDateButton from './elements/set_date_button'
|
||||
import IndeterminateCheckbox from './elements/indeterminate_checkbox'
|
||||
import AppTour from './elements/app_tour'
|
||||
import DashboardDropzone from './elements/dashboard_dropzone'
|
||||
import RequiredCheckboxGroup from './elements/required_checkbox_group'
|
||||
|
||||
import * as TurboInstantClick from './lib/turbo_instant_click'
|
||||
|
||||
@@ -105,6 +106,7 @@ safeRegisterElement('indeterminate-checkbox', IndeterminateCheckbox)
|
||||
safeRegisterElement('app-tour', AppTour)
|
||||
safeRegisterElement('dashboard-dropzone', DashboardDropzone)
|
||||
safeRegisterElement('check-on-click', CheckOnClick)
|
||||
safeRegisterElement('required-checkbox-group', RequiredCheckboxGroup)
|
||||
|
||||
safeRegisterElement('template-builder', class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export default class extends HTMLElement {
|
||||
connectedCallback () {
|
||||
this.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
|
||||
checkbox.addEventListener('change', this.handleChange)
|
||||
})
|
||||
}
|
||||
|
||||
handleChange = () => {
|
||||
if (this.checkedCount !== 0) {
|
||||
this.closest('form')?.requestSubmit()
|
||||
}
|
||||
}
|
||||
|
||||
get checkedCount () {
|
||||
return this.querySelectorAll('input[type="checkbox"]:checked').length
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
<% end %>
|
||||
<% if Templates.filter_undefined_submitters(@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 && @template.shared_link? %>
|
||||
<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: true }, 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: params.permit(:name, :email, :phone).compact_blank, resubmit: true }, method: :put, class: 'white-button w-full' %>
|
||||
</toggle-submit>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -29,13 +29,32 @@
|
||||
</div>
|
||||
<% if !@template.archived_at? && !@template.account.archived_at? %>
|
||||
<%= form_for @submitter, url: start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put, html: { class: 'space-y-4' } do |f| %>
|
||||
<div dir="auto" class="form-control !mt-0">
|
||||
<%= f.label :email, t('email'), class: 'label' %>
|
||||
<%= f.email_field :email, value: current_user&.email || params[:email] || @submitter.email, required: true, class: 'base-input', placeholder: t('provide_your_email_to_start') %>
|
||||
<% if @error_message %>
|
||||
<span class="label-text-alt text-red-400 mt-1"><%= @error_message %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @error_message %>
|
||||
<div class="alert items-start bg-base-100 border border-red-400 text-red-400">
|
||||
<%= svg_icon('info_circle', class: 'stroke-current shrink-0 h-6 w-6 mt-1') %>
|
||||
<div class="text-sm"><%= @error_message %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% link_form_fields = @template.preferences.fetch('link_form_fields', ['email']) %>
|
||||
<% multiple_fields = link_form_fields.size > 1 %>
|
||||
<% if link_form_fields.include?('name') %>
|
||||
<div dir="auto" class="form-control !mt-0">
|
||||
<%= f.label :name, t('name'), class: 'label' %>
|
||||
<%= f.text_field :name, value: current_user&.full_name || params[:name] || @submitter.name, required: true, class: 'base-input', placeholder: t(multiple_fields ? 'provide_your_name' : 'provide_your_name_to_start') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if link_form_fields.include?('email') %>
|
||||
<div dir="auto" class="form-control !mt-0">
|
||||
<%= f.label :email, t('email'), class: 'label' %>
|
||||
<%= f.email_field :email, value: current_user&.email || params[:email] || @submitter.email, required: true, class: 'base-input', placeholder: t(multiple_fields ? 'provide_your_email' : 'provide_your_email_to_start') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if link_form_fields.include?('phone') %>
|
||||
<div dir="auto" class="form-control !mt-0">
|
||||
<%= f.label :phone, t('phone'), class: 'label' %>
|
||||
<%= f.telephone_field :phone, value: params[:phone] || @submitter.phone, pattern: '^\+[0-9\s\-]+$', oninvalid: "this.value ? this.setCustomValidity('#{t('use_international_format_1xxx_')}') : ''", oninput: "this.setCustomValidity('')", required: true, class: 'base-input', placeholder: t(multiple_fields ? 'provide_your_phone_in_international_format' : 'provide_your_phone_in_international_format_to_start') %>
|
||||
</div>
|
||||
<% end %>
|
||||
<toggle-submit dir="auto" class="form-control">
|
||||
<%= f.button button_title(title: t('start'), disabled_with: t('starting')), class: 'base-button' %>
|
||||
</toggle-submit>
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
<% close_on_submit = local_assigns.fetch(:close_on_submit, true) %>
|
||||
<%= form_for template, url: template_recipients_path(template), method: :post, html: { autocomplete: 'off', class: 'mt-1', id: :submitters_form }, data: { close_on_submit: } do |f| %>
|
||||
<% unless close_on_submit %>
|
||||
<toggle-on-submit data-element-id="form_saved_alert"></toggle-on-submit>
|
||||
<% end %>
|
||||
<div class="space-y-3 divide-y">
|
||||
<% template.submitters.each_with_index do |submitter, index| %>
|
||||
<div class="<%= 'pt-3' if index.positive? %>">
|
||||
<%= f.fields_for :submitters, item = Struct.new(:name, :uuid, :is_requester, :email, :invite_by_uuid, :optional_invite_by_uuid, :linked_to_uuid, :option).new(*submitter.values_at('name', 'uuid', 'is_requester', 'email', 'invite_by_uuid', 'optional_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.invite_by_uuid.present? ? "invite_by_#{item.invite_by_uuid}" : (item.optional_invite_by_uuid.present? ? "optional_invite_by_#{item.optional_invite_by_uuid}" : '')))) %>
|
||||
<%= ff.hidden_field :uuid %>
|
||||
<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 %>
|
||||
<% if template.submitters.size == 2 %>
|
||||
<%= tag.input name: ff.field_name(:email), value: ff.object.email, type: :email, class: 'base-input', multiple: true, autocomplete: 'off', placeholder: t('default_email'), disabled: ff.object.is_requester || ff.object.invite_by_uuid.present? || ff.object.optional_invite_by_uuid.present?, id: field_uuid = SecureRandom.uuid %>
|
||||
<% else %>
|
||||
<toggle-attribute data-target-id="<%= email_field_uuid = SecureRandom.uuid %>" data-class-name="hidden" data-value="email">
|
||||
<%= ff.select :option, [[t('not_specified'), 'not_set'], [t('submission_requester'), 'is_requester'], [t('specified_email'), 'email'], *(template.submitters - [submitter]).flat_map { |e| [[t('invite_by_name', name: e['name']), "invite_by_#{e['uuid']}"], [t('invite_by_name', name: e['name']) + " (#{t(:optional).capitalize})", "optional_invite_by_#{e['uuid']}"]] }, *(template.submitters - [submitter]).map { |e| [t('same_as_name', name: e['name']), "linked_to_#{e['uuid']}"] }], {}, class: 'base-select mb-3' %>
|
||||
</toggle-attribute>
|
||||
<%= tag.input name: ff.field_name(:email), type: :email, value: ff.object.email, multiple: true, class: "base-input #{'hidden' if item.option != 'email'}", autocomplete: 'off', placeholder: t('default_email'), id: email_field_uuid %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if template.submitters.size == 2 %>
|
||||
<checkbox-group class="mt-3 flex items-center space-x-4">
|
||||
<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 :is_requester, class: 'base-checkbox' %>
|
||||
</toggle-attribute>
|
||||
<span class="select-none">
|
||||
<%= t('submission_requester') %>
|
||||
</span>
|
||||
</label>
|
||||
<% 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">
|
||||
<indeterminate-checkbox data-indeterminate="<%= ff.object.optional_invite_by_uuid.present? %>" data-show-indeterminate-id="invite_optional" data-name="<%= ff.field_name(:invite_by_uuid) %>" data-indeterminate-name="<%= ff.field_name(:optional_invite_by_uuid) %>" class="flex">
|
||||
<%= ff.check_box ff.object.optional_invite_by_uuid.present? ? :optional_invite_by_uuid : :invite_by_uuid, { class: 'base-checkbox' }, template.submitters.first['uuid'], '' %>
|
||||
</indeterminate-checkbox>
|
||||
</toggle-attribute>
|
||||
<span class="select-none">
|
||||
<%= t('invite_by_name', name: template.submitters.first['name']) %> <span id="invite_optional" class="<%= 'hidden' if ff.object.optional_invite_by_uuid.blank? %>">(<%= t(:optional).capitalize %>)</span>
|
||||
</span>
|
||||
</label>
|
||||
<% end %>
|
||||
</checkbox-group>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless current_account.account_configs.exists?(key: AccountConfig::ENFORCE_SIGNING_ORDER_KEY, value: true) %>
|
||||
<%= form_for template, url: template_preferences_path(template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %>
|
||||
<div class="flex items-center pt-4 mt-4 justify-between border-t w-full">
|
||||
<span>
|
||||
<%= t('enforce_recipients_order') %>
|
||||
</span>
|
||||
<%= f.fields_for :preferences, Struct.new(:submitters_order).new(template.preferences['submitters_order']) do |ff| %>
|
||||
<%= ff.check_box :submitters_order, { class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'preserved', '' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if can?(:manage, :personalization_advanced) %>
|
||||
<%= form_for template, url: template_preferences_path(template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %>
|
||||
<div class="flex items-center mt-4 justify-between w-full">
|
||||
<span>
|
||||
<%= t('ensure_unique_recipients') %>
|
||||
</span>
|
||||
<%= f.fields_for :preferences, Struct.new(:validate_unique_submitters).new(template.preferences['validate_unique_submitters']) do |ff| %>
|
||||
<%= ff.check_box :validate_unique_submitters, { class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'true', '' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="form-control mt-5">
|
||||
<%= button_tag button_title(title: t('save'), disabled_with: t('updating')), class: 'base-button', form: :submitters_form %>
|
||||
<% unless close_on_submit %>
|
||||
<div class="flex justify-center">
|
||||
<span id="form_saved_alert" class="text-sm invisible font-normal mt-0.5"><%= t('changes_have_been_saved') %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -287,91 +287,8 @@
|
||||
<%= render 'templates_code_modal/preferences', class: 'pt-2' %>
|
||||
</div>
|
||||
<% if show_recipients %>
|
||||
<div id="recipients" class="hidden mt-2 mb-4 px-5">
|
||||
<%= form_for @template, url: template_recipients_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1', id: :submitters_form } do |f| %>
|
||||
<div class="space-y-3 divide-y">
|
||||
<% @template.submitters.each_with_index do |submitter, index| %>
|
||||
<div class="pt-3">
|
||||
<%= f.fields_for :submitters, item = Struct.new(:name, :uuid, :is_requester, :email, :invite_by_uuid, :optional_invite_by_uuid, :linked_to_uuid, :option).new(*submitter.values_at('name', 'uuid', 'is_requester', 'email', 'invite_by_uuid', 'optional_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.invite_by_uuid.present? ? "invite_by_#{item.invite_by_uuid}" : (item.optional_invite_by_uuid.present? ? "optional_invite_by_#{item.optional_invite_by_uuid}" : '')))) %>
|
||||
<%= ff.hidden_field :uuid %>
|
||||
<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 %>
|
||||
<% if @template.submitters.size == 2 %>
|
||||
<%= tag.input name: ff.field_name(:email), value: ff.object.email, type: :email, class: 'base-input', multiple: true, autocomplete: 'off', placeholder: t('default_email'), disabled: ff.object.is_requester || ff.object.invite_by_uuid.present? || ff.object.optional_invite_by_uuid.present?, id: field_uuid = SecureRandom.uuid %>
|
||||
<% else %>
|
||||
<toggle-attribute data-target-id="<%= email_field_uuid = SecureRandom.uuid %>" data-class-name="hidden" data-value="email">
|
||||
<%= ff.select :option, [[t('not_specified'), 'not_set'], [t('submission_requester'), 'is_requester'], [t('specified_email'), 'email'], *(@template.submitters - [submitter]).flat_map { |e| [[t('invite_by_name', name: e['name']), "invite_by_#{e['uuid']}"], [t('invite_by_name', name: e['name']) + " (#{t(:optional).capitalize})", "optional_invite_by_#{e['uuid']}"]] }, *(@template.submitters - [submitter]).map { |e| [t('same_as_name', name: e['name']), "linked_to_#{e['uuid']}"] }], {}, class: 'base-select mb-3' %>
|
||||
</toggle-attribute>
|
||||
<%= tag.input name: ff.field_name(:email), type: :email, value: ff.object.email, multiple: true, class: "base-input #{'hidden' if item.option != 'email'}", autocomplete: 'off', placeholder: t('default_email'), id: email_field_uuid %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @template.submitters.size == 2 %>
|
||||
<checkbox-group class="mt-3 flex items-center space-x-4">
|
||||
<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 :is_requester, class: 'base-checkbox' %>
|
||||
</toggle-attribute>
|
||||
<span class="select-none">
|
||||
<%= t('submission_requester') %>
|
||||
</span>
|
||||
</label>
|
||||
<% 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">
|
||||
<indeterminate-checkbox data-indeterminate="<%= ff.object.optional_invite_by_uuid.present? %>" data-show-indeterminate-id="invite_optional" data-name="<%= ff.field_name(:invite_by_uuid) %>" data-indeterminate-name="<%= ff.field_name(:optional_invite_by_uuid) %>" class="flex">
|
||||
<%= ff.check_box ff.object.optional_invite_by_uuid.present? ? :optional_invite_by_uuid : :invite_by_uuid, { class: 'base-checkbox' }, @template.submitters.first['uuid'], '' %>
|
||||
</indeterminate-checkbox>
|
||||
</toggle-attribute>
|
||||
<span class="select-none">
|
||||
<%= t('invite_by_name', name: @template.submitters.first['name']) %> <span id="invite_optional" class="<%= 'hidden' if ff.object.optional_invite_by_uuid.blank? %>">(<%= t(:optional).capitalize %>)</span>
|
||||
</span>
|
||||
</label>
|
||||
<% end %>
|
||||
</checkbox-group>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless current_account.account_configs.exists?(key: AccountConfig::ENFORCE_SIGNING_ORDER_KEY, value: true) %>
|
||||
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %>
|
||||
<div class="flex items-center pt-4 mt-4 justify-between border-t w-full">
|
||||
<span>
|
||||
<%= t('enforce_recipients_order') %>
|
||||
</span>
|
||||
<%= f.fields_for :preferences, Struct.new(:submitters_order).new(@template.preferences['submitters_order']) do |ff| %>
|
||||
<%= ff.check_box :submitters_order, { class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'preserved', '' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if can?(:manage, :personalization_advanced) %>
|
||||
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %>
|
||||
<div class="flex items-center mt-4 justify-between w-full">
|
||||
<span>
|
||||
<%= t('ensure_unique_recipients') %>
|
||||
</span>
|
||||
<%= f.fields_for :preferences, Struct.new(:validate_unique_submitters).new(@template.preferences['validate_unique_submitters']) do |ff| %>
|
||||
<%= ff.check_box :validate_unique_submitters, { class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'true', '' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %>
|
||||
<div class="flex items-center mt-4 justify-between w-full">
|
||||
<span>
|
||||
<%= t('require_all_recipients') %>
|
||||
</span>
|
||||
<%= f.fields_for :preferences, Struct.new(:require_all_submitters).new(@template.preferences['require_all_submitters']) do |ff| %>
|
||||
<%= ff.check_box :require_all_submitters, { class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'true', '' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="form-control mt-5 pb-2">
|
||||
<%= button_tag button_title(title: t('save'), disabled_with: t('updating')), class: 'base-button', form: :submitters_form %>
|
||||
</div>
|
||||
<div id="recipients" class="hidden mt-2 mb-4 px-5 pt-1 pb-2">
|
||||
<%= render 'recipients', template: @template %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if show_api %>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<%= render 'shared/turbo_modal_large', title: t('share_link') do %>
|
||||
<div class="mt-2 mb-4 px-5">
|
||||
<%= form_for @template, url: template_share_link_path(@template), method: :post, html: { id: 'shared_link_form', autocomplete: 'off', class: 'mt-3' }, data: { close_on_submit: false } do |f| %>
|
||||
<div class="flex items-center justify-between gap-1 px-1">
|
||||
<span><%= t('enable_shared_link') %></span>
|
||||
<div class="flex items-center justify-between gap-1">
|
||||
<span class="pl-1"><%= t('enable_shared_link') %></span>
|
||||
<%= f.check_box :shared_link, { disabled: !can?(:update, @template), class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'true', 'false' %>
|
||||
</div>
|
||||
<div class="flex gap-2 mt-3">
|
||||
@@ -12,5 +12,34 @@
|
||||
</check-on-click>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-3' }, data: { close_on_submit: false } do |f| %>
|
||||
<% link_form_fields = @template.preferences.fetch('link_form_fields', ['email']) %>
|
||||
<label class="pl-1"><%= t('link_form_fields') %></label>
|
||||
<required-checkbox-group class="flex flex-col md:flex-row items-center gap-2 w-full mt-2">
|
||||
<% %w[name email phone].each do |field| %>
|
||||
<%= label_tag "link_form_fields_#{field}", t(field), class: 'relative flex w-full md:w-1/3 items-center h-12 border-base-300 py-3.5 border rounded-xl' do %>
|
||||
<%= check_box_tag 'template[preferences][link_form_fields][]', field, link_form_fields.include?(field), class: 'absolute !animate-none checkbox left-3', id: "link_form_fields_#{field}" %>
|
||||
<span class="font-medium w-full text-center"><%= t(field) %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</required-checkbox-group>
|
||||
<% end %>
|
||||
<% if Templates.filter_undefined_submitters(@template.submitters).size > 1 %>
|
||||
<div class="alert items-start bg-base-100 border-base-300 mt-4">
|
||||
<%= svg_icon('info_circle', class: 'stroke-current shrink-0 h-6 w-6 mt-1') %>
|
||||
<div><%= t('this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link') %></div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @template.submitters.to_a.length > 1 %>
|
||||
<div class="collapse collapse-arrow join-item border border-base-300 mt-4">
|
||||
<input type="checkbox" name="accordion">
|
||||
<div class="collapse-title text-xl font-medium">
|
||||
<%= t('recipients') %>
|
||||
</div>
|
||||
<div class="collapse-content !pb-0">
|
||||
<%= render 'templates_preferences/recipients', template: @template, close_on_submit: false %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
+106
-10
@@ -115,6 +115,11 @@ en: &en
|
||||
role: Role
|
||||
reason: Reason
|
||||
provide_your_email_to_start: Provide your email to start
|
||||
provide_your_email: Provide your email
|
||||
provide_your_name_to_start: Provide your name to start
|
||||
provide_your_name: Provide your name
|
||||
provide_your_phone_in_international_format_to_start: Provide your phone in international format to start
|
||||
provide_your_phone_in_international_format: Provide your phone in international format
|
||||
start: Start
|
||||
enforce_recipients_order: Enforce recipients order
|
||||
starting: Starting
|
||||
@@ -754,6 +759,9 @@ en: &en
|
||||
select_data_residency: Select data residency
|
||||
account_name_has_invited_you_to_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: '%{account_name} has invited you to fill and sign documents online effortlessly with a secure, fast, and user-friendly digital document signing solution.'
|
||||
review_or_download_completed_documents_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: Review or download completed documents. Fill and sign documents online effortlessly with a secure, fast, and user-friendly digital document signing solution.
|
||||
link_form_fields: Link form fields
|
||||
at_least_one_field_must_be_displayed_in_the_form: At least one field must be displayed in the form.
|
||||
this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link: This template has multiple parties, which prevents the use of a sharing link as it's unclear which party is responsible for specific fields. To resolve this, define the default party details.
|
||||
submission_sources:
|
||||
api: API
|
||||
bulk: Bulk Send
|
||||
@@ -953,6 +961,11 @@ es: &es
|
||||
role: Rol
|
||||
reason: Razón
|
||||
provide_your_email_to_start: Proporciona tu correo electrónico para comenzar
|
||||
provide_your_email: Proporciona tu correo electrónico
|
||||
provide_your_name_to_start: Proporciona tu nombre para comenzar
|
||||
provide_your_name: Proporciona tu nombre
|
||||
provide_your_phone_in_international_format_to_start: Proporciona tu teléfono en formato internacional para comenzar
|
||||
provide_your_phone_in_international_format: Proporciona tu teléfono en formato internacional
|
||||
start: Comenzar
|
||||
starting: Comenzando
|
||||
form_has_been_deleted_by_html: 'El formulario ha sido eliminado por <span class="font-semibold">%{name}</span>.'
|
||||
@@ -1591,6 +1604,9 @@ es: &es
|
||||
select_data_residency: Seleccionar ubicación de datos
|
||||
account_name_has_invited_you_to_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: '%{account_name} te ha invitado a completar y firmar documentos en línea fácilmente con una solución de firma digital segura, rápida y fácil de usar.'
|
||||
review_or_download_completed_documents_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: Revisa o descarga los documentos completados. Completa y firma documentos en línea fácilmente con una solución de firma digital segura, rápida y fácil de usar.
|
||||
link_form_fields: Vincular campos del formulario
|
||||
at_least_one_field_must_be_displayed_in_the_form: Al menos un campo debe mostrarse en el formulario.
|
||||
this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link: Esta plantilla tiene varias partes, lo que impide el uso de un enlace compartido porque no está claro qué parte es responsable de campos específicos. Para resolverlo, define los detalles predeterminados de la parte.
|
||||
submission_sources:
|
||||
api: API
|
||||
bulk: Envío masivo
|
||||
@@ -1789,6 +1805,11 @@ it: &it
|
||||
role: Ruolo
|
||||
reason: Ragione
|
||||
provide_your_email_to_start: Fornisci la tua email per iniziare
|
||||
provide_your_email: Fornisci la tua email
|
||||
provide_your_name_to_start: Fornisci il tuo nome per iniziare
|
||||
provide_your_name: Fornisci il tuo nome
|
||||
provide_your_phone_in_international_format_to_start: Fornisci il tuo telefono in formato internazionale per iniziare
|
||||
provide_your_phone_in_international_format: Fornisci il tuo telefono in formato internazionale
|
||||
start: Inizia
|
||||
starting: Iniziando
|
||||
form_has_been_deleted_by_html: 'Il modulo è stato eliminato da <span class="font-semibold">%{name}</span>.'
|
||||
@@ -2426,6 +2447,9 @@ it: &it
|
||||
select_data_residency: Seleziona la residenza dei dati
|
||||
account_name_has_invited_you_to_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: '%{account_name} ti ha invitato a compilare e firmare documenti online con facilità utilizzando una soluzione di firma digitale sicura, veloce e facile da usare.'
|
||||
review_or_download_completed_documents_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: Rivedi o scarica i documenti completati. Compila e firma documenti online facilmente con una soluzione di firma digitale sicura, veloce e facile da usare.
|
||||
link_form_fields: Collega i campi del modulo
|
||||
at_least_one_field_must_be_displayed_in_the_form: Almeno un campo deve essere visualizzato nel modulo.
|
||||
this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link: Questo modello ha più parti, il che impedisce l’uso di un link di condivisione perché non è chiaro quale parte sia responsabile di campi specifici. Per risolvere, definisci i dettagli predefiniti della parte.
|
||||
submission_sources:
|
||||
api: API
|
||||
bulk: Invio massivo
|
||||
@@ -2624,7 +2648,12 @@ fr: &fr
|
||||
digitally_signed_by: Signé numériquement par
|
||||
role: Rôle
|
||||
reason: Raison
|
||||
provide_your_email_to_start: Entrez votre adresse email pour commencer
|
||||
provide_your_email_to_start: Fournissez votre e-mail pour commencer
|
||||
provide_your_email: Fournissez votre e-mail
|
||||
provide_your_name_to_start: Fournissez votre nom pour commencer
|
||||
provide_your_name: Fournissez votre nom
|
||||
provide_your_phone_in_international_format_to_start: Fournissez votre téléphone au format international pour commencer
|
||||
provide_your_phone_in_international_format: Fournissez votre téléphone au format international
|
||||
start: Démarrer
|
||||
starting: Démarrage
|
||||
form_has_been_deleted_by_html: 'Le formulaire a été supprimé par <span class="font-semibold">%{name}</span>.'
|
||||
@@ -3264,6 +3293,9 @@ fr: &fr
|
||||
select_data_residency: Sélectionner la résidence des données
|
||||
account_name_has_invited_you_to_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: '%{account_name} vous a invité à remplir et signer des documents en ligne facilement avec une solution de signature numérique sécurisée, rapide et conviviale.'
|
||||
review_or_download_completed_documents_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: Consultez ou téléchargez les documents complétés. Remplissez et signez des documents en ligne facilement avec une solution de signature numérique sécurisée, rapide et conviviale.
|
||||
link_form_fields: Lier les champs du formulaire
|
||||
at_least_one_field_must_be_displayed_in_the_form: Au moins un champ doit être affiché dans le formulaire.
|
||||
this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link: Ce modèle contient plusieurs parties, ce qui empêche l’utilisation d’un lien de partage car il n’est pas clair quelle partie est responsable de certains champs. Pour résoudre cela, définissez les détails de la partie par défaut.
|
||||
submission_sources:
|
||||
api: API
|
||||
bulk: Envoi en masse
|
||||
@@ -3462,7 +3494,12 @@ pt: &pt
|
||||
digitally_signed_by: Assinado digitalmente por
|
||||
role: Função
|
||||
reason: Motivo
|
||||
provide_your_email_to_start: Forneça o seu email para começar
|
||||
provide_your_email_to_start: Informe seu e-mail para começar
|
||||
provide_your_email: Informe seu e-mail
|
||||
provide_your_name_to_start: Informe seu nome para começar
|
||||
provide_your_name: Informe seu nome
|
||||
provide_your_phone_in_international_format_to_start: Informe seu telefone no formato internacional para começar
|
||||
provide_your_phone_in_international_format: Informe seu telefone no formato internacional
|
||||
start: Iniciar
|
||||
starting: Iniciando
|
||||
form_has_been_deleted_by_html: 'O formulário foi eliminado por <span class="font-semibold">%{name}</span>.'
|
||||
@@ -4101,6 +4138,9 @@ pt: &pt
|
||||
select_data_residency: Selecionar local dos dados
|
||||
account_name_has_invited_you_to_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: '%{account_name} convidou você para preencher e assinar documentos online com facilidade usando uma solução de assinatura digital segura, rápida e fácil de usar.'
|
||||
review_or_download_completed_documents_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: Reveja ou baixe os documentos concluídos. Preencha e assine documentos online com facilidade usando uma solução de assinatura digital segura, rápida e fácil de usar.
|
||||
link_form_fields: Vincular campos do formulário
|
||||
at_least_one_field_must_be_displayed_in_the_form: Pelo menos um campo deve ser exibido no formulário.
|
||||
this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link: Este modelo tem várias partes, o que impede o uso de um link de compartilhamento, pois não está claro qual parte é responsável por campos específicos. Para resolver isso, defina os detalhes padrão da parte.
|
||||
submission_sources:
|
||||
api: API
|
||||
bulk: Envio em massa
|
||||
@@ -4300,7 +4340,12 @@ de: &de
|
||||
digitally_signed_by: Digital signiert von
|
||||
role: Rolle
|
||||
reason: Grund
|
||||
provide_your_email_to_start: Gib deine E-Mail-Adresse ein, um zu starten
|
||||
provide_your_email_to_start: Geben Sie Ihre E-Mail-Adresse ein, um zu starten
|
||||
provide_your_email: Geben Sie Ihre E-Mail-Adresse ein
|
||||
provide_your_name_to_start: Geben Sie Ihren Namen ein, um zu starten
|
||||
provide_your_name: Geben Sie Ihren Namen ein
|
||||
provide_your_phone_in_international_format_to_start: Geben Sie Ihre Telefonnummer im internationalen Format ein, um zu starten
|
||||
provide_your_phone_in_international_format: Geben Sie Ihre Telefonnummer im internationalen Format ein
|
||||
start: Starten
|
||||
starting: Starten
|
||||
form_has_been_deleted_by_html: 'Das Formular wurde von <span class="font-semibold">%{name}</span> gelöscht.'
|
||||
@@ -4939,6 +4984,9 @@ de: &de
|
||||
select_data_residency: Datenstandort auswählen
|
||||
account_name_has_invited_you_to_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: '%{account_name} hat Sie eingeladen, Dokumente mühelos online mit einer sicheren, schnellen und benutzerfreundlichen digitalen Signaturlösung auszufüllen und zu unterschreiben.'
|
||||
review_or_download_completed_documents_fill_and_sign_documents_online_effortlessly_with_a_secure_fast_and_user_friendly_digital_document_signing_solution: Überprüfen oder laden Sie abgeschlossene Dokumente herunter. Füllen und unterschreiben Sie Dokumente mühelos online mit einer sicheren, schnellen und benutzerfreundlichen digitalen Signaturlösung.
|
||||
link_form_fields: Formularfelder verknüpfen
|
||||
at_least_one_field_must_be_displayed_in_the_form: Mindestens ein Feld muss im Formular angezeigt werden.
|
||||
this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link: Diese Vorlage enthält mehrere Parteien, was die Verwendung eines Freigabelinks verhindert, da unklar ist, welche Partei für bestimmte Felder verantwortlich ist. Um dies zu beheben, definieren Sie die Standardparteidetails.
|
||||
submission_sources:
|
||||
api: API
|
||||
bulk: Massenversand
|
||||
@@ -5063,7 +5111,13 @@ pl:
|
||||
digitally_signed_by: Podpis cyfrowy przez
|
||||
form_expired_at_html: 'Formularz wygasł o <span class="font-semibold">%{time}</span>'
|
||||
role: Rola
|
||||
provide_your_email_to_start: Podaj swój adres email, aby rozpocząć
|
||||
provide_your_email_to_start: Podaj swój e-mail, aby rozpocząć
|
||||
provide_your_email: Podaj swój e-mail
|
||||
provide_your_name_to_start: Podaj swoje imię, aby rozpocząć
|
||||
provide_your_name: Podaj swoje imię
|
||||
provide_your_phone_in_international_format_to_start: Podaj numer telefonu w formacie międzynarodowym, aby rozpocząć
|
||||
provide_your_phone_in_international_format: Podaj numer telefonu w formacie międzynarodowym
|
||||
use_international_format_1xxx_: 'Użyj formatu międzynarodowego: +1xxx...'
|
||||
start: Rozpocznij
|
||||
reason: Powód
|
||||
starting: Rozpoczynanie
|
||||
@@ -5136,7 +5190,13 @@ uk:
|
||||
digitally_signed_by: Цифровий підпис від
|
||||
verification_code_code: 'Код підтвердження: %{code}'
|
||||
role: Роль
|
||||
provide_your_email_to_start: Введіть свій email, щоб почати
|
||||
provide_your_email_to_start: Введіть свій емейл, щоб почати
|
||||
provide_your_email: Введіть свій емейл
|
||||
provide_your_name_to_start: Введіть своє ім’я, щоб почати
|
||||
provide_your_name: Введіть своє ім’я
|
||||
provide_your_phone_in_international_format_to_start: Введіть номер телефону у міжнародному форматі, щоб почати
|
||||
provide_your_phone_in_international_format: Введіть номер телефону у міжнародному форматі
|
||||
use_international_format_1xxx_: 'Використовуйте міжнародний формат: +1xxx...'
|
||||
form_expired_at_html: 'Строк подачі завершився о <span class="font-semibold">%{time}</span>'
|
||||
start: Почати
|
||||
reason: Причина
|
||||
@@ -5210,7 +5270,13 @@ cs:
|
||||
digitally_signed_by: Digitálně podepsáno uživatelem
|
||||
verification_code_code: 'Ověřovací kód: %{code}'
|
||||
role: Role
|
||||
provide_your_email_to_start: Zadejte svůj email pro zahájení
|
||||
provide_your_email_to_start: Zadejte svůj e-mail pro zahájení
|
||||
provide_your_email: Zadejte svůj e-mail
|
||||
provide_your_name_to_start: Zadejte své jméno pro zahájení
|
||||
provide_your_name: Zadejte své jméno
|
||||
provide_your_phone_in_international_format_to_start: Zadejte své telefonní číslo v mezinárodním formátu pro zahájení
|
||||
provide_your_phone_in_international_format: Zadejte své telefonní číslo v mezinárodním formátu
|
||||
use_international_format_1xxx_: 'Použijte mezinárodní formát: +1xxx...'
|
||||
reason: Důvod
|
||||
form_expired_at_html: 'Formulář vypršel <span class="font-semibold">%{time}</span>'
|
||||
start: Zahájit
|
||||
@@ -5285,7 +5351,13 @@ he:
|
||||
role: תפקיד
|
||||
reason: סיבה
|
||||
verification_code_code: 'קוד אימות: %{code}'
|
||||
provide_your_email_to_start: ספק את כתובת הדוא"ל שלך כדי להתחיל
|
||||
provide_your_email_to_start: הזן את האימייל שלך כדי להתחיל
|
||||
provide_your_email: הזן את האימייל שלך
|
||||
provide_your_name_to_start: הזן את שמך כדי להתחיל
|
||||
provide_your_name: הזן את שמך
|
||||
provide_your_phone_in_international_format_to_start: הזן את מספר הטלפון שלך בפורמט בינלאומי כדי להתחיל
|
||||
provide_your_phone_in_international_format: הזן את מספר הטלפון שלך בפורמט בינלאומי
|
||||
use_international_format_1xxx_: 'השתמש בפורמט בינלאומי: +1xxx...'
|
||||
start: התחל
|
||||
starting: מתחיל
|
||||
form_expired_at_html: 'הטופס פג תוקף ב- <span class="font-semibold">%{time}</span>'
|
||||
@@ -5358,7 +5430,13 @@ nl:
|
||||
digitally_signed_by: Digitaal ondertekend door
|
||||
role: Rol
|
||||
verification_code_code: 'Verificatiecode: %{code}'
|
||||
provide_your_email_to_start: Geef uw e-mailadres om te beginnen
|
||||
provide_your_email_to_start: Voer je e-mailadres in om te beginnen
|
||||
provide_your_email: Voer je e-mailadres in
|
||||
provide_your_name_to_start: Voer je naam in om te beginnen
|
||||
provide_your_name: Voer je naam in
|
||||
provide_your_phone_in_international_format_to_start: Voer je telefoonnummer in internationaal formaat in om te beginnen
|
||||
provide_your_phone_in_international_format: Voer je telefoonnummer in internationaal formaat in
|
||||
use_international_format_1xxx_: 'Gebruik het internationale formaat: +1xxx...'
|
||||
start: Start
|
||||
reason: Reden
|
||||
form_expired_at_html: 'Formulier is verlopen op <span class="font-semibold">%{time}</span>'
|
||||
@@ -5431,7 +5509,13 @@ ar:
|
||||
email: البريد الإلكتروني
|
||||
digitally_signed_by: تم التوقيع الرقمي بواسطة
|
||||
role: الدور
|
||||
provide_your_email_to_start: قدم بريدك الإلكتروني للبدء
|
||||
provide_your_email_to_start: أدخل بريدك الإلكتروني للبدء
|
||||
provide_your_email: أدخل بريدك الإلكتروني
|
||||
provide_your_name_to_start: أدخل اسمك للبدء
|
||||
provide_your_name: أدخل اسمك
|
||||
provide_your_phone_in_international_format_to_start: أدخل رقم هاتفك بصيغة دولية للبدء
|
||||
provide_your_phone_in_international_format: أدخل رقم هاتفك بصيغة دولية
|
||||
use_international_format_1xxx_: 'استخدم التنسيق الدولي: +1xxx...'
|
||||
start: بدء
|
||||
starting: بداية
|
||||
verification_code_code: 'رمز التحقق: %{code}'
|
||||
@@ -5505,7 +5589,13 @@ ko:
|
||||
email: 이메일
|
||||
digitally_signed_by: 디지털로 서명됨
|
||||
role: 역할
|
||||
provide_your_email_to_start: 시작하려면 이메일을 제공하세요
|
||||
provide_your_email_to_start: 시작하려면 이메일을 입력하세요
|
||||
provide_your_email: 이메일을 입력하세요
|
||||
provide_your_name_to_start: 시작하려면 이름을 입력하세요
|
||||
provide_your_name: 이름을 입력하세요
|
||||
provide_your_phone_in_international_format_to_start: 시작하려면 국제 형식의 전화번호를 입력하세요
|
||||
provide_your_phone_in_international_format: 국제 형식의 전화번호를 입력하세요
|
||||
use_international_format_1xxx_: '국제 형식을 사용하세요: +1xxx...'
|
||||
start: 시작
|
||||
reason: 이유
|
||||
starting: 시작 중
|
||||
@@ -5580,6 +5670,12 @@ ja:
|
||||
digitally_signed_by: 電子署名者
|
||||
role: 役割
|
||||
provide_your_email_to_start: 開始するにはメールアドレスを入力してください
|
||||
provide_your_email: メールアドレスを入力してください
|
||||
provide_your_name_to_start: 開始するには名前を入力してください
|
||||
provide_your_name: 名前を入力してください
|
||||
provide_your_phone_in_international_format_to_start: 開始するには国際形式の電話番号を入力してください
|
||||
provide_your_phone_in_international_format: 国際形式の電話番号を入力してください
|
||||
use_international_format_1xxx_: '国際形式を使用してください:+1xxx...'
|
||||
start: 開始
|
||||
reason: 理由
|
||||
starting: 開始中
|
||||
|
||||
@@ -9,18 +9,78 @@ RSpec.describe 'Signing Form' do
|
||||
create(:template, shared_link: true, account:, author:, except_field_types: %w[phone payment stamp])
|
||||
end
|
||||
|
||||
before do
|
||||
it 'displays only the email step when only email is required' do
|
||||
visit start_form_path(slug: template.slug)
|
||||
end
|
||||
|
||||
it 'shows the email step' do
|
||||
expect(page).to have_content('You have been invited to submit a form')
|
||||
expect(page).to have_content("Invited by #{account.name}")
|
||||
expect(page).to have_field('Email', type: 'email')
|
||||
expect(page).to have_field('Email', type: 'email', placeholder: 'Provide your email to start')
|
||||
expect(page).not_to have_field('Phone', type: 'tel')
|
||||
expect(page).not_to have_field('Name', type: 'text')
|
||||
expect(page).to have_button('Start')
|
||||
end
|
||||
|
||||
it 'displays name, email, and phone fields together when all are required' do
|
||||
template.update(preferences: { link_form_fields: %w[email name phone] })
|
||||
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
expect(page).to have_content('You have been invited to submit a form')
|
||||
expect(page).to have_content("Invited by #{account.name}")
|
||||
expect(page).to have_field('Email', type: 'email', placeholder: 'Provide your email')
|
||||
expect(page).to have_field('Name', type: 'text', placeholder: 'Provide your name')
|
||||
expect(page).to have_field('Phone', type: 'tel', placeholder: 'Provide your phone in international format')
|
||||
expect(page).to have_button('Start')
|
||||
end
|
||||
|
||||
it 'displays only the name step when only name is required' do
|
||||
template.update(preferences: { link_form_fields: %w[name] })
|
||||
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
expect(page).to have_content('You have been invited to submit a form')
|
||||
expect(page).to have_content("Invited by #{account.name}")
|
||||
expect(page).to have_field('Name', type: 'text', placeholder: 'Provide your name to start')
|
||||
expect(page).not_to have_field('Phone', type: 'tel')
|
||||
expect(page).not_to have_field('Email', type: 'email')
|
||||
expect(page).to have_button('Start')
|
||||
end
|
||||
|
||||
it 'displays only the phone step when only phone is required' do
|
||||
template.update(preferences: { link_form_fields: %w[phone] })
|
||||
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
expect(page).to have_content('You have been invited to submit a form')
|
||||
expect(page).to have_content("Invited by #{account.name}")
|
||||
expect(page).to have_field('Phone', type: 'tel',
|
||||
placeholder: 'Provide your phone in international format to start')
|
||||
expect(page).not_to have_field('Name', type: 'text')
|
||||
expect(page).not_to have_field('Email', type: 'email')
|
||||
expect(page).to have_button('Start')
|
||||
end
|
||||
|
||||
it 'prevents starting the form if phone is not in international format' do
|
||||
template.update(preferences: { link_form_fields: %w[phone] })
|
||||
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
fill_in 'Phone', with: '12345'
|
||||
|
||||
expect { click_button 'Start' }.not_to(change { current_path })
|
||||
end
|
||||
|
||||
it 'prevents starting the form if email is invali' do
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
fill_in 'Email', with: 'invalid-email'
|
||||
|
||||
expect { click_button 'Start' }.not_to(change { current_path })
|
||||
end
|
||||
|
||||
it 'completes the form' do
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
# Submit's email step
|
||||
fill_in 'Email', with: 'john.dou@example.com'
|
||||
click_button 'Start'
|
||||
@@ -100,6 +160,97 @@ RSpec.describe 'Signing Form' do
|
||||
expect(field_value(submitter, 'Attachment')).to be_present
|
||||
expect(field_value(submitter, 'Cell code')).to eq '123'
|
||||
end
|
||||
|
||||
# rubocop:disable RSpec/ExampleLength
|
||||
it 'completes the form when name, email, and phone are required' do
|
||||
template.update(preferences: { link_form_fields: %w[email name phone] })
|
||||
|
||||
visit start_form_path(slug: template.slug)
|
||||
|
||||
# Submit's name, email, and phone step
|
||||
fill_in 'Email', with: 'john.dou@example.com'
|
||||
fill_in 'Name', with: 'John Doe'
|
||||
fill_in 'Phone', with: '+17732298825'
|
||||
click_button 'Start'
|
||||
|
||||
# Text step
|
||||
fill_in 'First Name', with: 'John'
|
||||
click_button 'next'
|
||||
|
||||
# Date step
|
||||
fill_in 'Birthday', with: I18n.l(20.years.ago, format: '%Y-%m-%d')
|
||||
click_button 'next'
|
||||
|
||||
# Checkbox step
|
||||
check 'Do you agree?'
|
||||
click_button 'next'
|
||||
|
||||
# Radio step
|
||||
choose 'Boy'
|
||||
click_button 'next'
|
||||
|
||||
# Signature step
|
||||
draw_canvas
|
||||
click_button 'next'
|
||||
|
||||
# Number step
|
||||
fill_in 'House number', with: '123'
|
||||
click_button 'next'
|
||||
|
||||
# Multiple choice step
|
||||
%w[Red Blue].each { |color| check color }
|
||||
click_button 'next'
|
||||
|
||||
# Select step
|
||||
select 'Male', from: 'Gender'
|
||||
click_button 'next'
|
||||
|
||||
# Initials step
|
||||
draw_canvas
|
||||
click_button 'next'
|
||||
|
||||
# Image step
|
||||
find('#dropzone').click
|
||||
find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-image.png'))
|
||||
click_button 'next'
|
||||
|
||||
# File step
|
||||
find('#dropzone').click
|
||||
find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-document.pdf'))
|
||||
click_button 'next'
|
||||
|
||||
# Cell step
|
||||
fill_in 'Cell code', with: '123'
|
||||
click_on 'Complete'
|
||||
|
||||
expect(page).to have_button('Download')
|
||||
expect(page).to have_content('Document has been signed!')
|
||||
|
||||
submitter = template.submissions.last.submitters.last
|
||||
|
||||
expect(submitter.email).to eq('john.dou@example.com')
|
||||
expect(submitter.name).to eq('John Doe')
|
||||
expect(submitter.phone).to eq('+17732298825')
|
||||
expect(submitter.ip).to eq('127.0.0.1')
|
||||
expect(submitter.ua).to be_present
|
||||
expect(submitter.opened_at).to be_present
|
||||
expect(submitter.completed_at).to be_present
|
||||
expect(submitter.declined_at).to be_nil
|
||||
|
||||
expect(field_value(submitter, 'First Name')).to eq 'John'
|
||||
expect(field_value(submitter, 'Birthday')).to eq 20.years.ago.strftime('%Y-%m-%d')
|
||||
expect(field_value(submitter, 'Do you agree?')).to be_truthy
|
||||
expect(field_value(submitter, 'First child')).to eq 'Boy'
|
||||
expect(field_value(submitter, 'Signature')).to be_present
|
||||
expect(field_value(submitter, 'House number')).to eq 123
|
||||
expect(field_value(submitter, 'Colors')).to contain_exactly('Red', 'Blue')
|
||||
expect(field_value(submitter, 'Gender')).to eq 'Male'
|
||||
expect(field_value(submitter, 'Initials')).to be_present
|
||||
expect(field_value(submitter, 'Avatar')).to be_present
|
||||
expect(field_value(submitter, 'Attachment')).to be_present
|
||||
expect(field_value(submitter, 'Cell code')).to eq '123'
|
||||
end
|
||||
# rubocop:enable RSpec/ExampleLength
|
||||
end
|
||||
|
||||
context 'when the submitter form link is opened' do
|
||||
|
||||
Reference in New Issue
Block a user