<%= render 'shared/turbo_modal_large', title: t('preferences') do %> <% show_api = Docuseal.multitenant? || current_account.testing? || !current_account.linked_account_account %> <% show_recipients = @template.submitters.to_a.length > 1 %> <% options = [[t('general'), 'general']] %> <% options << [t('recipients'), 'recipients'] if show_recipients %> <% options << [t('api_and_embedding'), 'api'] if show_api %> <% if options.size > 1 %>
<% options.each_with_index do |(label, value), index| %> <%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %> <% end %>
<% end %>
<%= render 'access' %> <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %> <%= f.fields_for :preferences, Struct.new(:bcc_completed).new(@template.preferences['bcc_completed']) do |ff| %>
<%= ff.label :bcc_completed, class: 'label' do %> <%= t('completed_documents_notification_bcc_address') %> <% end %> <%= tag.input type: 'email', multiple: true, name: 'template[preferences][bcc_completed]', autocomplete: 'off', class: 'base-input', value: ff.object.bcc_completed %>
<% end %>
<%= f.button button_title(title: t('save'), disabled_with: t('updating')), class: 'base-button' %>
<% end %> <%= render 'templates_code_modal/preferences' %>
<%= t('form_preferences') %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %> <% 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, :require_phone_2fa).new(@template.preferences['completed_redirect_url'].presence, Struct.new(:title, :body).new(*(@template.preferences['completed_message'] || {}).values_at('title', 'body')), @template.preferences['require_phone_2fa'] == true) do |ff| %>
<%= ff.label :completed_redirect_url, t('redirect_on_completion_url'), class: 'label' %> <%= ff.url_field :completed_redirect_url, required: false, class: 'base-input', dir: 'auto' %>
<%= ff.fields_for :completed_message, ff.object.completed_message do |fff| %>
<%= fff.label :body, t('completion_message'), class: 'label' %> <%= fff.text_area :body, required: false, class: 'base-input w-full py-2', dir: 'auto' %>
<% end %> <%= render 'templates_preferences/form_fields', ff: %> <% end %>
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button' %>
<% end %>
<%= t('signature_request_email') %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %> <%= tag.input id: 'request_email_per_submitter', value: '1', name: 'request_email_per_submitter', class: 'peer', type: 'checkbox', hidden: true, checked: @template.preferences['submitters'].to_a.size > 1 %>
<%= f.fields_for :preferences, Struct.new(:request_email_subject, :request_email_body).new(*(@template.preferences.values_at('request_email_subject', 'request_email_body').compact_blank.presence || AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_INVITATION_EMAIL_KEY).value.values_at('subject', 'body'))) do |ff| %>
<%= ff.label :request_email_subject, t('email_subject'), class: 'label' %> <% if @template.submitters.size > 1 && @template.submitters.size < 5 %> <% end %>
<%= ff.text_field :request_email_subject, required: true, class: 'base-input', dir: 'auto' %>
<%= ff.label :request_email_body, t('email_body'), class: 'label' %> <%= svg_icon('info_circle', class: 'w-4 h-4') %>
<%= ff.text_area :request_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
<% end %>
<% if @template.submitters.size > 1 && @template.submitters.size < 5 %> <% end %>
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button' %>
<% end %>
<%= t('documents_copy_email') %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %> <% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY).value %> <%= f.fields_for :preferences, Struct.new(:documents_copy_email_reply_to, :documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled, :documents_copy_email_attach_audit, :documents_copy_email_attach_documents).new(@template.preferences['documents_copy_email_reply_to'].presence || configs['reply_to'], @template.preferences['documents_copy_email_subject'].presence || configs['subject'], @template.preferences['documents_copy_email_body'].presence || configs['body'], @template.preferences['documents_copy_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['documents_copy_email_attach_audit'] != false, configs['attach_documents'] != false && @template.preferences['documents_copy_email_attach_documents'] != false) do |ff| %>
<%= ff.label :documents_copy_email_subject, t('email_subject'), class: 'label' %> <%= ff.text_field :documents_copy_email_subject, required: true, class: 'base-input', dir: 'auto' %>
<%= ff.label :documents_copy_email_body, t('email_body'), class: 'label' %> <%= svg_icon('info_circle', class: 'w-4 h-4') %>
<%= ff.text_area :documents_copy_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
<% if can?(:manage, :reply_to) %>
<%= ff.label :documents_copy_email_reply_to, t('reply_to'), class: 'label' %> <%= ff.email_field :documents_copy_email_reply_to, class: 'base-input', dir: 'auto', placeholder: t(:email) %>
<% end %>
<%= t('attach_documents_to_the_email') %> <%= ff.check_box :documents_copy_email_attach_documents, { checked: ff.object.documents_copy_email_attach_documents != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['attach_documents'] == false }, 'true', 'false' %>
<%= t('attach_audit_log_pdf_to_the_email') %> <%= ff.check_box :documents_copy_email_attach_audit, { checked: ff.object.documents_copy_email_attach_audit != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['attach_audit_log'] == false }, 'true', 'false' %>
<%= t('send_emails_automatically_on_completion') %> <%= ff.check_box :documents_copy_email_enabled, { checked: ff.object.documents_copy_email_enabled != false && configs['enabled'] != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['enabled'] == false }, 'true', 'false' %>
<% end %>
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button' %>
<% end %>
<%= t('completed_notification_email') %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %> <% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_COMPLETED_EMAIL_KEY).value %> <%= f.fields_for :preferences, Struct.new(:completed_notification_email_subject, :completed_notification_email_body, :completed_notification_email_enabled, :completed_notification_email_attach_audit, :completed_notification_email_attach_documents).new(@template.preferences['completed_notification_email_subject'].presence || configs['subject'], @template.preferences['completed_notification_email_body'].presence || configs['body'], @template.preferences['completed_notification_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['completed_notification_email_attach_audit'] != false, configs['attach_documents'] != false && @template.preferences['completed_notification_email_attach_documents'] != false) do |ff| %>
<%= ff.label :completed_notification_email_subject, t('email_subject'), class: 'label' %> <%= ff.text_field :completed_notification_email_subject, required: true, class: 'base-input', dir: 'auto' %>
<%= ff.label :completed_notification_email_body, t('email_body'), class: 'label' %> <%= svg_icon('info_circle', class: 'w-4 h-4') %>
<%= ff.text_area :completed_notification_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
<%= t('attach_documents_to_the_email') %> <%= ff.check_box :completed_notification_email_attach_documents, { checked: ff.object.completed_notification_email_attach_documents != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['attach_documents'] == false }, 'true', 'false' %>
<%= t('attach_audit_log_pdf_to_the_email') %> <%= ff.check_box :completed_notification_email_attach_audit, { checked: ff.object.completed_notification_email_attach_audit != false, class: 'toggle', onchange: 'this.form.requestSubmit()', disabled: configs['attach_audit_log'] == false }, 'true', 'false' %>
<%= t('send_emails_automatically_on_completion') %> <%= ff.check_box :completed_notification_email_enabled, { checked: ff.object.completed_notification_email_enabled != false, class: 'toggle', onchange: 'this.form.requestSubmit()' }, 'true', 'false' %>
<% end %>
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button' %>
<% end %>
<% if show_recipients %> <% end %> <% if show_api %> <% end %> <% end %>