From 3a12e59db65c2a76a4151603e6d2442dd8cb0f24 Mon Sep 17 00:00:00 2001
From: zandercymatics <141044360+zandercymatics@users.noreply.github.com>
Date: Tue, 18 Feb 2025 15:02:53 -0700
Subject: [PATCH 1/7] Fix andi errors
---
src/registrar/admin.py | 7 ++++---
src/registrar/assets/src/sass/_theme/_admin.scss | 4 ++++
.../templates/admin/change_list_results.html | 10 +++++-----
src/registrar/templatetags/custom_filters.py | 14 +++++++++-----
4 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/registrar/admin.py b/src/registrar/admin.py
index 2d2b90a5f..9dae19a22 100644
--- a/src/registrar/admin.py
+++ b/src/registrar/admin.py
@@ -2287,11 +2287,12 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
@admin.display(description=_("Requested Domain"))
def custom_requested_domain(self, obj):
# Example: Show different icons based on `status`
- url = reverse("admin:registrar_domainrequest_changelist") + f"{obj.id}"
text = obj.requested_domain
if obj.portfolio:
- return format_html(' {}', url, text)
- return format_html('{}', url, text)
+ return format_html(
+ f' {escape(text)}'
+ )
+ return text
custom_requested_domain.admin_order_field = "requested_domain__name" # type: ignore
diff --git a/src/registrar/assets/src/sass/_theme/_admin.scss b/src/registrar/assets/src/sass/_theme/_admin.scss
index a15d1eabe..79fc6273e 100644
--- a/src/registrar/assets/src/sass/_theme/_admin.scss
+++ b/src/registrar/assets/src/sass/_theme/_admin.scss
@@ -982,3 +982,7 @@ ul.add-list-reset {
}
}
+
+#result_list > tbody tr > th > a {
+ text-decoration: underline;
+}
\ No newline at end of file
diff --git a/src/registrar/templates/admin/change_list_results.html b/src/registrar/templates/admin/change_list_results.html
index 5e4f37711..f55ac7197 100644
--- a/src/registrar/templates/admin/change_list_results.html
+++ b/src/registrar/templates/admin/change_list_results.html
@@ -19,11 +19,11 @@ Load our custom filters to extract info from the django generated markup.
{% if results.0|contains_checkbox %}
{# .gov - hardcode the select all checkbox #}
-
+
-
+
@@ -61,10 +61,10 @@ Load our custom filters to extract info from the django generated markup.
{% endif %}
{% with result_value=result.0|extract_value %}
- {% with result_label=result.1|extract_a_text %}
+ {% with result_label=result.1|extract_a_text checkbox_id="select-"|add:result_value %}
-
-
+
+
{% endwith %}
{% endwith %}
diff --git a/src/registrar/templatetags/custom_filters.py b/src/registrar/templatetags/custom_filters.py
index ff73e6dc1..cf2abf447 100644
--- a/src/registrar/templatetags/custom_filters.py
+++ b/src/registrar/templatetags/custom_filters.py
@@ -25,11 +25,15 @@ def extract_a_text(value):
pattern = r"]*>(.*?)"
match = re.search(pattern, value)
if match:
- extracted_text = match.group(1)
- else:
- extracted_text = ""
-
- return extracted_text
+ # Get the content and strip any nested HTML tags
+ content = match.group(1)
+ # Remove any nested HTML tags (like )
+ text_pattern = r"<[^>]+>"
+ text_only = re.sub(text_pattern, "", content)
+ # Clean up any extra whitespace
+ return text_only.strip()
+
+ return ""
@register.filter
From 0e09e5720bc49b9ecf677be53f7bbceaf412c52f Mon Sep 17 00:00:00 2001
From: zandercymatics <141044360+zandercymatics@users.noreply.github.com>
Date: Wed, 19 Feb 2025 10:45:47 -0700
Subject: [PATCH 2/7] Test making button clickable
---
.../assets/src/js/getgov-admin/button-utils.js | 16 ++++++++++++++++
src/registrar/assets/src/js/getgov-admin/main.js | 2 ++
.../import_export/change_list_export_item.html | 7 +++++++
.../import_export/change_list_import_item.html | 2 +-
4 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 src/registrar/assets/src/js/getgov-admin/button-utils.js
create mode 100644 src/registrar/templates/admin/import_export/change_list_export_item.html
diff --git a/src/registrar/assets/src/js/getgov-admin/button-utils.js b/src/registrar/assets/src/js/getgov-admin/button-utils.js
new file mode 100644
index 000000000..79d9091d6
--- /dev/null
+++ b/src/registrar/assets/src/js/getgov-admin/button-utils.js
@@ -0,0 +1,16 @@
+/**
+ * Initializes buttons to behave like links by navigating to their data-url attribute
+ * Example usage:
+ */
+export function initButtonLinks() {
+ document.querySelectorAll('button.use-button-as-link').forEach(button => {
+ button.addEventListener('click', function() {
+ // Equivalent to button.getAttribute("data-href")
+ const href = this.dataset.href;
+ console.log(`in loop: ${href}`)
+ if (href) {
+ window.location.href = href;
+ }
+ });
+ });
+}
diff --git a/src/registrar/assets/src/js/getgov-admin/main.js b/src/registrar/assets/src/js/getgov-admin/main.js
index 5c6de20ab..7eb1fc8cd 100644
--- a/src/registrar/assets/src/js/getgov-admin/main.js
+++ b/src/registrar/assets/src/js/getgov-admin/main.js
@@ -16,6 +16,7 @@ import { initDynamicPortfolioFields } from './portfolio-form.js';
import { initDynamicDomainInformationFields } from './domain-information-form.js';
import { initDynamicDomainFields } from './domain-form.js';
import { initAnalyticsDashboard } from './analytics.js';
+import { initButtonLinks } from './button-utils.js';
// General
initModals();
@@ -23,6 +24,7 @@ initCopyToClipboard();
initFilterHorizontalWidget();
initDescriptions();
initSubmitBar();
+initButtonLinks();
// Domain request
initIneligibleModal();
diff --git a/src/registrar/templates/admin/import_export/change_list_export_item.html b/src/registrar/templates/admin/import_export/change_list_export_item.html
new file mode 100644
index 000000000..9678d224a
--- /dev/null
+++ b/src/registrar/templates/admin/import_export/change_list_export_item.html
@@ -0,0 +1,7 @@
+{% load i18n %}
+{% load admin_urls %}
+
+{% if has_export_permission %}
+{% comment %} Uses the initButtonLinks {% endcomment %}
+
+{% endif %}
diff --git a/src/registrar/templates/admin/import_export/change_list_import_item.html b/src/registrar/templates/admin/import_export/change_list_import_item.html
index 8255a8ba7..0f2d59421 100644
--- a/src/registrar/templates/admin/import_export/change_list_import_item.html
+++ b/src/registrar/templates/admin/import_export/change_list_import_item.html
@@ -3,6 +3,6 @@
{% if has_import_permission %}
{% if not IS_PRODUCTION %}
-