Make task list read better for screen readers

This duplicates how the task list pattern is coded in the GOV.UK
Prototype kit[1]. It adds ARIA attributes and the use of a
semantically-meaningful element (`<strong>`) to give more information to
screen reader users.

1. https://govuk-prototype-kit.herokuapp.com/docs/templates/task-list
This commit is contained in:
Chris Hill-Scott
2018-09-21 14:24:31 +01:00
parent d4b481d55e
commit c2ef522986
4 changed files with 18 additions and 20 deletions

View File

@@ -67,8 +67,7 @@ from app.notify_client.billing_api_client import BillingAPIClient
from app.notify_client.complaint_api_client import ComplaintApiClient from app.notify_client.complaint_api_client import ComplaintApiClient
from app.notify_client.platform_stats_api_client import PlatformStatsAPIClient from app.notify_client.platform_stats_api_client import PlatformStatsAPIClient
from app.commands import setup_commands from app.commands import setup_commands
from app.utils import get_cdn_domain from app.utils import get_cdn_domain, gmt_timezones, id_safe
from app.utils import gmt_timezones
login_manager = LoginManager() login_manager = LoginManager()
csrf = CSRFProtect() csrf = CSRFProtect()
@@ -664,5 +663,6 @@ def add_template_filters(application):
formatted_list, formatted_list,
nl2br, nl2br,
format_phone_number_human_readable, format_phone_number_human_readable,
id_safe,
]: ]:
application.add_template_filter(fn) application.add_template_filter(fn)

View File

@@ -1,10 +1,10 @@
{% macro task_list_item(completed, label) %} {% macro task_list_item(completed, label, link) %}
<li class="task-list-item"> <li class="task-list-item">
{{ label }} <span aria-describedby="{{ label|id_safe }}"><a href="{{ link }}">{{ label }}</a></span>
{% if completed %} {% if completed %}
<span class="task-list-indicator-completed">Completed</span> <strong class="task-list-indicator-completed" id="{{ label|id_safe }}">Completed</strong>
{% else %} {% else %}
<span class="task-list-indicator-not-completed">Not completed</span> <strong class="task-list-indicator-not-completed" id="{{ label|id_safe }}">Not completed</strong>
{% endif %} {% endif %}
</li> </li>
{% endmacro %} {% endmacro %}

View File

@@ -17,32 +17,26 @@
{% call task_list_wrapper() %} {% call task_list_wrapper() %}
{{ task_list_item( {{ task_list_item(
current_service.has_team_members, current_service.has_team_members,
'<a href="{}">Add a team member who can manage settings, team and usage</a> 'Add a team member who can manage settings, team and usage',
'.format( url_for('main.manage_users', service_id=current_service.id),
url_for('main.manage_users', service_id=current_service.id)
)|safe,
) }} ) }}
{{ task_list_item( {{ task_list_item(
current_service.has_templates, current_service.has_templates,
'<a href="{}">Add templates with examples of the content you plan to send 'Add templates with examples of the content you plan to send',
</a>'.format( url_for('main.choose_template', service_id=current_service.id),
url_for('main.choose_template', service_id=current_service.id)
)|safe,
) }} ) }}
{% if current_service.has_email_templates %} {% if current_service.has_email_templates %}
{{ task_list_item( {{ task_list_item(
current_service.has_email_reply_to_address, current_service.has_email_reply_to_address,
'<a href="{}">Add an email reply-to address</a>'.format( 'Add an email reply-to address',
url_for('main.service_email_reply_to', service_id=current_service.id) url_for('main.service_email_reply_to', service_id=current_service.id),
)|safe,
) }} ) }}
{% endif %} {% endif %}
{% if current_service.has_sms_templates and current_service.shouldnt_use_govuk_as_sms_sender %} {% if current_service.has_sms_templates and current_service.shouldnt_use_govuk_as_sms_sender %}
{{ task_list_item( {{ task_list_item(
not current_service.sms_sender_is_govuk, not current_service.sms_sender_is_govuk,
'<a href="{}">Change your text message sender name</a>'.format( 'Change your text message sender name',
url_for('main.service_sms_senders', service_id=current_service.id) url_for('main.service_sms_senders', service_id=current_service.id),
)|safe
) }} ) }}
{% endif %} {% endif %}
{% endcall %} {% endcall %}

View File

@@ -206,6 +206,10 @@ def email_safe(string, whitespace='.'):
return string.strip('.') return string.strip('.')
def id_safe(string):
return email_safe(string, whitespace='-')
class Spreadsheet(): class Spreadsheet():
allowed_file_extensions = ['csv', 'xlsx', 'xls', 'ods', 'xlsm', 'tsv'] allowed_file_extensions = ['csv', 'xlsx', 'xls', 'ods', 'xlsm', 'tsv']