From 99b33d4165c35473692ce446dbccf3fc32e6c8ec Mon Sep 17 00:00:00 2001 From: DocuSeal Date: Fri, 20 Oct 2023 22:55:25 +0300 Subject: [PATCH] allow to resubmit form via shared link --- app/controllers/start_form_controller.rb | 8 ++++++-- app/views/icons/_reload.html.erb | 5 +++++ app/views/start_form/completed.html.erb | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 app/views/icons/_reload.html.erb diff --git a/app/controllers/start_form_controller.rb b/app/controllers/start_form_controller.rb index 3ec5ad0f..75e4d0be 100644 --- a/app/controllers/start_form_controller.rb +++ b/app/controllers/start_form_controller.rb @@ -13,8 +13,12 @@ class StartFormController < ApplicationController end def update - @submitter = Submitter.where(submission: @template.submissions.where(deleted_at: nil)) - .find_or_initialize_by(email: submitter_params[:email]) + @submitter = Submitter.new(email: submitter_params[:email]) + + if params[:resubmit].blank? + @submitter = Submitter.where(submission: @template.submissions.where(deleted_at: nil)) + .find_by(email: submitter_params[:email]) || @submitter + end if @submitter.completed_at? redirect_to start_form_completed_path(@template.slug, email: submitter_params[:email]) diff --git a/app/views/icons/_reload.html.erb b/app/views/icons/_reload.html.erb new file mode 100644 index 00000000..f7848edd --- /dev/null +++ b/app/views/icons/_reload.html.erb @@ -0,0 +1,5 @@ + + + + + diff --git a/app/views/start_form/completed.html.erb b/app/views/start_form/completed.html.erb index 3ebc7daa..90537c20 100644 --- a/app/views/start_form/completed.html.erb +++ b/app/views/start_form/completed.html.erb @@ -24,6 +24,9 @@ <%= button_to button_title(title: 'Send copy to Email', disabled_with: '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 %> +
+ <%= button_to button_title(title: 'Resubmit', disabled_with: 'Resubmit', icon: svg_icon('reload', class: 'w-6 h-6')), start_form_path(@template.slug), params: { submitter: { email: params[:email] }, resubmit: true }, method: :put, form: { onsubmit: 'event.submitter.disabled = true' }, class: 'white-button w-full' %> +
<%= render 'shared/attribution', link_path: '/start' %>