From f37137cdb380df289e9fcbe5068a05f0e3f667ac Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Sat, 11 Apr 2020 11:07:20 +0100 Subject: [PATCH] Convert list table to mapping table A list table takes a list of input, and assumes one row of output. In order to show errors that span multiple rows we need to output two rows for one item of input. The list table inherits from the mapping table; using the mapping table directly gives us the flexibility we need. --- app/templates/views/check/row-errors.html | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/app/templates/views/check/row-errors.html b/app/templates/views/check/row-errors.html index 69b6bc373..b29aa88d9 100644 --- a/app/templates/views/check/row-errors.html +++ b/app/templates/views/check/row-errors.html @@ -1,7 +1,7 @@ {% extends "withnav_template.html" %} {% from "components/banner.html" import banner_wrapper %} {% from "components/radios.html" import radio_select %} -{% from "components/table.html" import list_table, field, text_field, index_field, hidden_field_heading %} +{% from "components/table.html" import mapping_table, row, field, text_field, index_field, hidden_field_heading %} {% from "components/file-upload.html" import file_upload %} {% from "components/back-link/macro.njk" import govukBackLink %} {% from "components/message-count-label.html" import message_count_label %} @@ -59,38 +59,41 @@
- {% call(item, row_number) list_table( - recipients.displayed_rows, + {% call(item, row_number) mapping_table( caption=original_file_name, caption_visible=False, field_headings=[ 'Row in file'|safe ] + recipients.column_headers ) %} - {% call index_field() %} - - {{ item.index + 2 }} - - {% endcall %} - {% for column in recipients.column_headers %} - {% if item[column].error and not recipients.missing_column_headers %} - {% call field() %} - - {{ item[column].error }} - {{ item[column].data if item[column].data != None }} + {% for item in recipients.displayed_rows %} + {% call row(item.id) %} + {% call index_field() %} + + {{ item.index + 2 }} {% endcall %} - {% elif item[column].ignore %} - {{ text_field(item[column].data or '', status='default') }} - {% else %} - {{ text_field(item[column].data or '') }} - {% endif %} + {% for column in recipients.column_headers %} + {% if item[column].error and not recipients.missing_column_headers %} + {% call field() %} + + {{ item[column].error }} + {{ item[column].data if item[column].data != None }} + + {% endcall %} + {% elif item[column].ignore %} + {{ text_field(item[column].data or '', status='default') }} + {% else %} + {{ text_field(item[column].data or '') }} + {% endif %} + {% endfor %} + {% if item[None].data %} + {% for column in item[None].data %} + {{ text_field(column, status='default') }} + {% endfor %} + {% endif %} + {% endcall %} {% endfor %} - {% if item[None].data %} - {% for column in item[None].data %} - {{ text_field(column, status='default') }} - {% endfor %} - {% endif %} {% endcall %}
{% if count_of_displayed_recipients < count_of_recipients %}