From 1999611b261951e8ba87f825b950b9f8aa19fff0 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 19 Sep 2026 11:40:48 +0300 Subject: [PATCH] fix share modal --- app/javascript/elements/toggle_on_submit.js | 16 +++++----------- app/views/templates_share_link/show.html.erb | 10 +++++----- 2 files changed, 10 insertions(+), 16 deletions(-) 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| %> -