From 906622bd551ce65561f31e66d1611d808db00b9a Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:18:45 -0600 Subject: [PATCH 01/14] Add seperate show more buttons --- src/registrar/admin.py | 18 ++- src/registrar/assets/js/get-gov-admin.js | 38 +---- src/registrar/assets/sass/_theme/_admin.scss | 7 + .../admin/includes/detail_table_fieldset.html | 140 ++++++++++-------- 4 files changed, 103 insertions(+), 100 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index eee2eda2f..7a202c26b 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1485,6 +1485,12 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): custom_election_board.admin_order_field = "is_election_board" # type: ignore custom_election_board.short_description = "Election office" # type: ignore + # This is just a placeholder. This field will be populated in the detail_table_fieldset view. + # This is not a field that exists on the model. + def status_history(self, obj): + return "No changelog to display." + status_history.short_description = "Status History" + # Filters list_filter = ( StatusListFilter, @@ -1510,6 +1516,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): { "fields": [ "portfolio", + "status_history", "status", "rejection_reason", "action_needed_reason", @@ -1592,6 +1599,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): "alternative_domains", "is_election_board", "federal_agency", + "status_history" ) # Read only that we'll leverage for CISA Analysts @@ -2097,6 +2105,14 @@ class DomainInformationInline(admin.StackedInline): return modified_fieldsets +class DomainForm(forms.ModelForm): + """This form utilizes the custom widget for its class's forms""" + + class Meta: + model = models.Domain + fields = "__all__" + widgets = { + } class DomainResource(FsmModelResource): """defines how each field in the referenced model should be mapped to the corresponding fields in the @@ -2110,7 +2126,7 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin): """Custom domain admin class to add extra buttons.""" resource_classes = [DomainResource] - + #form = MyUserAdminForm class ElectionOfficeFilter(admin.SimpleListFilter): """Define a custom filter for is_election_board""" diff --git a/src/registrar/assets/js/get-gov-admin.js b/src/registrar/assets/js/get-gov-admin.js index 140421db5..bbda07834 100644 --- a/src/registrar/assets/js/get-gov-admin.js +++ b/src/registrar/assets/js/get-gov-admin.js @@ -421,38 +421,6 @@ function initializeWidgetOnList(list, parentId) { sessionStorage.removeItem(name); } } - - document.addEventListener('DOMContentLoaded', function() { - let statusSelect = document.getElementById('id_status'); - - function moveStatusChangelog(actionNeededReasonFormGroup, statusSelect) { - let flexContainer = actionNeededReasonFormGroup.querySelector('.flex-container'); - let statusChangelog = document.getElementById('dja-status-changelog'); - - // On action needed, show the email that will be sent out - let showReasonEmailContainer = document.querySelector("#action_needed_reason_email_readonly") - - // Prepopulate values on page load. - if (statusSelect.value === "action needed") { - flexContainer.parentNode.insertBefore(statusChangelog, flexContainer.nextSibling); - showElement(showReasonEmailContainer); - } else { - // Move the changelog back to its original location - let statusFlexContainer = statusSelect.closest('.flex-container'); - statusFlexContainer.parentNode.insertBefore(statusChangelog, statusFlexContainer.nextSibling); - hideElement(showReasonEmailContainer); - } - - } - - // Call the function on page load - moveStatusChangelog(actionNeededReasonFormGroup, statusSelect); - - // Add event listener to handle changes to the selector itself - statusSelect.addEventListener('change', function() { - moveStatusChangelog(actionNeededReasonFormGroup, statusSelect); - }) - }); })(); /** An IIFE for toggling the submit bar on domain request forms @@ -548,13 +516,13 @@ function initializeWidgetOnList(list, parentId) { })(); -/** An IIFE that hooks up to the "show email" button. - * which shows the auto generated email on action needed reason. +/** An IIFE that hooks to the show/hide button underneath action needed reason. + * This shows the auto generated email on action needed reason. */ (function () { let actionNeededReasonDropdown = document.querySelector("#id_action_needed_reason"); let actionNeededEmail = document.querySelector("#action_needed_reason_email_view_more"); - if(actionNeededReasonDropdown && actionNeededEmail && container) { + if(actionNeededReasonDropdown && actionNeededEmail) { // Add a change listener to the action needed reason dropdown handleChangeActionNeededEmail(actionNeededReasonDropdown, actionNeededEmail); } diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index aa8020ede..950285de6 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -788,6 +788,7 @@ div.dja__model-description{ } .dja-readonly-textarea-container { + overflow-x: scroll; textarea { width: 100%; min-width: 610px; @@ -810,6 +811,12 @@ div.dja__model-description{ } } +@media (max-width: 1230px) { + .dja-readonly-textarea-container { + overflow-x: scroll; + } +} + .max-full { width: 100% !important; } 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 284dd9217..d6c68970a 100644 --- a/src/registrar/templates/django/admin/includes/detail_table_fieldset.html +++ b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html @@ -8,7 +8,60 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html) {% block field_readonly %} {% with all_contacts=original_object.other_contacts.all %} - {% if field.field.name == "other_contacts" %} + {% if field.field.name == "status_history" %} + {% if filtered_audit_log_entries %} +
Status | +User | +Changed at | +
---|---|---|
+ {% if entry.status %} + {{ entry.status|default:"Error" }} + {% else %} + Error + {% endif %} + + {% if entry.rejection_reason %} + - {{ entry.rejection_reason|default:"Error" }} + {% endif %} + + {% if entry.action_needed_reason %} + - {{ entry.action_needed_reason|default:"Error" }} + {% endif %} + | +{{ entry.actor|default:"Error" }} | +{{ entry.timestamp|date:"Y-m-d H:i:s" }} | +
No changelog to display.
+ {% endif %} +Status | -User | -Changed at | -
---|---|---|
- {% if entry.status %} - {{ entry.status|default:"Error" }} - {% else %} - Error - {% endif %} - - {% if entry.rejection_reason %} - - {{ entry.rejection_reason|default:"Error" }} - {% endif %} - - {% if entry.action_needed_reason %} - - {{ entry.action_needed_reason|default:"Error" }} - {% endif %} - | -{{ entry.actor|default:"Error" }} | -{{ entry.timestamp|date:"Y-m-d H:i:s" }} | -
No changelog to display.
- {% endif %} - - {% comment %} - Store the action needed reason emails in a json-based dictionary. - This allows us to change the action_needed_reason_email field dynamically, depending on value. - The alternative to this is an API endpoint. + {% comment %} + Store the action needed reason emails in a json-based dictionary. + This allows us to change the action_needed_reason_email field dynamically, depending on value. + The alternative to this is an API endpoint. - Given that we have a limited number of emails, doing it this way makes sense. - {% endcomment %} - {% if action_needed_reason_emails %} - - {% endif %} -No email will be sent.
-No email will be sent.