mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-30 11:19:44 -04:00
Show error across the whole row
Errors with messages being too long or empty aren’t specific to a single cell of the uploaded spreadsheet, they’re the results of combining all the cells with the template. Previously we could only show errors against a specific cell. This commit makes it possible to add a super-row which spans all the cells, into which we can put errors. The index (header) column then spans both these rows, to show that they are both associated with the same row of input. Depends on: - [x] https://github.com/alphagov/notifications-utils/pull/719
This commit is contained in:
@@ -65,12 +65,12 @@
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro field(align='left', status='', border=True) -%}
|
||||
{% macro field(align='left', status='', border=True, colspan=None) -%}
|
||||
|
||||
{% set field_alignment = 'table-field-right-aligned' if align == 'right' else 'table-field-left-aligned' %}
|
||||
{% set border = '' if border else 'table-field-noborder' %}
|
||||
|
||||
<td class="{{ [field_alignment, border]|join(' ') }}">
|
||||
<td class="{{ [field_alignment, border]|join(' ') }}" {% if colspan %}colspan="{{ colspan }}"{% endif %}>
|
||||
<div class="{{ 'table-field-status-' + status if status }}">{{ caller() }}</div>
|
||||
</td>
|
||||
{%- endmacro %}
|
||||
@@ -81,8 +81,8 @@
|
||||
</th>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro index_field(text=None) -%}
|
||||
<td class="table-field-index">
|
||||
{% macro index_field(text=None, rowspan=None) -%}
|
||||
<td class="table-field-index" {% if rowspan %}rowspan="{{ rowspan }}"{% endif %}>
|
||||
{{ text if text != None else caller() }}
|
||||
</td>
|
||||
{%- endmacro %}
|
||||
|
||||
@@ -67,12 +67,32 @@
|
||||
] + recipients.column_headers
|
||||
) %}
|
||||
{% for item in recipients.displayed_rows %}
|
||||
{% call row(item.id) %}
|
||||
{% call index_field() %}
|
||||
<span class="{% if item.has_errors %}table-field-error{% endif %}">
|
||||
{{ item.index + 2 }}
|
||||
</span>
|
||||
{% if item.has_error_spanning_multiple_cells %}
|
||||
{% call row() %}
|
||||
{% call index_field(rowspan=2) %}
|
||||
<span class="table-field-error">
|
||||
{{ item.index + 2 }}
|
||||
</span>
|
||||
{% endcall %}
|
||||
{% call field(colspan=recipients.column_headers|length) %}
|
||||
<span class="table-field-error-label">
|
||||
{% if item.message_empty %}
|
||||
No content for this message
|
||||
{% elif item.message_too_long %}
|
||||
Message is too long
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
{% call row(item.id) %}
|
||||
{% if not item.has_error_spanning_multiple_cells %}
|
||||
{% call index_field() %}
|
||||
<span class="{% if item.has_errors %}table-field-error{% endif %}">
|
||||
{{ item.index + 2 }}
|
||||
</span>
|
||||
{% endcall %}
|
||||
{% endif %}
|
||||
{% for column in recipients.column_headers %}
|
||||
{% if item[column].error and not recipients.missing_column_headers %}
|
||||
{% call field() %}
|
||||
|
||||
Reference in New Issue
Block a user