mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 06:24:12 +02:00
cleanup
This commit is contained in:
parent
0572969d23
commit
0bbb227b71
4 changed files with 28 additions and 31 deletions
|
@ -17,6 +17,22 @@ var SUCCESS = "success";
|
||||||
// <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
|
// <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
|
||||||
// Helper functions.
|
// Helper functions.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide element
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const hideElement = (element) => {
|
||||||
|
element.classList.add('display-none');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show element
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const showElement = (element) => {
|
||||||
|
element.classList.remove('display-none');
|
||||||
|
};
|
||||||
|
|
||||||
/** Makes an element invisible. */
|
/** Makes an element invisible. */
|
||||||
function makeHidden(el) {
|
function makeHidden(el) {
|
||||||
el.style.position = "absolute";
|
el.style.position = "absolute";
|
||||||
|
@ -1019,22 +1035,6 @@ function updatePagination(itemName, paginationSelector, counterSelector, headerA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hide element
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const hideElement = (element) => {
|
|
||||||
element.classList.add('display-none');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show element
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const showElement = (element) => {
|
|
||||||
element.classList.remove('display-none');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper that toggles content/ no content/ no search results
|
* A helper that toggles content/ no content/ no search results
|
||||||
*
|
*
|
||||||
|
@ -1071,7 +1071,7 @@ const updateDisplay = (data, dataWrapper, noDataWrapper, noSearchResultsWrapper,
|
||||||
const unsetHeader = (header) => {
|
const unsetHeader = (header) => {
|
||||||
header.removeAttribute('aria-sort');
|
header.removeAttribute('aria-sort');
|
||||||
let headerName = header.innerText;
|
let headerName = header.innerText;
|
||||||
const headerLabel = `${headerName}', sortable column, currently unsorted"`;
|
const headerLabel = `${headerName}, sortable column, currently unsorted"`;
|
||||||
const headerButtonLabel = `Click to sort by ascending order.`;
|
const headerButtonLabel = `Click to sort by ascending order.`;
|
||||||
header.setAttribute("aria-label", headerLabel);
|
header.setAttribute("aria-label", headerLabel);
|
||||||
header.querySelector('.usa-table__header__button').setAttribute("title", headerButtonLabel);
|
header.querySelector('.usa-table__header__button').setAttribute("title", headerButtonLabel);
|
||||||
|
@ -1219,11 +1219,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
hideElement(resetButton);
|
hideElement(resetButton);
|
||||||
}
|
}
|
||||||
loadDomains(1, 'id', 'asc');
|
loadDomains(1, 'id', 'asc');
|
||||||
resetheaders();
|
resetHeaders();
|
||||||
})
|
})
|
||||||
|
|
||||||
// Reset UI and accessibility
|
// Reset UI and accessibility
|
||||||
function resetheaders() {
|
function resetHeaders() {
|
||||||
tableHeaders.forEach(header => {
|
tableHeaders.forEach(header => {
|
||||||
// Unset sort UI in headers
|
// Unset sort UI in headers
|
||||||
unsetHeader(header);
|
unsetHeader(header);
|
||||||
|
@ -1237,7 +1237,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
currentSearchTerm = '';
|
currentSearchTerm = '';
|
||||||
hideElement(resetButton);
|
hideElement(resetButton);
|
||||||
loadDomains(1, 'id', 'asc', hasLoaded, '');
|
loadDomains(1, 'id', 'asc', hasLoaded, '');
|
||||||
resetheaders();
|
resetHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resetButton) {
|
if (resetButton) {
|
||||||
|
@ -1512,9 +1512,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
const closeButton = modal.querySelector('.usa-modal__close');
|
const closeButton = modal.querySelector('.usa-modal__close');
|
||||||
submitButton.addEventListener('click', function() {
|
submitButton.addEventListener('click', function() {
|
||||||
pk = submitButton.getAttribute('data-pk');
|
pk = submitButton.getAttribute('data-pk');
|
||||||
// Close the modal to remove the USWDS UI locl classes
|
// Close the modal to remove the USWDS UI local classes
|
||||||
closeButton.click();
|
closeButton.click();
|
||||||
// If we're deleteing the last item on a page that is not page 1, we'll need to refresh the display to the previous page
|
// If we're deleting the last item on a page that is not page 1, we'll need to refresh the display to the previous page
|
||||||
let pageToDisplay = data.page;
|
let pageToDisplay = data.page;
|
||||||
if (data.total == 1 && data.unfiltered_total > 1) {
|
if (data.total == 1 && data.unfiltered_total > 1) {
|
||||||
pageToDisplay--;
|
pageToDisplay--;
|
||||||
|
@ -1573,11 +1573,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
hideElement(resetButton);
|
hideElement(resetButton);
|
||||||
}
|
}
|
||||||
loadDomainRequests(1, 'id', 'asc');
|
loadDomainRequests(1, 'id', 'asc');
|
||||||
resetheaders();
|
resetHeaders();
|
||||||
})
|
})
|
||||||
|
|
||||||
// Reset UI and accessibility
|
// Reset UI and accessibility
|
||||||
function resetheaders() {
|
function resetHeaders() {
|
||||||
tableHeaders.forEach(header => {
|
tableHeaders.forEach(header => {
|
||||||
// unset sort UI in headers
|
// unset sort UI in headers
|
||||||
unsetHeader(header);
|
unsetHeader(header);
|
||||||
|
@ -1591,7 +1591,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
currentSearchTerm = '';
|
currentSearchTerm = '';
|
||||||
hideElement(resetButton);
|
hideElement(resetButton);
|
||||||
loadDomainRequests(1, 'id', 'asc', hasLoaded, '');
|
loadDomainRequests(1, 'id', 'asc', hasLoaded, '');
|
||||||
resetheaders();
|
resetHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resetButton) {
|
if (resetButton) {
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- CSRF token -->
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<section class="section--outlined domains">
|
<section class="section--outlined domains">
|
||||||
<div class="grid-row">
|
<div class="grid-row">
|
||||||
<div class="mobile:grid-col-12 desktop:grid-col-6">
|
<div class="mobile:grid-col-12 desktop:grid-col-6">
|
||||||
|
|
|
@ -105,7 +105,7 @@ class GetDomainsJsonTest(TestWithUser, WebTest):
|
||||||
def test_get_domains_json_search(self):
|
def test_get_domains_json_search(self):
|
||||||
"""Test search."""
|
"""Test search."""
|
||||||
# Define your URL variables as a dictionary
|
# Define your URL variables as a dictionary
|
||||||
url_vars = {"search_term": "e2"} # Modify with your actual variables
|
url_vars = {"search_term": "e2"}
|
||||||
|
|
||||||
# Use the params parameter to include URL variables
|
# Use the params parameter to include URL variables
|
||||||
response = self.app.get(reverse("get_domains_json"), params=url_vars)
|
response = self.app.get(reverse("get_domains_json"), params=url_vars)
|
||||||
|
|
|
@ -205,7 +205,7 @@ class GetRequestsJsonTest(TestWithUser, WebTest):
|
||||||
def test_get_domain_requests_json_search(self):
|
def test_get_domain_requests_json_search(self):
|
||||||
"""Test search."""
|
"""Test search."""
|
||||||
# Define your URL variables as a dictionary
|
# Define your URL variables as a dictionary
|
||||||
url_vars = {"search_term": "lamb"} # Modify with your actual variables
|
url_vars = {"search_term": "lamb"}
|
||||||
|
|
||||||
# Use the params parameter to include URL variables
|
# Use the params parameter to include URL variables
|
||||||
response = self.app.get(reverse("get_domain_requests_json"), params=url_vars)
|
response = self.app.get(reverse("get_domain_requests_json"), params=url_vars)
|
||||||
|
@ -234,7 +234,7 @@ class GetRequestsJsonTest(TestWithUser, WebTest):
|
||||||
def test_get_domain_requests_json_search_new_domains(self):
|
def test_get_domain_requests_json_search_new_domains(self):
|
||||||
"""Test search when looking up New domain requests"""
|
"""Test search when looking up New domain requests"""
|
||||||
# Define your URL variables as a dictionary
|
# Define your URL variables as a dictionary
|
||||||
url_vars = {"search_term": "ew"} # Modify with your actual variables
|
url_vars = {"search_term": "ew"}
|
||||||
|
|
||||||
# Use the params parameter to include URL variables
|
# Use the params parameter to include URL variables
|
||||||
response = self.app.get(reverse("get_domain_requests_json"), params=url_vars)
|
response = self.app.get(reverse("get_domain_requests_json"), params=url_vars)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue