From a8c10816b8e6913b57ba9369d7adae4fcbb0eb10 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:49:32 -0600 Subject: [PATCH] Add links to urls --- src/registrar/assets/js/get-gov-admin.js | 44 +++++++++++++++++++ src/registrar/assets/sass/_theme/_admin.scss | 32 ++++++++++++++ .../includes/domain_request_detail_table.html | 42 +++++++----------- .../includes/domain_request_fieldset.html | 24 +++++++--- src/registrar/templatetags/url_helpers.py | 7 +++ 5 files changed, 117 insertions(+), 32 deletions(-) diff --git a/src/registrar/assets/js/get-gov-admin.js b/src/registrar/assets/js/get-gov-admin.js index 4ed00c33f..28149999c 100644 --- a/src/registrar/assets/js/get-gov-admin.js +++ b/src/registrar/assets/js/get-gov-admin.js @@ -170,6 +170,50 @@ function checkToListThenInitWidget(toListId, attempts) { } } +(function() { + function addUrlsToOtherContacts() { + document.addEventListener('DOMContentLoaded', function() { + // Select all table rows that have a data-contact-id attribute + let contactRows = document.querySelectorAll("tr[data-contact-url]"); + + if (contactRows){ + // Add a click event listener to each row + let index = 1; + contactRows.forEach(function(row) { + let otherContactUrl = row.getAttribute("data-contact-url"); + if (otherContactUrl){ + let otherContact = document.querySelector(`.other-contact__${index}`); + if (otherContact) { + otherContact.href = otherContactUrl; + } + } + index++; + }); + } + }); + } + + addUrlsToOtherContacts() +})(); + +document.addEventListener('DOMContentLoaded', function() { + // Select all table rows that have a data-contact-id attribute + let contactRows = document.querySelectorAll("tr[data-contact-url]"); + + // Add a click event listener to each row + index = 1 + contactRows.forEach(function(row) { + let otherContactUrl = row.getAttribute("data-contact-url"); + if (otherContactUrl){ + let otherContact = document.querySelector(`.other-contact__${index}`) + if (otherContact) { + otherContact.href = otherContactUrl + } + } + index++ + }); +}); + // Initialize the widget: // add related buttons to the widget for edit, delete and view // add event listeners on the from list, the to list, and selector buttons which either enable or disable the related buttons diff --git a/src/registrar/assets/sass/_theme/_admin.scss b/src/registrar/assets/sass/_theme/_admin.scss index 596de17ac..98e5009db 100644 --- a/src/registrar/assets/sass/_theme/_admin.scss +++ b/src/registrar/assets/sass/_theme/_admin.scss @@ -330,3 +330,35 @@ details.dja-detail-table { } } } + +table.dja-user-detail-table { + margin-left: 160px; + tr { + background-color: var(--body-bg); + } +} + +.admin-icon-group { + position: relative; + display: flex; + align-items: center; + + .usa-button__icon { + position: absolute; + right: 0; + height: 100%; + } + + input { + // Allow for padding around the copy button + padding-right: 35px; + // Match the height of other inputs + min-height: 2.25rem; + } + + .no-outline-on-click:focus { + outline: none !important; + } +} + + diff --git a/src/registrar/templates/django/admin/includes/domain_request_detail_table.html b/src/registrar/templates/django/admin/includes/domain_request_detail_table.html index f34ffa491..fba588b61 100644 --- a/src/registrar/templates/django/admin/includes/domain_request_detail_table.html +++ b/src/registrar/templates/django/admin/includes/domain_request_detail_table.html @@ -1,28 +1,18 @@ {% load i18n static %} - -
- Details -
- {% if user.title or user.email or user.phone %} - - - - - - - - - - - - - - - -
Title{{ user.title }}
Email{{ user.email }}
Phone{{ user.phone }}
- {% else %} -
No details found
- {% endif %} -
-
\ No newline at end of file + + + + + + + + + + + + + + + +
Title{{ user.title }}
Email{{ user.email }}
Phone{{ user.phone }}
diff --git a/src/registrar/templates/django/admin/includes/domain_request_fieldset.html b/src/registrar/templates/django/admin/includes/domain_request_fieldset.html index d034d2441..c90423474 100644 --- a/src/registrar/templates/django/admin/includes/domain_request_fieldset.html +++ b/src/registrar/templates/django/admin/includes/domain_request_fieldset.html @@ -1,5 +1,5 @@ {% extends "admin/fieldset.html" %} - +{% load static url_helpers %} {% comment %} This is using a custom implementation fieldset.html (see admin/fieldset.html) {% endcomment %} @@ -16,18 +16,26 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html) {% else %} {{ field.label_tag }} {% if field.is_readonly %} -
{{ field.contents }}
+ {% if field.field.name == "other_contacts" %} +
+ {% for contact in field.contents|split:", " %} + {{ contact }}{% if not forloop.last %}, {% endif %} + {% endfor %} +
+ {% else %} +
{{ field.contents }}
+ {% endif %} {% else %} {{ field.field }} {% endif %} {% endif %} {% if field.field.name == "creator" %} - {% include "django/admin/includes/domain_request_detail_table.html" with user=original.creator start_opened=True %} + {% include "django/admin/includes/domain_request_detail_table.html" with user=original.creator %} {% elif field.field.name == "submitter" %} - {% include "django/admin/includes/domain_request_detail_table.html" with user=original.submitter start_opened=True %} + {% include "django/admin/includes/domain_request_detail_table.html" with user=original.submitter %} {% elif field.field.name == "authorizing_official" %} - {% include "django/admin/includes/domain_request_detail_table.html" with user=original.authorizing_official start_opened=True %} + {% include "django/admin/includes/domain_request_detail_table.html" with user=original.authorizing_official %} {% elif field.field.name == "other_contacts" %}
Details @@ -35,7 +43,11 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html) {% for contact in original.other_contacts.all %} - + {% comment %} + Since we can't get the id from field, we can embed this information here. + Then we can link these two fields using javascript. + {% endcomment %} + diff --git a/src/registrar/templatetags/url_helpers.py b/src/registrar/templatetags/url_helpers.py index 931eedc92..9413892aa 100644 --- a/src/registrar/templatetags/url_helpers.py +++ b/src/registrar/templatetags/url_helpers.py @@ -26,6 +26,13 @@ def endswith(text, ends): return False +@register.filter("split") +def split_string(value, key): + """ + Splits a given string + """ + return value.split(key) + @register.simple_tag def public_site_url(url_path): """Make a full URL for this path at our public site.
{{contact.first_name}} {{contact.last_name}} {{ contact.title }} {{ contact.email }}