Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-09-19 | MAIN --> PROD | DEV (baabe97) --> STAGING #4295

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion backend/audit/templates/audit/submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ <h1 class="font-sans-2xl" id="submission">Single Audit Submission</h1>
Please save copies of all submitted documents to your local drive. The FAC doesn't maintain these files, and can't return them for future review.
</p>
<div class="margin-top-6">
<button class="usa-button margin-right-2" id="continue">Submit Single Audit</button>
<div hidden id="loader" class="cross-validation-loader margin-top-6">
<img src="{% static 'img/loader.svg' %}" alt="spinner for processing upload" />
</div>
<button class="usa-button margin-right-2" id="continue" disable-submit-after-click>Submit Single Audit</button>
<a href="{% url 'audit:SubmissionProgress' report_id %}">Cancel</a>
</div>
</fieldset>
</form>
</div>
</div>
<script src="{% static 'compiled/js/util.js' %}"></script>
{% endblock content %}
30 changes: 30 additions & 0 deletions backend/static/js/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Attach an event handler to every button with attribute "disable-submit-after-click".
* This will disable the button after clicking it, enable the sibling spinning icon
* (if it exists), and submit the form.
*/
function disableSubmitAfterClick() {
const matching_buttons = document.querySelectorAll(
'button[disable-submit-after-click]'
);

matching_buttons.forEach((button) => {
const form = button.closest('form'); // Parent form
const loader = button.parentElement.querySelector(`div[id='loader']`); // Sibling loader

button.addEventListener('click', () => {
button.disabled = true;
button.textContent = 'Submitting...';
if (loader) {
loader.hidden = false;
}
form.submit();
});
});
}

function init() {
disableSubmitAfterClick();
}

window.onload = init;
Loading