From f9ae79dd5b173f98e4770f9f6ff6faca1d302b73 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 13 Apr 2024 15:33:05 +0300 Subject: [PATCH] add go to last --- app/controllers/api/submissions_controller.rb | 4 ++-- app/controllers/api/submitters_controller.rb | 5 ++++- app/views/submit_form/_submission_form.html.erb | 2 +- lib/submitters.rb | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/submissions_controller.rb b/app/controllers/api/submissions_controller.rb index 1e032fda5..af42a6ddf 100644 --- a/app/controllers/api/submissions_controller.rb +++ b/app/controllers/api/submissions_controller.rb @@ -165,11 +165,11 @@ def serialize_params def submissions_params permitted_attrs = [ - :send_email, :send_sms, :bcc_completed, :completed_redirect_url, :reply_to, + :send_email, :send_sms, :bcc_completed, :completed_redirect_url, :reply_to, :go_to_last, { message: %i[subject body], submitters: [[:send_email, :send_sms, :completed_redirect_url, :uuid, :name, :email, :role, - :completed, :phone, :application_key, :external_id, :reply_to, + :completed, :phone, :application_key, :external_id, :reply_to, :go_to_last, { metadata: {}, values: {}, readonly_fields: [], message: %i[subject body], fields: [:name, :uuid, :default_value, :title, :description, :readonly, :redacted, :validation_pattern, :invalid_message, diff --git a/app/controllers/api/submitters_controller.rb b/app/controllers/api/submitters_controller.rb index d36ee0515..baff08281 100644 --- a/app/controllers/api/submitters_controller.rb +++ b/app/controllers/api/submitters_controller.rb @@ -74,7 +74,7 @@ def submitter_params submitter_params.permit( :send_email, :send_sms, :reply_to, :completed_redirect_url, :uuid, :name, :email, :role, - :completed, :phone, :application_key, :external_id, + :completed, :phone, :application_key, :external_id, :go_to_last, { metadata: {}, values: {}, readonly_fields: [], message: %i[subject body], fields: [[:name, :uuid, :default_value, :readonly, :redacted, :validation_pattern, :invalid_message, { default_value: [] }]] } @@ -126,6 +126,9 @@ def assign_preferences(submitter, attrs) submitter.preferences['send_sms'] = submitter_preferences['send_sms'] if submitter_preferences.key?('send_sms') submitter.preferences['reply_to'] = submitter_preferences['reply_to'] if submitter_preferences.key?('reply_to') + if submitter_preferences.key?('go_to_last') + submitter.preferences['go_to_last'] = submitter_preferences['go_to_last'] + end if submitter_preferences.key?('completed_redirect_url') submitter.preferences['completed_redirect_url'] = submitter_preferences['completed_redirect_url'] diff --git a/app/views/submit_form/_submission_form.html.erb b/app/views/submit_form/_submission_form.html.erb index b3ee13c76..9e0ecb632 100644 --- a/app/views/submit_form/_submission_form.html.erb +++ b/app/views/submit_form/_submission_form.html.erb @@ -1,4 +1,4 @@ <% data_attachments = attachments_index.values.select { |e| e.record_id == submitter.id }.to_json(only: %i[uuid], methods: %i[url filename content_type]) %> <% data_fields = (submitter.submission.template_fields || submitter.submission.template.fields).select { |f| f['submitter_uuid'] == submitter.uuid }.to_json %> <% configs = Submitters::FormConfigs.call(submitter) %> - + diff --git a/lib/submitters.rb b/lib/submitters.rb index 0ed1d77a3..2be8b6d5e 100644 --- a/lib/submitters.rb +++ b/lib/submitters.rb @@ -62,6 +62,7 @@ def normalize_preferences(account, user, params) preferences['send_sms'] = params['send_sms'].in?(TRUE_VALUES) if params.key?('send_sms') preferences['bcc_completed'] = params['bcc_completed'] if params.key?('bcc_completed') preferences['reply_to'] = params['reply_to'] if params.key?('reply_to') + preferences['go_to_last'] = params['go_to_last'] if params.key?('go_to_last') preferences['completed_redirect_url'] = params['completed_redirect_url'] if params.key?('completed_redirect_url') preferences