diff --git a/src/registrar/assets/js/get-gov-admin.js b/src/registrar/assets/js/get-gov-admin.js index 7b94fb4e1..cd2cd6da4 100644 --- a/src/registrar/assets/js/get-gov-admin.js +++ b/src/registrar/assets/js/get-gov-admin.js @@ -554,14 +554,23 @@ function initializeWidgetOnList(list, parentId) { if(actionNeededReasonDropdown && actionNeededEmail) { let emailContainer = actionNeededEmail.closest(".dja-readonly-textarea-container"); if (statusDropdown.value == "action needed") { - showElement(emailContainer) + showElement(emailContainer); } statusDropdown.addEventListener("change", function() { if (statusDropdown.value == "action needed") { - showElement(emailContainer) + showElement(emailContainer); }else { - hideElement(emailContainer) + 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. + let changeLog = document.querySelector(".dja-status-changelog"); + console.log(`value is ===>${actionNeededReasonDropdown.value}<===`) + if(changeLog && changeLog.classList.contains("display-none") && actionNeededReasonDropdown.value){ + showElement(changeLog); } }); @@ -572,8 +581,16 @@ function initializeWidgetOnList(list, parentId) { function handleChangeActionNeededEmail(actionNeededReasonDropdown, actionNeededEmail) { actionNeededReasonDropdown.addEventListener("change", function() { // TODO on change if not actionneeded on status, hide show email button - const pk = document.querySelector("#domain_request_id").value - const reason = actionNeededReasonDropdown.value + const pk = document.querySelector("#domain_request_id").value; + const reason = actionNeededReasonDropdown.value; + + // If a reason isn't specified, no email will be sent. + // You also cannot save the model in this state. + if(!reason) { + actionNeededEmail.value = "No email will be sent"; + return; + } + fetch(`/get-domain-requests-json/${pk}/action-needed-email/${reason}`) .then(response => response.json()) .then(data => { @@ -581,13 +598,9 @@ function initializeWidgetOnList(list, parentId) { console.log('Error in AJAX call: ' + data.error); return; } - - let noEmailMessage = document.getElementById("no-email-message"); + if(data && data.email_body_text) { actionNeededEmail.value = data.email_body_text - - - }else if (data && !data.email_body_text) { actionNeededEmail.value = "No email will be sent"; } @@ -597,7 +610,6 @@ function initializeWidgetOnList(list, parentId) { } }); }); - } })(); \ No newline at end of file diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index 21fb429a1..eb09c01ec 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -823,4 +823,4 @@ div.dja__model-description{ .no-border { border: none; -} \ No newline at end of file +} diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index ee577a84e..795aa9ee7 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -614,7 +614,8 @@ class DomainRequest(TimeStampedModel): def sync_action_needed_reason_email(self): """If no action_needed_reason_email is defined, add a default one""" - if self.action_needed_reason and not self.action_needed_reason_email: + # Change this in #1901. Add a check on "not self.action_needed_reason_email" + if self.action_needed_reason: text = self.get_action_needed_reason_default_email_text(self.action_needed_reason) self.action_needed_reason_email = text.get("email_body_text") @@ -852,8 +853,6 @@ class DomainRequest(TimeStampedModel): can_send_email = False # TODO - replace this logic with self.action_needed_reason_email in #1901. - # The email content should be dependent on that field. - # Assumes that the template name matches the action needed reason if nothing is specified. # This is so you can override if you need, or have this taken care of for you. if not email_template_name and not email_template_subject_name: diff --git a/src/registrar/templates/django/admin/includes/detail_table_fieldset.html b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html index 12d41c23e..a8de2b161 100644 --- a/src/registrar/templates/django/admin/includes/detail_table_fieldset.html +++ b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html @@ -68,11 +68,12 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html) {% endblock field_readonly %} {% block after_help_text %} - {% if field.field.name == "status" and filtered_audit_log_entries %} -