add submitter completed redirect url

pull/217/head
Pete Matsyburka 2 years ago
parent 2edc76414b
commit d0ba180729

@ -142,9 +142,9 @@ module Api
params.permit(
key => [
[:send_email, :send_sms, :bcc_completed, {
[:send_email, :send_sms, :bcc_completed, :completed_redirect_url, {
message: %i[subject body],
submitters: [[:send_email, :send_sms, :uuid, :name, :email, :role,
submitters: [[:send_email, :send_sms, :completed_redirect_url, :uuid, :name, :email, :role,
:completed, :phone, :application_key,
{ values: {}, readonly_fields: [], message: %i[subject body],
fields: [%i[name default_value title description

@ -3,7 +3,7 @@
class SubmitFormController < ApplicationController
layout 'form'
around_action :with_browser_locale, only: %i[show completed]
around_action :with_browser_locale, only: %i[show completed success]
skip_before_action :authenticate_user!
skip_authorization_check
@ -59,4 +59,6 @@ class SubmitFormController < ApplicationController
def completed
@submitter = Submitter.find_by!(slug: params[:submit_form_slug])
end
def success; end
end

@ -19,6 +19,7 @@ window.customElements.define('submission-form', class extends HTMLElement {
withTypedSignature: this.dataset.withTypedSignature !== 'false',
values: reactive(JSON.parse(this.dataset.values)),
completedButton: JSON.parse(this.dataset.completedButton),
completedRedirectUrl: this.dataset.completedRedirectUrl,
attachments: reactive(JSON.parse(this.dataset.attachments)),
fields: JSON.parse(this.dataset.fields)
})

@ -332,9 +332,9 @@
v-else
:is-demo="isDemo"
:attribution="attribution"
:completed-button="completedButton"
:with-send-copy-button="withSendCopyButton"
:with-download-button="withDownloadButton"
:completed-button="completedRedirectUrl ? {} : completedButton"
:with-send-copy-button="withSendCopyButton && !completedRedirectUrl"
:with-download-button="withDownloadButton && !completedRedirectUrl"
:with-confetti="withConfetti"
:can-send-email="canSendEmail && !!submitter.email"
:submitter-slug="submitterSlug"
@ -496,6 +496,11 @@ export default {
required: false,
default: true
},
completedRedirectUrl: {
type: String,
required: false,
default: ''
},
completedButton: {
type: Object,
required: false,
@ -784,6 +789,10 @@ export default {
if (respData) {
this.onComplete(JSON.parse(respData))
}
if (this.completedRedirectUrl) {
window.location.href = this.completedRedirectUrl
}
}
}).catch(error => {
console.error(error)

@ -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) %>
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.opened_at? %>" data-is-direct-upload="<%= Docuseal.active_storage_public? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Accounts.can_send_emails?(Struct.new(:id).new(@submitter.submission.template.account_id)) %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>"></submission-form>
<submission-form data-is-demo="<%= Docuseal.demo? %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'] %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.opened_at? %>" data-is-direct-upload="<%= Docuseal.active_storage_public? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Accounts.can_send_emails?(Struct.new(:id).new(@submitter.submission.template.account_id)) %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>"></submission-form>

@ -0,0 +1,20 @@
<div class="max-w-md mx-auto px-2 mt-12 mb-4">
<div class="space-y-6 mx-auto">
<div class="space-y-6">
<div class="flex items-center justify-center">
<%= render 'start_form/banner' %>
</div>
<div class="flex items-center p-2 mb-4 justify-center">
<div class="flex items-center">
<div class="mr-3">
<%= svg_icon('circle_check', class: 'w-10 h-10 text-green-600') %>
</div>
<div class="text-2xl">
<%= t('completed_successfully') %>
</div>
</div>
</div>
</div>
</div>
</div>
<%= render 'shared/attribution', link_path: '/start' %>

@ -17,6 +17,7 @@ en: &en
or: or
download_documents: Download documents
downloading: Downloading
completed_successfully: Completed Successfully
es: &es
digitally_signed_by: Firmado digitalmente por
@ -38,6 +39,7 @@ es: &es
or: o
download_documents: Descargar documentos
downloading: Descargando
completed_successfully: Completado exitosamente
it:
digitally_signed_by: Signé numériquement par
@ -59,6 +61,7 @@ it:
or: o
download_documents: Scarica documenti
downloading: Scaricamento
completed_successfully: Completato con successo
fr: &fr
email: Email
@ -78,6 +81,7 @@ fr: &fr
or: ou
download_documents: Télécharger des documents
downloading: Téléchargement
completed_successfully: Terminé avec succès
pt: &pt
digitally_signed_by: Assinado digitalmente por
@ -99,6 +103,7 @@ pt: &pt
or: ou
download_documents: Baixar documentos
downloading: Baixando
completed_successfully: Concluído com sucesso
de: &de
digitally_signed_by: Digital signiert von
@ -120,6 +125,7 @@ de: &de
or: oder
download_documents: Dokumente herunterladen
downloading: Herunterladen
completed_successfully: Erfolgreich abgeschlossen
pl:
email: Email
@ -139,6 +145,7 @@ pl:
or: lub
download_documents: Pobierz dokumenty
downloading: Pobieranie
completed_successfully: Zakończono pomyślnie
uk:
email: Email
@ -158,6 +165,7 @@ uk:
or: або
download_documents: Завантажити документи
downloading: Завантаження
completed_successfully: Успішно завершено
cs:
email: Email
@ -177,6 +185,7 @@ cs:
or: nebo
download_documents: Stáhnout dokumenty
downloading: Stahování
completed_successfully: Úspěšně dokončeno
he:
email: דוא"ל
@ -196,6 +205,7 @@ he:
or: או
download_documents: הורד מסמכים
downloading: מוריד
completed_successfully: הושלם בהצלחה
en-US:
<<: *en

@ -81,6 +81,10 @@ Rails.application.routes.draw do
get :completed
end
resources :submit_form, only: %i[], path: '' do
get :success, on: :collection
end
resources :submit_form, only: %i[show update], path: 's', param: 'slug' do
get :completed
end

@ -60,6 +60,7 @@ module Submitters
preferences['send_email'] = params['send_email'].in?(TRUE_VALUES) if params.key?('send_email')
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['completed_redirect_url'] = params['completed_redirect_url'] if params.key?('completed_redirect_url')
preferences
end

Loading…
Cancel
Save