<%= 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, id: ff.field_id(:bcc_completed) %>
<% end %>
<%= f.button button_title(title: t('save'), disabled_with: t('updating')), class: 'base-button' %>
<% end %> <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mb-5' }, data: { close_on_submit: false } do |f| %> <%= f.fields_for :preferences, Struct.new(:default_expire_at_duration, :default_expire_at).new(@template.preferences['default_expire_at_duration'], @template.preferences['default_expire_at'] ? Time.zone.parse(@template.preferences['default_expire_at']).in_time_zone(current_account.timezone) : nil) do |ff| %>
<% duration_options = Templates::EXPIRATION_DURATIONS.keys.map { |duration| [t(duration), duration] } + [[t('specified_date'), 'specified_date']] %> <%= ff.label :default_expire_at_duration, t('default_expiration'), class: 'label pt-0' %>
<%= ff.select :default_expire_at_duration, duration_options, { include_blank: t('none') }, required: false, class: 'base-select flex-1', dir: 'auto', autocomplete: 'off' %> <%= ff.datetime_field :default_expire_at, required: false, class: ['base-input flex-1', ff.object.default_expire_at.blank? && 'hidden'].compact_blank.join(' '), dir: 'auto', autocomplete: 'off' %>
<% end %> <% end %>
<%= t('form_preferences') %>
<%= render 'templates_prefillable_fields/form', template: @template %> <%= 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') %>
<%= render 'templates_preferences/submitter_invitation_email_form' %>
<%= t('documents_copy_email') %>
<%= render 'templates_preferences/submitter_documents_copy_email_form' %>
<%= t('completed_notification_email') %>
<%= render 'templates_preferences/submitter_completed_email_form' %>
<%= render 'templates_code_modal/preferences', class: 'pt-2' %>
<% if show_recipients %> <% end %> <% if show_api %> <% end %> <% end %>