mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 20:01:01 -05:00
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
198 lines
6.6 KiB
HTML
198 lines
6.6 KiB
HTML
{% from "components/big-number.html" import big_number %}
|
|
|
|
{% macro mapping_table(caption='', field_headings=[], field_headings_visible=True, caption_visible=True, equal_length=False) -%}
|
|
<table class="table table-font-xsmall">
|
|
<caption class="heading-medium table-heading{{ ' govuk-visually-hidden' if not caption_visible}}">
|
|
{{ caption }}
|
|
</caption>
|
|
<thead class="table-field-headings{% if field_headings_visible %}-visible{% endif %}">
|
|
<tr>
|
|
{% for field_heading in field_headings %}
|
|
<th scope="col" class="table-field-heading{% if loop.first %}-first{% endif %}" width="{% if equal_length %}{{ (100 / field_headings|length)|int }}%{% endif %}">
|
|
{% if field_headings_visible %}
|
|
{{ field_heading }}
|
|
{% else %}
|
|
<span class="govuk-visually-hidden">{{ field_heading }}</span>
|
|
{% endif %}
|
|
</th>
|
|
{% endfor %}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{ caller() }}
|
|
</tbody>
|
|
</table>
|
|
{%- endmacro %}
|
|
|
|
{% macro list_table(items, caption='', empty_message='', field_headings=[], field_headings_visible=True, caption_visible=True, equal_length=False) -%}
|
|
{% set parent_caller = caller %}
|
|
|
|
{% call mapping_table(caption, field_headings, field_headings_visible, caption_visible, equal_length) %}
|
|
{% for item in items %}
|
|
{% call row(item.id) %}
|
|
{{ parent_caller(item, loop.index + 1) }}
|
|
{% endcall %}
|
|
{% endfor %}
|
|
{% if not items %}
|
|
{% call row() %}
|
|
<td class="table-empty-message" colspan="10">
|
|
{{ empty_message }}
|
|
</td>
|
|
{% endcall %}
|
|
{% endif %}
|
|
{%- endcall %}
|
|
|
|
{%- endmacro %}
|
|
|
|
{% macro row(id=None) -%}
|
|
<tr class="table-row" {% if id and id is string %}id="{{id}}"{% endif %}>
|
|
{{ caller() }}
|
|
</tr>
|
|
{%- endmacro %}
|
|
|
|
{% macro row_group(id=None) %}
|
|
<tbody class="table-row-group" {% if id %}id="{{id}}"{% endif %}>
|
|
{{ caller() }}
|
|
</tbody>
|
|
{%- endmacro %}
|
|
|
|
{% macro settings_row(if_has_permission='') -%}
|
|
{% set parent_caller = caller %}
|
|
{% if if_has_permission in current_service.permissions %}
|
|
{% call row() %}
|
|
{{ parent_caller() }}
|
|
{% endcall %}
|
|
{% endif %}
|
|
{%- endmacro %}
|
|
|
|
{% 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(' ') }}" {% if colspan %}colspan="{{ colspan }}"{% endif %}>
|
|
<div class="{{ 'table-field-status-' + status if status }}">{{ caller() }}</div>
|
|
</td>
|
|
{%- endmacro %}
|
|
|
|
{% macro row_heading() -%}
|
|
<th class="table-field">
|
|
{{ caller() }}
|
|
</th>
|
|
{%- endmacro %}
|
|
|
|
{% 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 %}
|
|
|
|
{% macro text_field(text, status='', truncate=false) -%}
|
|
{% call field(status=status) %}
|
|
{% if text is iterable and text is not string %}
|
|
<ul>
|
|
{% for item in text %}
|
|
{% if item %}
|
|
<li>{{ item }}</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
{% if truncate %}
|
|
<div class="truncate-text" title="{{ text }}">{{text}}</div>
|
|
{% else %}
|
|
{{ text }}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endcall %}
|
|
{%- endmacro %}
|
|
|
|
{% macro optional_text_field(text, default='Not set', truncate=false) -%}
|
|
{{ text_field(
|
|
text or default,
|
|
status='' if text else 'default',
|
|
truncate=truncate
|
|
) }}
|
|
{%- endmacro %}
|
|
|
|
{% macro link_field(text, link) -%}
|
|
{% call field() %}
|
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">{{ text }}</a>
|
|
{% endcall %}
|
|
{%- endmacro %}
|
|
|
|
{% macro edit_field(text, link, permissions=[]) -%}
|
|
{% call field(align='right') %}
|
|
{% if not permissions or current_user.has_permissions(*permissions) %}
|
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ link }}">{{ text }}</a>
|
|
{% endif %}
|
|
{% endcall %}
|
|
{%- endmacro %}
|
|
|
|
{% macro boolean_field(value) -%}
|
|
{{ text_field('On' if value else 'Off') }}
|
|
{%- endmacro %}
|
|
|
|
{% macro right_aligned_field_heading(text) %}
|
|
<span class="table-field-heading-right-aligned">{{ text }}</span>
|
|
{%- endmacro %}
|
|
|
|
{% macro hidden_field_heading(text) %}
|
|
<span class="govuk-visually-hidden">{{ text }}</span>
|
|
{%- endmacro %}
|
|
|
|
|
|
{% macro notification_status_field(notification) %}
|
|
|
|
{% set displayed_on_single_line = notification.status in ['created', 'pending', 'pending-virus-check', 'sending', 'sent', 'delivered', 'returned-letter', 'accepted', 'received'] %}
|
|
|
|
{% if not notification %}
|
|
{% call field(align='right') %}{% endcall %}
|
|
{% else %}
|
|
{% set status = notification.status|format_notification_status_as_field_status(notification.notification_type) %}
|
|
{% call field(
|
|
status=status,
|
|
align='right'
|
|
) %}
|
|
{% if displayed_on_single_line %}<span class="align-with-message-body">{% endif %}
|
|
{% if notification.status|format_notification_status_as_url(notification.notification_type) %}
|
|
<a class="govuk-link govuk-link--{% if status == 'error' %}destructive{% else %}no-visited-state{% endif %}" href="{{ notification.status|format_notification_status_as_url(notification.notification_type) }}">
|
|
{% endif %}
|
|
{{ notification.status|format_notification_status(notification.template.template_type) }}
|
|
{% if notification.status|format_notification_status_as_url(notification.notification_type) %}
|
|
</a>
|
|
{% endif %}
|
|
<span class="status-hint">
|
|
{% if notification['notification_type'] == "letter" %}
|
|
{% if notification.status == 'permanent-failure' %}
|
|
{{ (notification.updated_at)|format_datetime_short }}
|
|
{% else %}
|
|
{{ (notification.created_at)|format_datetime_short }}
|
|
{% endif %}
|
|
{% else %}
|
|
{{ notification.status|format_notification_status_as_time(
|
|
notification.created_at|format_datetime_short,
|
|
(notification.updated_at or notification.created_at)|format_datetime_short
|
|
) }}
|
|
{% endif %}
|
|
</span>
|
|
{% if displayed_on_single_line %}</span>{% endif %}
|
|
{% endcall %}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
|
|
{% macro spark_bar_field(
|
|
count,
|
|
max_count,
|
|
id=None
|
|
) %}
|
|
{% call field(align='right') %}
|
|
<span {% if id %}id="{{ id }}"{% endif %} class="spark-bar">
|
|
<span class="spark-bar-bar" style="width: {{ count / max_count * 100 }}%">
|
|
{{ '{:,.0f}'.format(count) }}
|
|
</span>
|
|
</span>
|
|
{% endcall %}
|
|
{% endmacro %}
|