Projet

Général

Profil

0001-misc-add-aria-attributes-to-steps-markup-40934.patch

Frédéric Péters, 23 mars 2020 20:24

Télécharger (2,33 ko)

Voir les différences:

Subject: [PATCH] misc: add aria attributes to steps markup (#40934)

 wcs/forms/root.py                     |  4 ++++
 wcs/templates/wcs/formdata_steps.html | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
wcs/forms/root.py
266 266
        get_logger().info('form %s - step %s' % (self.formdef.name, step_no))
267 267

  
268 268
        page_labels = []
269
        current_page_label = None
269 270
        current_position = 1
270 271

  
271 272
        for i, page in enumerate(self.pages):
......
275 276
                page_labels.append(page.label)
276 277
            if page is current_page:
277 278
                current_position = i + 1
279
                if page is not None:
280
                    current_page_label = page.label
278 281

  
279 282
        if step_no > 0:
280 283
            current_position = len(page_labels) + step_no
......
289 292
                list(self.get_formdef_template_variants(self.steps_templates)),
290 293
                {
291 294
                  'page_labels': page_labels,
295
                  'current_page_label': current_page_label,
292 296
                  'current_page_no': current_position,
293 297
                })
294 298

  
wcs/templates/wcs/formdata_steps.html
1
<div id="steps" class="steps-{{page_labels|length}}">
1
{% load i18n %}
2
<div id="steps" class="steps-{{page_labels|length}}"
3
   role="progressbar"
4
   aria-valuenow="{{ current_page_no }}"
5
   aria-valuemin="1"
6
   aria-valuemax="{{ page_labels|length }}"
7
   {% if current_page_label %}
8
   aria-valuetext="{% blocktrans %}Step #{{ current_page_no }}: {{ current_page_label }}{% endblocktrans %}"
9
   {% else %}
10
   aria-valuetext="{% blocktrans %}Step #{{ current_page_no }}{% endblocktrans %}"
11
   {% endif %}
12
>
2 13
<ol>
3 14
{% for page_label in page_labels %}
4 15
{% spaceless %}
5
-