Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility improvements for submission report pdf #5099

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/openforms/formio/formatters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ def __call__(self, component: ComponentT, value: Any) -> str:
# note all this depends on value not being unexpected type or shape
values = self.normalise_value_to_list(component, value)

formatted_values = (
formatted_values = list(
force_str(self.format(component, value)) for value in values
)

# Check if formatted_values isn't empty
if len(formatted_values) == 0:
return self.process_result(component, "")

# logically we'd want a .filter_formatted_values() step here
return self.process_result(
component, self.join_formatted_values(component, formatted_values)
Expand Down
2 changes: 2 additions & 0 deletions src/openforms/formio/formatters/formio.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def format(self, component: SelectBoxesComponent, value: dict[str, bool]) -> str
# For the html output, wrap the values in li tags and put it inside an ul tag.
# The selectboxes formatter handles all values at the same time,
# so handle the full html formatting here.
if not selected_labels:
return ""
return format_html(
"<ul>{values}</ul>",
values=format_html_join(
Expand Down
36 changes: 22 additions & 14 deletions src/openforms/submissions/templates/report/submission_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
<html lang="{{ LANG }}" class="{{ theme.get_classname }}">
<head>
<meta charset="utf-8">
<title>{% block title %}
{% blocktrans with form_name=report.form.name trimmed %}
{{ form_name }}: PDF report
{% endblocktrans %}
{% endblock %}</title>
<title>{% spaceless %}
{% block title %}
{% blocktrans with form_name=report.form.name trimmed %}
{{ form_name }}: PDF report
{% endblocktrans %}
{% endblock %}
{% endspaceless %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{% static 'bundles/pdf-css.css' %}" media="all" rel="stylesheet" />
{% block extra_css %}{% endblock %}
Expand Down Expand Up @@ -65,7 +67,7 @@ <h1 class="title">{{ report.form.name }}</h1>

{% for submission_step_node in report.renderer.get_children %}
{% if submission_step_node.has_children %}
<div class="submission-step">
<section class="submission-step">
<h2 class="subtitle">{{ submission_step_node.render }}</h2>
{% for component_node in submission_step_node.get_children %}
{% if component_node.label or component_node.display_value %}
Expand All @@ -76,19 +78,25 @@ <h2 class="subtitle">{{ submission_step_node.render }}</h2>
{% if component_node.component.type == "fieldset" %}
<span class="submission-step-row__fieldset-label">{{ component_node.label }}</span>
{% else %}
<div class="submission-step-row__label">
{{ component_node.label }}
</div>

<div class="submission-step-row__value{% if not component_node.display_value %} submission-step-row__value--empty{% endif %}">
{{ component_node.display_value|default:"" }}
</div>
{% with node_path=component_node.configuration_path|add:'.'|add:component_node.key %}
<span id="{{ node_path }}" class="submission-step-row__label">
{{ component_node.label }}
</span>

<div aria-labelledby="{{ node_path }}" class="submission-step-row__value{% if not component_node.display_value %} submission-step-row__value--empty{% endif %}">
{% if component_node.display_value %}
{{ component_node.display_value }}
{% elif not component_node.layout_modifier %}
{% trans "No information provided" %}
{% endif %}
</div>
{% endwith %}
{% endif %}
{% endif %}
</div>
{% endif %}
{% endfor %}
</div>
</section>
{% endif %}
{% endfor %}

Expand Down
Loading