mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 06:24:12 +02:00
Edge cases
Found a bug regarding the default display of the show more/less icons for the audit log table
This commit is contained in:
parent
f5dcb8ea35
commit
fd0dcc3440
4 changed files with 24 additions and 26 deletions
|
@ -14,7 +14,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const hideElement = (element) => {
|
const hideElement = (element) => {
|
||||||
if (!element.classList.contains("display-none"))
|
if (element && !element.classList.contains("display-none"))
|
||||||
element.classList.add('display-none');
|
element.classList.add('display-none');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const hideElement = (element) => {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const showElement = (element) => {
|
const showElement = (element) => {
|
||||||
if (element.classList.contains("display-none"))
|
if (element && element.classList.contains("display-none"))
|
||||||
element.classList.remove('display-none');
|
element.classList.remove('display-none');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -428,15 +428,33 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
function moveStatusChangelog(actionNeededReasonFormGroup, statusSelect) {
|
function moveStatusChangelog(actionNeededReasonFormGroup, statusSelect) {
|
||||||
let flexContainer = actionNeededReasonFormGroup.querySelector('.flex-container');
|
let flexContainer = actionNeededReasonFormGroup.querySelector('.flex-container');
|
||||||
let statusChangelog = document.getElementById('dja-status-changelog');
|
let statusChangelog = document.getElementById('dja-status-changelog');
|
||||||
|
let actionNeededEmail = document.querySelector("#action_needed_reason_email_view_more");
|
||||||
|
let emailContainer = actionNeededEmail.closest(".dja-readonly-textarea-container");
|
||||||
|
let hasAuditLogs = document.getElementById("has_audit_logs").value == "true"
|
||||||
|
|
||||||
|
// Prepopulate values on page load.
|
||||||
if (statusSelect.value === "action needed") {
|
if (statusSelect.value === "action needed") {
|
||||||
flexContainer.parentNode.insertBefore(statusChangelog, flexContainer.nextSibling);
|
flexContainer.parentNode.insertBefore(statusChangelog, flexContainer.nextSibling);
|
||||||
|
|
||||||
|
// Show the changelog if hidden and show the email container
|
||||||
|
showElement(statusChangelog);
|
||||||
|
showElement(emailContainer);
|
||||||
} else {
|
} else {
|
||||||
// Move the changelog back to its original location
|
// Move the changelog back to its original location
|
||||||
let statusFlexContainer = statusSelect.closest('.flex-container');
|
let statusFlexContainer = statusSelect.closest('.flex-container');
|
||||||
statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling);
|
statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling);
|
||||||
|
|
||||||
|
// Hide the email container, and show the element if we have audit logs
|
||||||
|
hideElement(emailContainer)
|
||||||
|
if (hasAuditLogs){
|
||||||
|
showElement(statusChangelog);
|
||||||
|
}else {
|
||||||
|
hideElement(statusChangelog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Call the function on page load
|
// Call the function on page load
|
||||||
moveStatusChangelog(actionNeededReasonFormGroup, statusSelect);
|
moveStatusChangelog(actionNeededReasonFormGroup, statusSelect);
|
||||||
|
|
||||||
|
@ -550,28 +568,8 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
// for both of these things seperately.
|
// for both of these things seperately.
|
||||||
let actionNeededEmail = document.querySelector("#action_needed_reason_email_view_more");
|
let actionNeededEmail = document.querySelector("#action_needed_reason_email_view_more");
|
||||||
let changeLog = document.querySelector(".dja-status-changelog");
|
let changeLog = document.querySelector(".dja-status-changelog");
|
||||||
|
|
||||||
if(actionNeededReasonDropdown && actionNeededEmail) {
|
if(actionNeededReasonDropdown && actionNeededEmail) {
|
||||||
let emailContainer = actionNeededEmail.closest(".dja-readonly-textarea-container");
|
// Add a change listener to the action needed reason dropdown
|
||||||
if (statusDropdown.value == "action needed") {
|
|
||||||
showElement(emailContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
statusDropdown.addEventListener("change", function() {
|
|
||||||
if (statusDropdown.value == "action needed") {
|
|
||||||
showElement(emailContainer);
|
|
||||||
}else {
|
|
||||||
hideElement(emailContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We hide the table if there isn't any data to start with.
|
|
||||||
// If we add a value, show it.
|
|
||||||
// This edge case applies to fixtures data. Prod data will have a changelog to pull from.
|
|
||||||
if(changeLog && changeLog.classList.contains("display-none") && actionNeededReasonDropdown.value){
|
|
||||||
showElement(changeLog);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
handleChangeActionNeededEmail(actionNeededReasonDropdown, actionNeededEmail);
|
handleChangeActionNeededEmail(actionNeededReasonDropdown, actionNeededEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,5 +619,4 @@ function initializeWidgetOnList(list, parentId) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
|
@ -801,7 +801,7 @@ div.dja__model-description{
|
||||||
}
|
}
|
||||||
|
|
||||||
&::-webkit-scrollbar-thumb {
|
&::-webkit-scrollbar-thumb {
|
||||||
background-color: var(--hairline-color);
|
background-color: var(--body-fg);
|
||||||
border-radius: 99px;
|
border-radius: 99px;
|
||||||
background-clip: content-box;
|
background-clip: content-box;
|
||||||
border: 3px solid transparent;
|
border: 3px solid transparent;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<a id="invisible-ineligible-modal-toggler" class="display-none" href="#toggle-set-ineligible" aria-controls="toggle-set-ineligible" data-open-modal></a>
|
<a id="invisible-ineligible-modal-toggler" class="display-none" href="#toggle-set-ineligible" aria-controls="toggle-set-ineligible" data-open-modal></a>
|
||||||
{# Store the current object id so we can access it easier #}
|
{# Store the current object id so we can access it easier #}
|
||||||
<input id="domain_request_id" class="display-none" value="{{original.id}}" />
|
<input id="domain_request_id" class="display-none" value="{{original.id}}" />
|
||||||
|
<input id="has_audit_logs" class="display-none" value="{%if filtered_audit_log_entries %}true{% else %}false{% endif %}"/>
|
||||||
{% for fieldset in adminform %}
|
{% for fieldset in adminform %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
TODO: this will eventually need to be changed to something like this
|
TODO: this will eventually need to be changed to something like this
|
||||||
|
|
|
@ -69,7 +69,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
|
|
||||||
{% block after_help_text %}
|
{% block after_help_text %}
|
||||||
{% if field.field.name == "status" %}
|
{% if field.field.name == "status" %}
|
||||||
<div class="flex-container {% if not filtered_audit_log_entries or not original_object.action_needed_reason %}display-none{% endif %}" id="dja-status-changelog">
|
<div class="flex-container {% if not filtered_audit_log_entries and original_object.status != "action needed" or not original_object.action_needed_reason and original_object.status == "action needed" and not filtered_audit_log_entries %}display-none{% endif %}" id="dja-status-changelog">
|
||||||
<label aria-label="Status changelog"></label>
|
<label aria-label="Status changelog"></label>
|
||||||
<div>
|
<div>
|
||||||
<div class="usa-table-container--scrollable collapse--dgsimple collapsed" tabindex="0">
|
<div class="usa-table-container--scrollable collapse--dgsimple collapsed" tabindex="0">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue