diff --git a/app/controllers/submit_form_controller.rb b/app/controllers/submit_form_controller.rb index 0cfebae3..621849eb 100644 --- a/app/controllers/submit_form_controller.rb +++ b/app/controllers/submit_form_controller.rb @@ -12,16 +12,20 @@ class SubmitFormController < ApplicationController def show @submitter = Submitter.find_by!(slug: params[:slug]) + submission = @submitter.submission + return redirect_to submit_form_completed_path(@submitter.slug) if @submitter.completed_at? - return render :archived if @submitter.submission.template.archived_at? || @submitter.submission.archived_at? - return render :expired if @submitter.submission.expired? + return render :archived if submission.template.archived_at? || submission.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' && + !Submitters.current_submitter_order?(@submitter) Submitters.preload_with_pages(@submitter) Submitters::MaybeUpdateDefaultValues.call(@submitter, current_user) - @attachments_index = ActiveStorage::Attachment.where(record: @submitter.submission.submitters, name: :attachments) + @attachments_index = ActiveStorage::Attachment.where(record: submission.submitters, name: :attachments) .preload(:blob).index_by(&:uuid) @form_configs = Submitters::FormConfigs.call(@submitter, CONFIG_KEYS) diff --git a/app/views/submit_form/awaiting.html.erb b/app/views/submit_form/awaiting.html.erb new file mode 100644 index 00000000..a1205824 --- /dev/null +++ b/app/views/submit_form/awaiting.html.erb @@ -0,0 +1,21 @@ +
+
+
+
+ <%= render 'start_form/banner' %> +
+
+
+
+ <%= svg_icon('writing_sign', class: 'w-10 h-10') %> +
+
+

<%= @submitter.submission.template.name %>

+

<%= t('awaiting_completion_by_the_other_party') %>

+
+
+
+
+
+
+<%= render 'shared/attribution', link_path: '/start', account: @submitter.account %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 2ef4b3af..cf6ea5a7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -24,6 +24,7 @@ en: &en you_have_been_invited_to_sign_the_name: 'You have been invited to sign the "%{name}".' alternatively_you_can_review_and_download_your_copy_using_the_link_below: "Alternatively, you can review and download your copy using the link below:" please_check_the_copy_of_your_name_in_the_email_attachments: 'Please check the copy of your "%{name}" in the email attachments.' + awaiting_completion_by_the_other_party: "Awaiting completion by the other party" review_and_sign: Review and Sign review_and_submit: Review and Submit please_contact_us_by_replying_to_this_email_if_you_didn_t_request_this: "Please contact us by replying to this email if you have any questions." diff --git a/lib/submitters.rb b/lib/submitters.rb index b3cc10a4..18b2d151 100644 --- a/lib/submitters.rb +++ b/lib/submitters.rb @@ -102,4 +102,14 @@ module Submitters SendSubmitterInvitationEmailJob.perform_async('submitter_id' => submitter.id) end end + + def current_submitter_order?(submitter) + submitter_items = submitter.submission.template_submitters || submitter.submission.template.submitters + + before_items = submitter_items[0...(submitter_items.find_index { |e| e['uuid'] == submitter.uuid })] + + before_items.reduce(true) do |acc, item| + acc && submitter.submission.submitters.find { |e| e.uuid == item['uuid'] }&.completed_at? + end + end end