diff --git a/app/assets/javascripts/preventDuplicateFormSubmissions.js b/app/assets/javascripts/preventDuplicateFormSubmissions.js index 61e2e6890..e3221d9d2 100644 --- a/app/assets/javascripts/preventDuplicateFormSubmissions.js +++ b/app/assets/javascripts/preventDuplicateFormSubmissions.js @@ -13,16 +13,23 @@ } else { $submitButton.data('clicked', 'true'); - setTimeout(renableSubmitButton($submitButton), 1500); + if ($submitButton.is('[name="Send"], [name="Schedule"]')) { + $submitButton.prop('disabled', true); + + setTimeout(() => { + renableSubmitButton($submitButton); + }, 10000); + } else { + setTimeout(renableSubmitButton($submitButton), 1500); + } } - }; let renableSubmitButton = $submitButton => () => { $submitButton.data('clicked', ''); - + $submitButton.prop('disabled', false); }; $('form').on('submit', disableSubmitButtons); diff --git a/app/main/views/send.py b/app/main/views/send.py index 194ee55ef..54f5eb098 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -924,6 +924,10 @@ def get_template_error_dict(exception): def preview_notification(service_id, template_id): recipient = get_recipient() if not recipient: + current_app.logger.warning( + f"No recipient found for service {service_id}, template {template_id}. Redirecting..." + ) + return redirect( url_for( ".send_one_off", diff --git a/app/templates/components/components/button/template.njk b/app/templates/components/components/button/template.njk index dc81ebf11..01bc649ac 100644 --- a/app/templates/components/components/button/template.njk +++ b/app/templates/components/components/button/template.njk @@ -16,7 +16,7 @@ {#- Define common attributes we can use for both button and input types #} -{%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %} +{%- set buttonAttributes %}{% if params.name %} name="{{ params.name | trim }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %} {#- Actually create a button... or a link! #} diff --git a/app/templates/views/check/preview.html b/app/templates/views/check/preview.html index 6e0122499..091ba345f 100644 --- a/app/templates/views/check/preview.html +++ b/app/templates/views/check/preview.html @@ -101,6 +101,9 @@ {% set button_text %} {{ "Schedule" if scheduled_for else 'Send'}} {% endset %} - {{ usaButton({ "text": button_text }) }} + {{ usaButton({ + "text": button_text, + "name": button_text + }) }} {% endblock %} diff --git a/app/templates/views/notifications/preview.html b/app/templates/views/notifications/preview.html index d0be74aed..536288d9a 100644 --- a/app/templates/views/notifications/preview.html +++ b/app/templates/views/notifications/preview.html @@ -43,7 +43,6 @@ {% endcall %} {% elif error == 'message-too-long' %} - {# the only row_errors we can get when sending one off messages is that the message is too long #}
{% call banner_wrapper(type='dangerous') %} {% include "partials/check/message-too-long.html" %} @@ -77,13 +76,15 @@ help='3' if help else 0 )}}" class='page-footer'> -

Does everything look good?

{% if not error %} {% set button_text %} {{ "Schedule" if scheduled_for else 'Send'}} {% endset %} - {{ usaButton({ "text": button_text }) }} + {{ usaButton({ + "text": button_text, + "name": button_text + }) }} {% endif %}