Merge branch 'za/1852-user-contact-info-inline' into za/1848-copy-contact-email-to-clipboard

This commit is contained in:
zandercymatics 2024-03-19 14:08:26 -06:00
commit 706275a1e4
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
5 changed files with 116 additions and 0 deletions

View file

@ -1115,6 +1115,8 @@ class DomainRequestAdmin(ListHeaderAdmin):
"requested_domain",
"approved_domain",
"alternative_domains",
"other_contacts",
"current_websites",
"purpose",
"submitter",
"no_other_contacts_rationale",
@ -1134,6 +1136,8 @@ class DomainRequestAdmin(ListHeaderAdmin):
# Table ordering
ordering = ["requested_domain__name"]
change_form_template = "django/admin/domain_request_change_form.html"
# Trigger action when a fieldset is changed
def save_model(self, request, obj, form, change):
"""Custom save_model definition that handles edge cases"""

View file

@ -317,6 +317,20 @@ input.admin-confirm-button {
color: $dhs-blue-70;
}
details.dja-detail-table {
background-color: var(--darkened-bg);
display: inline-table;
.dja-details-summary {
color: var(--header-link-color);
background-color: var(--primary);
}
.dja-details-contents {
tr {
background-color: var(--darkened-bg);
}
}
}
.admin-icon-group {
position: relative;
display: flex;

View file

@ -0,0 +1,8 @@
{% extends 'admin/change_form.html' %}
{% load i18n static %}
{% block field_sets %}
{% for fieldset in adminform %}
{% include "django/admin/includes/domain_request_fieldset.html" %}
{% endfor %}
{% endblock %}

View file

@ -0,0 +1,28 @@
{% load i18n static %}
<details class="margin-top-1 dja-detail-table" {% if start_opened %}open{% endif %}>
<summary class="padding-1 dja-details-summary">Details</summary>
<div class="grid-container padding-left-0 padding-right-0 dja-details-contents">
{% if user.title or user.email or user.phone %}
<table>
<tbody>
<tr>
<th scope="row">Title</th>
<td>{{ user.title }}</td>
</tr>
<tr>
<th scope="row">Email</th>
<td>{{ user.email }}</td>
</tr>
<tr>
<th scope="row">Phone</th>
<td>{{ user.phone }}</td>
</tr>
</tbody>
</table>
{% else %}
<div class="padding-1">No details found</div>
{% endif %}
</div>
</details>

View file

@ -0,0 +1,62 @@
{% extends "admin/fieldset.html" %}
{% comment %}
This is using a custom implementation fieldset.html (see admin/fieldset.html)
{% endcomment %}
{% block fieldset_lines %}
{% for line in fieldset %}
<div class="form-row{% if line.fields|length == 1 and line.errors %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
{% if line.fields|length == 1 %}{{ line.errors }}{% else %}<div class="flex-container form-multiline">{% endif %}
{% for field in line %}
<div>
{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
<div class="flex-container{% if not line.fields|length == 1 %} fieldBox{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}{% elif field.is_checkbox %} checkbox-row{% endif %}">
{% if field.is_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% else %}
{{ field.label_tag }}
{% if field.is_readonly %}
<div class="readonly">{{ field.contents }}</div>
{% else %}
{{ field.field }}
{% endif %}
{% endif %}
</div>
{% if field.field.name == "creator" %}
{% include "django/admin/includes/domain_request_detail_table.html" with user=original.creator start_opened=True %}
{% elif field.field.name == "submitter" %}
{% include "django/admin/includes/domain_request_detail_table.html" with user=original.submitter start_opened=True %}
{% elif field.field.name == "authorizing_official" %}
{% include "django/admin/includes/domain_request_detail_table.html" with user=original.authorizing_official start_opened=True %}
{% elif field.field.name == "other_contacts" %}
<details class="margin-top-1 dja-detail-table">
<summary class="padding-1 dja-details-summary">Details</summary>
<div class="grid-container padding-left-0 padding-right-0 dja-details-contents">
<table>
<tbody>
{% for contact in original.other_contacts.all %}
<tr>
<th scope="row">{{contact.first_name}} {{contact.last_name}}</th>
<td>{{ contact.title }}</td>
<td>{{ contact.email }}</td>
<td>{{ contact.phone }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</details>
{% endif %}
{% if field.field.help_text %}
<div class="help"{% if field.field.id_for_label %} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
<div>{{ field.field.help_text|safe }}</div>
</div>
{% endif %}
</div>
{% endfor %}
{% if not line.fields|length == 1 %}</div>{% endif %}
</div>
{% endfor %}
{% endblock fieldset_lines %}