mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 03:58:39 +02:00
Make collapsible fieldsets toggle accessible
This commit is contained in:
parent
0daca56699
commit
b27fce713b
5 changed files with 64 additions and 15 deletions
|
@ -1001,9 +1001,10 @@ class DomainInformationAdmin(ListHeaderAdmin):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"More details",
|
"Show details",
|
||||||
{
|
{
|
||||||
"classes": ["collapse"],
|
"classes": ["collapse--dotgov"],
|
||||||
|
"description": "Extends type of organization",
|
||||||
"fields": [
|
"fields": [
|
||||||
"federal_type",
|
"federal_type",
|
||||||
# "updated_federal_agency",
|
# "updated_federal_agency",
|
||||||
|
@ -1026,9 +1027,10 @@ class DomainInformationAdmin(ListHeaderAdmin):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"More details",
|
"Show details",
|
||||||
{
|
{
|
||||||
"classes": ["collapse"],
|
"classes": ["collapse--dotgov"],
|
||||||
|
"description": "Extends organization name and mailing address",
|
||||||
"fields": [
|
"fields": [
|
||||||
"address_line1",
|
"address_line1",
|
||||||
"address_line2",
|
"address_line2",
|
||||||
|
@ -1242,9 +1244,10 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"More details",
|
"Show details",
|
||||||
{
|
{
|
||||||
"classes": ["collapse"],
|
"classes": ["collapse--dotgov"],
|
||||||
|
"description": "Extends type of organization",
|
||||||
"fields": [
|
"fields": [
|
||||||
"federal_type",
|
"federal_type",
|
||||||
# "updated_federal_agency",
|
# "updated_federal_agency",
|
||||||
|
@ -1267,9 +1270,10 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"More details",
|
"Show details",
|
||||||
{
|
{
|
||||||
"classes": ["collapse"],
|
"classes": ["collapse--dotgov"],
|
||||||
|
"description": "Extends organization name and mailing address",
|
||||||
"fields": [
|
"fields": [
|
||||||
"address_line1",
|
"address_line1",
|
||||||
"address_line2",
|
"address_line2",
|
||||||
|
|
|
@ -525,17 +525,25 @@ address.dja-address-contact-list {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapse button styles for fieldsets
|
// Collapse button styles for fieldsets
|
||||||
.module.collapse {
|
.module.collapse--dotgov {
|
||||||
margin-top: -35px;
|
margin-top: -35px;
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
border: none;
|
border: none;
|
||||||
h2 {
|
button {
|
||||||
background: none;
|
background: none;
|
||||||
color: var(--body-fg)!important;
|
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: var(--link-fg);
|
color: var(--link-fg);
|
||||||
|
margin-top: 8px;
|
||||||
|
margin-left: 10px;
|
||||||
|
span {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.collapse--dotgov.collapsed .collapse-toggle--dotgov {
|
||||||
|
display: inline-block!important;
|
||||||
|
* {
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
<script type="application/javascript" src="{% static 'js/get-gov-admin.js' %}" defer></script>
|
<script type="application/javascript" src="{% static 'js/get-gov-admin.js' %}" defer></script>
|
||||||
<script type="application/javascript" src="{% static 'js/get-gov-reports.js' %}" defer></script>
|
<script type="application/javascript" src="{% static 'js/get-gov-reports.js' %}" defer></script>
|
||||||
|
<script type="application/javascript" src="{% static 'js/dja-collapse.js' %}" defer></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
|
||||||
|
|
|
@ -6,9 +6,23 @@ It is not inherently customizable on its own, so we can modify this instead.
|
||||||
https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/includes/fieldset.html
|
https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/includes/fieldset.html
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
<fieldset class="module aligned {{ fieldset.classes }}">
|
<fieldset class="module aligned {{ fieldset.classes }}">
|
||||||
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
|
{% if fieldset.name %}
|
||||||
|
{# Customize the markup for the collapse toggle #}
|
||||||
|
{% if 'collapse--dotgov' in fieldset.classes %}
|
||||||
|
<button type="button" aria-label="Toggle (show/hide) the content in this fiedset">
|
||||||
|
<span>{{ fieldset.name }}</span>
|
||||||
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||||
|
<use xlink:href="{%static 'img/sprite.svg'%}#expand_more"></use>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<legend class="sr-only">{{ fieldset.description }}</legend>
|
||||||
|
{% else %}
|
||||||
|
<h2>{{ fieldset.name }}</h2>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if fieldset.description %}
|
{# Customize the markup for the collapse toggle: Do not show a description for the collapse fieldsets, instead we're using the description as a screen reader only legend #}
|
||||||
|
{% if fieldset.description and 'collapse--dotgov' not in fieldset.classes %}
|
||||||
<div class="description">{{ fieldset.description|safe }}</div>
|
<div class="description">{{ fieldset.description|safe }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
@ -887,6 +887,28 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
]
|
]
|
||||||
self.test_helper.assert_response_contains_distinct_values(response, expected_values)
|
self.test_helper.assert_response_contains_distinct_values(response, expected_values)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
|
def test_collaspe_toggle_button_markup(self):
|
||||||
|
"""
|
||||||
|
Tests for the correct collapse toggle button markup
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Create a fake domain request and domain
|
||||||
|
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
|
||||||
|
|
||||||
|
p = "adminpass"
|
||||||
|
self.client.login(username="superuser", password=p)
|
||||||
|
response = self.client.get(
|
||||||
|
"/admin/registrar/domainrequest/{}/change/".format(domain_request.pk),
|
||||||
|
follow=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Make sure the page loaded, and that we're on the right page
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertContains(response, domain_request.requested_domain.name)
|
||||||
|
|
||||||
|
self.test_helper.assertContains(response, "<span>Show details</span>")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_analyst_can_see_and_edit_alternative_domain(self):
|
def test_analyst_can_see_and_edit_alternative_domain(self):
|
||||||
"""Tests if an analyst can still see and edit the alternative domain field"""
|
"""Tests if an analyst can still see and edit the alternative domain field"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue