diff --git a/src/registrar/assets/src/js/getgov/domain-dnssec.js b/src/registrar/assets/src/js/getgov/domain-dnssec.js new file mode 100644 index 000000000..860359fe0 --- /dev/null +++ b/src/registrar/assets/src/js/getgov/domain-dnssec.js @@ -0,0 +1,15 @@ +import { submitForm } from './helpers.js'; + +export function initDomainDNSSEC() { + document.addEventListener('DOMContentLoaded', function() { + let domain_dnssec_page = document.getElementById("domain-dnssec"); + if (domain_dnssec_page) { + const button = document.getElementById("disable-dnssec-button"); + if (button) { + button.addEventListener("click", function () { + submitForm("disable-dnssec-form"); + }); + } + } + }); +} \ No newline at end of file diff --git a/src/registrar/assets/src/js/getgov/domain-dsdata.js b/src/registrar/assets/src/js/getgov/domain-dsdata.js new file mode 100644 index 000000000..7c0871bec --- /dev/null +++ b/src/registrar/assets/src/js/getgov/domain-dsdata.js @@ -0,0 +1,27 @@ +import { submitForm } from './helpers.js'; + +export function initDomainDSData() { + document.addEventListener('DOMContentLoaded', function() { + let domain_dsdata_page = document.getElementById("domain-dsdata"); + if (domain_dsdata_page) { + const override_button = document.getElementById("disable-override-click-button"); + const cancel_button = document.getElementById("btn-cancel-click-button"); + const cancel_close_button = document.getElementById("btn-cancel-click-close-button"); + if (override_button) { + override_button.addEventListener("click", function () { + submitForm("disable-override-click-form"); + }); + } + if (cancel_button) { + cancel_button.addEventListener("click", function () { + submitForm("btn-cancel-click-form"); + }); + } + if (cancel_close_button) { + cancel_close_button.addEventListener("click", function () { + submitForm("btn-cancel-click-form"); + }); + } + } + }); +} \ No newline at end of file diff --git a/src/registrar/assets/src/js/getgov/domain-managers.js b/src/registrar/assets/src/js/getgov/domain-managers.js new file mode 100644 index 000000000..26eccd8cd --- /dev/null +++ b/src/registrar/assets/src/js/getgov/domain-managers.js @@ -0,0 +1,20 @@ +import { submitForm } from './helpers.js'; + +export function initDomainManagersPage() { + document.addEventListener('DOMContentLoaded', function() { + let domain_managers_page = document.getElementById("domain-managers"); + if (domain_managers_page) { + // Add event listeners for all buttons matching user-delete-button-{NUMBER} + const deleteButtons = document.querySelectorAll('[id^="user-delete-button-"]'); // Select buttons with ID starting with "user-delete-button-" + deleteButtons.forEach((button) => { + const buttonId = button.id; // e.g., "user-delete-button-1" + const number = buttonId.split('-').pop(); // Extract the NUMBER part + const formId = `user-delete-form-${number}`; // Generate the corresponding form ID + + button.addEventListener("click", function () { + submitForm(formId); // Pass the form ID to submitForm + }); + }); + } + }); +} \ No newline at end of file diff --git a/src/registrar/assets/src/js/getgov/domain-request-form.js b/src/registrar/assets/src/js/getgov/domain-request-form.js new file mode 100644 index 000000000..d9b660a50 --- /dev/null +++ b/src/registrar/assets/src/js/getgov/domain-request-form.js @@ -0,0 +1,12 @@ +import { submitForm } from './helpers.js'; + +export function initDomainRequestForm() { + document.addEventListener('DOMContentLoaded', function() { + const button = document.getElementById("domain-request-form-submit-button"); + if (button) { + button.addEventListener("click", function () { + submitForm("submit-domain-request-form"); + }); + } + }); +} \ No newline at end of file diff --git a/src/registrar/assets/src/js/getgov/form-errors.js b/src/registrar/assets/src/js/getgov/form-errors.js new file mode 100644 index 000000000..ec1faaccf --- /dev/null +++ b/src/registrar/assets/src/js/getgov/form-errors.js @@ -0,0 +1,19 @@ +export function initFormErrorHandling() { + document.addEventListener('DOMContentLoaded', function() { + const errorSummary = document.getElementById('form-errors'); + const firstErrorField = document.querySelector('.usa-input--error'); + if (firstErrorField) { + // Scroll to the first field in error + firstErrorField.scrollIntoView({ behavior: 'smooth', block: 'center' }); + + // Add focus to the first field in error + setTimeout(() => { + firstErrorField.focus(); + }, 50); + } else if (errorSummary) { + // Scroll to the error summary + errorSummary.scrollIntoView({ behavior: 'smooth', block: 'center' }); + } + + }); +} \ No newline at end of file diff --git a/src/registrar/assets/src/js/getgov/helpers.js b/src/registrar/assets/src/js/getgov/helpers.js index 1afd84520..93c25ee45 100644 --- a/src/registrar/assets/src/js/getgov/helpers.js +++ b/src/registrar/assets/src/js/getgov/helpers.js @@ -75,3 +75,16 @@ export function debounce(handler, cooldown=600) { export function getCsrfToken() { return document.querySelector('input[name="csrfmiddlewaretoken"]').value; } + +/** + * Helper function to submit a form + * @param {} form_id - the id of the form to be submitted + */ +export function submitForm(form_id) { + let form = document.getElementById(form_id); + if (form) { + form.submit(); + } else { + console.error("Form '" + form_id + "' not found."); + } +} diff --git a/src/registrar/assets/src/js/getgov/main.js b/src/registrar/assets/src/js/getgov/main.js index f5ebc83a3..6ff402aa4 100644 --- a/src/registrar/assets/src/js/getgov/main.js +++ b/src/registrar/assets/src/js/getgov/main.js @@ -11,6 +11,11 @@ import { initMembersTable } from './table-members.js'; import { initMemberDomainsTable } from './table-member-domains.js'; import { initEditMemberDomainsTable } from './table-edit-member-domains.js'; import { initPortfolioNewMemberPageToggle, initAddNewMemberPageListeners, initPortfolioMemberPageRadio } from './portfolio-member-page.js'; +import { initDomainRequestForm } from './domain-request-form.js'; +import { initDomainManagersPage } from './domain-managers.js'; +import { initDomainDSData } from './domain-dsdata.js'; +import { initDomainDNSSEC } from './domain-dnssec.js'; +import { initFormErrorHandling } from './form-errors.js'; initDomainValidators(); @@ -36,6 +41,13 @@ initMembersTable(); initMemberDomainsTable(); initEditMemberDomainsTable(); +initDomainRequestForm(); +initDomainManagersPage(); +initDomainDSData(); +initDomainDNSSEC(); + +initFormErrorHandling(); + // Init the portfolio new member page initPortfolioMemberPageRadio(); initPortfolioNewMemberPageToggle(); diff --git a/src/registrar/assets/src/js/getgov/table-base.js b/src/registrar/assets/src/js/getgov/table-base.js index e526c6b5f..97c256734 100644 --- a/src/registrar/assets/src/js/getgov/table-base.js +++ b/src/registrar/assets/src/js/getgov/table-base.js @@ -495,7 +495,8 @@ export class BaseTable { // Add event listeners to table headers for sorting initializeTableHeaders() { this.tableHeaders.forEach(header => { - header.addEventListener('click', () => { + header.addEventListener('click', event => { + let button = header.querySelector('.usa-table__header__button') const sortBy = header.getAttribute('data-sortable'); let order = 'asc'; // sort order will be ascending, unless the currently sorted column is ascending, and the user @@ -505,6 +506,13 @@ export class BaseTable { } // load the results with the updated sort this.loadTable(1, sortBy, order); + // If the click occurs outside of the button, need to simulate a button click in order + // for USWDS listener on the button to execute. + // Check first to see if click occurs outside of the button + if (!button.contains(event.target)) { + // Simulate a button click + button.click(); + } }); }); } diff --git a/src/registrar/assets/src/sass/_theme/_tables.scss b/src/registrar/assets/src/sass/_theme/_tables.scss index 45f0b5245..ea160396e 100644 --- a/src/registrar/assets/src/sass/_theme/_tables.scss +++ b/src/registrar/assets/src/sass/_theme/_tables.scss @@ -88,8 +88,14 @@ th { } @include at-media(tablet-lg) { - th[data-sortable]:not([aria-sort]) .usa-table__header__button { + th[data-sortable] .usa-table__header__button { right: auto; + + &[aria-sort=ascending], + &[aria-sort=descending], + &:not([aria-sort]) { + right: auto; + } } } } diff --git a/src/registrar/templates/domain_add_user.html b/src/registrar/templates/domain_add_user.html index 1429127e6..b09f1f814 100644 --- a/src/registrar/templates/domain_add_user.html +++ b/src/registrar/templates/domain_add_user.html @@ -37,6 +37,9 @@ {% endif %} {% endblock breadcrumb %} + + {% include "includes/form_errors.html" with form=form %} +
diff --git a/src/registrar/templates/domain_dnssec.html b/src/registrar/templates/domain_dnssec.html index cfec053c2..a795fb2fc 100644 --- a/src/registrar/templates/domain_dnssec.html +++ b/src/registrar/templates/domain_dnssec.html @@ -27,7 +27,7 @@ {% endif %} {% endblock breadcrumb %} -
DNSSEC, or DNS Security Extensions, is an additional security layer to protect your website. Enabling DNSSEC ensures that when someone visits your domain, they can be certain that it’s connecting to the correct server, preventing potential hijacking or tampering with your domain's records.
@@ -78,7 +78,11 @@In order to enable DNSSEC, you must first configure it with your DNS hosting service.
@@ -141,7 +141,15 @@