From 47c7270911c895f1e409ca9347d32201ead829e9 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 27 Mar 2025 18:29:02 +0200 Subject: [PATCH] enforce signing order --- app/controllers/account_configs_controller.rb | 1 + app/controllers/submit_form_controller.rb | 8 +++++--- app/models/account_config.rb | 1 + app/views/accounts/show.html.erb | 14 +++++++++++++ app/views/templates_preferences/show.html.erb | 20 ++++++++++--------- config/locales/i18n.yml | 6 ++++++ lib/submitters/form_configs.rb | 3 +++ 7 files changed, 41 insertions(+), 12 deletions(-) diff --git a/app/controllers/account_configs_controller.rb b/app/controllers/account_configs_controller.rb index 21c380a2..4146c130 100644 --- a/app/controllers/account_configs_controller.rb +++ b/app/controllers/account_configs_controller.rb @@ -15,6 +15,7 @@ class AccountConfigsController < ApplicationController AccountConfig::DOWNLOAD_LINKS_AUTH_KEY, AccountConfig::FORCE_SSO_AUTH_KEY, AccountConfig::FLATTEN_RESULT_PDF_KEY, + AccountConfig::ENFORCE_SIGNING_ORDER_KEY, AccountConfig::WITH_SIGNATURE_ID, AccountConfig::COMBINE_PDF_RESULT_KEY, AccountConfig::REQUIRE_SIGNING_REASON_KEY, diff --git a/app/controllers/submit_form_controller.rb b/app/controllers/submit_form_controller.rb index 90343331..057a3e6f 100644 --- a/app/controllers/submit_form_controller.rb +++ b/app/controllers/submit_form_controller.rb @@ -20,7 +20,11 @@ class SubmitFormController < ApplicationController @submitter.account.archived_at? return render :expired if submission.expired? return render :declined if @submitter.declined_at? - return render :awaiting if submission.template.preferences['submitters_order'] == 'preserved' && + + @form_configs = Submitters::FormConfigs.call(@submitter, CONFIG_KEYS) + + return render :awaiting if (@form_configs[:enforce_signing_order] || + submission.template.preferences['submitters_order'] == 'preserved') && !Submitters.current_submitter_order?(@submitter) Submitters.preload_with_pages(@submitter) @@ -29,8 +33,6 @@ class SubmitFormController < ApplicationController @attachments_index = build_attachments_index(submission) - @form_configs = Submitters::FormConfigs.call(@submitter, CONFIG_KEYS) - return unless @form_configs[:prefill_signature] if (user_signature = UserConfigs.load_signature(current_user)) diff --git a/app/models/account_config.rb b/app/models/account_config.rb index adda8091..d573ad0f 100644 --- a/app/models/account_config.rb +++ b/app/models/account_config.rb @@ -30,6 +30,7 @@ class AccountConfig < ApplicationRecord ALLOW_TO_RESUBMIT = 'allow_to_resubmit' ALLOW_TO_DECLINE_KEY = 'allow_to_decline' SUBMITTER_REMINDERS = 'submitter_reminders' + ENFORCE_SIGNING_ORDER_KEY = 'enforce_signing_order' FORM_COMPLETED_BUTTON_KEY = 'form_completed_button' FORM_COMPLETED_MESSAGE_KEY = 'form_completed_message' FORM_WITH_CONFETTI_KEY = 'form_with_confetti' diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index b8e945d5..7c6db5eb 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -151,6 +151,20 @@ <% end %> <% end %> + <% if !Docuseal.multitenant? || can?(:manage, :personalization_advanced) %> + <% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::ENFORCE_SIGNING_ORDER_KEY) %> + <% if can?(:manage, account_config) %> + <%= form_for account_config, url: account_configs_path, method: :post do |f| %> + <%= f.hidden_field :key %> +
+ + <%= t('always_enforce_signing_order') %> + + <%= f.check_box :value, class: 'toggle', checked: account_config.value, onchange: 'this.form.requestSubmit()' %> +
+ <% end %> + <% end %> + <% end %> <% end %> <%= render 'compliances' %> diff --git a/app/views/templates_preferences/show.html.erb b/app/views/templates_preferences/show.html.erb index db878d70..013e3918 100644 --- a/app/views/templates_preferences/show.html.erb +++ b/app/views/templates_preferences/show.html.erb @@ -322,15 +322,17 @@ <% end %> <% end %> - <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-2' }, data: { close_on_submit: false } do |f| %> -
- - <%= t('enforce_recipients_order') %> - - <%= 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 %> -
+ <% 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| %> +
+ + <%= t('enforce_recipients_order') %> + + <%= 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 %> +
+ <% end %> <% end %>
<%= button_tag button_title(title: t('save'), disabled_with: t('updating')), class: 'base-button', form: :submitters_form %> diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index 4a979547..3b5cf6db 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -21,6 +21,7 @@ en: &en hi_there: Hi there thanks: Thanks bcc_recipients: BCC recipients + always_enforce_signing_order: Always enforce the signing order edit_per_party: Edit per party reply_to: Reply to pending_by_me: Pending by me @@ -746,6 +747,7 @@ en: &en read: Read your data es: &es + always_enforce_signing_order: Siempre imponer el orden de firma bcc_recipients: Destinatarios CCO edit_per_party: Editar por parte signed: Firmado @@ -1474,6 +1476,7 @@ es: &es read: Leer tus datos it: &it + always_enforce_signing_order: Applicare sempre l'ordine di firma bcc_recipients: Destinatari BCC edit_per_party: Modifica per partito signed: Firmato @@ -2201,6 +2204,7 @@ it: &it read: Leggi i tuoi dati fr: &fr + always_enforce_signing_order: Toujours appliquer l'ordre de signature bcc_recipients: Destinataires en CCI edit_per_party: Éditer par partie signed: Signé @@ -2930,6 +2934,7 @@ fr: &fr read: Lire vos données pt: &pt + always_enforce_signing_order: Sempre impor a ordem de assinatura bcc_recipients: Destinatários BCC edit_per_party: Edita por festa signed: Assinado @@ -3658,6 +3663,7 @@ pt: &pt read: Ler seus dados de: &de + always_enforce_signing_order: Immer die Reihenfolge der Unterschriften erzwingen bcc_recipients: BCC-Empfänger edit_per_party: Bearbeiten pro Partei signed: Unterschrieben diff --git a/lib/submitters/form_configs.rb b/lib/submitters/form_configs.rb index 7b41afdf..ef4077e5 100644 --- a/lib/submitters/form_configs.rb +++ b/lib/submitters/form_configs.rb @@ -8,6 +8,7 @@ module Submitters AccountConfig::FORM_PREFILL_SIGNATURE_KEY, AccountConfig::WITH_SIGNATURE_ID, AccountConfig::ALLOW_TO_DECLINE_KEY, + AccountConfig::ENFORCE_SIGNING_ORDER_KEY, AccountConfig::REQUIRE_SIGNING_REASON_KEY, AccountConfig::REUSE_SIGNATURE_KEY, AccountConfig::ALLOW_TYPED_SIGNATURE, @@ -27,6 +28,7 @@ module Submitters with_decline = find_safe_value(configs, AccountConfig::ALLOW_TO_DECLINE_KEY) != false with_signature_id = find_safe_value(configs, AccountConfig::WITH_SIGNATURE_ID) == true require_signing_reason = find_safe_value(configs, AccountConfig::REQUIRE_SIGNING_REASON_KEY) == true + enforce_signing_order = find_safe_value(configs, AccountConfig::ENFORCE_SIGNING_ORDER_KEY) == true policy_links = find_safe_value(configs, AccountConfig::POLICY_LINKS_KEY) attrs = { @@ -36,6 +38,7 @@ module Submitters reuse_signature:, with_decline:, policy_links:, + enforce_signing_order:, completed_message:, require_signing_reason:, prefill_signature:,