diff --git a/app/javascript/elements/toggle_on_submit.js b/app/javascript/elements/toggle_on_submit.js
index 8cbc213f9..f14fe4648 100644
--- a/app/javascript/elements/toggle_on_submit.js
+++ b/app/javascript/elements/toggle_on_submit.js
@@ -1,27 +1,21 @@
export default class extends HTMLElement {
connectedCallback () {
- document.addEventListener('turbo:submit-end', this.onSubmitEnd)
-
this.form.addEventListener('submit', this.onSubmit)
+ this.form.addEventListener('turbo:before-fetch-response', this.onFetchResponse)
}
disconnectedCallback () {
- document.removeEventListener('turbo:submit-end', this.onSubmitEnd)
-
this.form.removeEventListener('submit', this.onSubmit)
+ this.form.removeEventListener('turbo:before-fetch-response', this.onFetchResponse)
}
onSubmit = () => {
this.element.classList.add('invisible')
}
- onSubmitEnd = (event) => {
- if (event.target === this.form) {
- const resp = event.detail?.formSubmission?.result?.fetchResponse?.response
-
- if (resp?.status / 100 === 2) {
- this.element.classList.remove('invisible')
- }
+ onFetchResponse = (event) => {
+ if (event.detail.fetchResponse.succeeded) {
+ this.element.classList.remove('invisible')
}
}
diff --git a/app/views/templates_share_link/show.html.erb b/app/views/templates_share_link/show.html.erb
index fd45fef69..c16c6572e 100644
--- a/app/views/templates_share_link/show.html.erb
+++ b/app/views/templates_share_link/show.html.erb
@@ -3,19 +3,19 @@
<%= render 'shared/turbo_modal_large', title: t('share_link') do %>
<% if @template.variables_schema.present? %>
-
+
<%= svg_icon('info_circle', class: 'stroke-current shrink-0 h-6 w-6') %>
<%= t('dynamic_template_with_variables_cannot_be_used_via_shared_link') %>
<% end %>
<%= form_for @template, url: template_share_link_path(@template), method: :post, html: { id: 'shared_link_form', autocomplete: 'off', class: 'mt-3' }, data: { close_on_submit: false } do |f| %>
<% if @template.preferences&.dig('require_email_2fa') || @template.preferences&.dig('require_phone_2fa') %>
-
<% end %>
<% if multiple_submitters && !enough_defined_submitters && @template.variables_schema.blank? %>
-
+
<%= svg_icon('info_circle', class: 'stroke-current shrink-0 h-6 w-6 mt-1') %>
<%= t('this_template_has_multiple_parties_which_prevents_the_use_of_a_sharing_link') %>
@@ -86,7 +86,7 @@
<% if Docuseal.multitenant? || Accounts.can_send_emails?(current_account) %>
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-4' }, data: { close_on_submit: false } do |f| %>
<%= f.fields_for :preferences, Struct.new(:shared_link_2fa).new(@template.preferences['shared_link_2fa'] == true) do |ff| %>
-
+
<%= t('request_email_otp_verification_with_shared_link') %>
<%= ff.check_box :shared_link_2fa, { checked: ff.object.shared_link_2fa == true, disabled: !can?(:update, @template), class: 'toggle' }, 'true', 'false' %>