diff --git a/app/controllers/account_configs_controller.rb b/app/controllers/account_configs_controller.rb index 87baf04c..5d33a547 100644 --- a/app/controllers/account_configs_controller.rb +++ b/app/controllers/account_configs_controller.rb @@ -7,6 +7,7 @@ class AccountConfigsController < ApplicationController ALLOWED_KEYS = [ AccountConfig::ALLOW_TYPED_SIGNATURE, AccountConfig::FORCE_MFA, + AccountConfig::ALLOW_TO_RESUBMIT, AccountConfig::ESIGNING_PREFERENCE_KEY ].freeze diff --git a/app/models/account_config.rb b/app/models/account_config.rb index fdbaa1b9..c0b3b24c 100644 --- a/app/models/account_config.rb +++ b/app/models/account_config.rb @@ -27,6 +27,7 @@ class AccountConfig < ApplicationRecord BCC_EMAILS = 'bcc_emails' FORCE_MFA = 'force_mfa' ALLOW_TYPED_SIGNATURE = 'allow_typed_signature' + ALLOW_TO_RESUBMIT = 'allow_to_resubmit' SUBMITTER_REMAILERS = 'submitter_reminders' FORM_COMPLETED_BUTTON_KEY = 'form_completed_button' FORM_WITH_CONFETTI_KEY = 'form_with_confetti' diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index 5d3916a9..b6f8a7cb 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -63,6 +63,18 @@ <% end %> <% end %> + <% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::ALLOW_TO_RESUBMIT) %> + <% if can?(:manage, account_config) %> + <%= form_for account_config, url: account_configs_path, method: :post do |f| %> + <%= f.hidden_field :key %> +
+ + Allow to resubmit completed forms + + <%= f.check_box :value, class: 'toggle', checked: account_config.value != false, onchange: 'this.form.requestSubmit()' %> +
+ <% end %> + <% end %> <% end %> <% if can?(:manage, current_account) && Docuseal.multitenant? && true_user == current_user %> diff --git a/app/views/start_form/completed.html.erb b/app/views/start_form/completed.html.erb index e78bc48f..71750f6f 100644 --- a/app/views/start_form/completed.html.erb +++ b/app/views/start_form/completed.html.erb @@ -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 }, form: { onsubmit: 'event.submitter.disabled = true' }, class: 'base-button w-full' %> <% end %> - <% if @template.submitters.to_a.size == 1 %> + <% 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 %>
<%= 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, form: { onsubmit: 'event.submitter.disabled = true' }, class: 'white-button w-full' %>
diff --git a/app/views/submit_form/completed.html.erb b/app/views/submit_form/completed.html.erb index 36149480..00167f64 100644 --- a/app/views/submit_form/completed.html.erb +++ b/app/views/submit_form/completed.html.erb @@ -36,7 +36,7 @@ - <% if @submitter.submission.template.submitters.size == 1 && %w[api embed].exclude?(@submitter.submission.source) %> + <% 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 %>
<%= t('or') %>
<%= 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, form: { onsubmit: 'event.submitter.disabled = true' }, class: 'white-button w-full' %>