Files
notifications-admin/app/templates/components/table.html
T

101 lines
2.7 KiB
HTML
Raw Normal View History

2016-01-07 12:29:56 +00:00
{% macro mapping_table(caption='', field_headings=[], field_headings_visible=True, caption_visible=True) -%}
2015-12-10 17:54:05 +00:00
<table class="table">
2015-12-17 11:52:24 +00:00
<caption class="heading-medium table-heading{{ ' visuallyhidden' if not caption_visible}}">
2015-12-10 17:54:05 +00:00
{{ 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 %}">
{% if field_headings_visible %}
{{ field_heading }}
{% else %}
<span class="visuallyhidden">{{ field_heading }}</span>
{% endif %}
</th>
{% endfor %}
</tr>
</thead>
<tbody>
2016-01-07 12:29:56 +00:00
{{ caller() }}
2015-12-10 17:54:05 +00:00
</tbody>
</table>
{%- endmacro %}
2016-01-07 12:29:56 +00:00
{% macro list_table(items, caption='', empty_message='', field_headings=[], field_headings_visible=True, caption_visible=True) -%}
{% set parent_caller = caller %}
2016-02-03 14:43:16 +00:00
{% call mapping_table(caption, field_headings, field_headings_visible, caption_visible) %}
{% for item in items %}
{% call row() %}
2016-04-05 11:16:29 +01:00
{{ parent_caller(item, loop.index + 1) }}
2016-02-03 14:43:16 +00:00
{% endcall %}
{% endfor %}
{% if not items %}
{% call row() %}
<td class="table-empty-message" colspan="10">
{{ empty_message }}
</td>
{% endcall %}
{% endif %}
{%- endcall %}
2016-01-07 12:29:56 +00:00
{%- endmacro %}
{% macro row() -%}
<tr class="table-row">
{{ caller() }}
</tr>
{%- endmacro %}
2015-12-17 11:14:19 +00:00
{% macro field(align='left', status='') -%}
<td class="table-field{% if align == 'right' %}-right-aligned{% endif %}">
<span class="{{ 'table-field-status-' + status if status }}">{{ caller() }}</span>
2015-12-10 17:54:05 +00:00
</td>
{%- endmacro %}
2015-12-17 11:14:19 +00:00
2016-06-08 13:41:02 +01:00
{% macro row_heading() -%}
<th class="table-field">
<span>{{ caller() }}</span>
</th>
{%- endmacro %}
2016-04-05 11:16:29 +01:00
{% macro index_field(text) -%}
<td class="table-field-index">
<span>{{ text }}</span>
</td>
{%- endmacro %}
2016-06-08 13:41:02 +01:00
{% macro date_field(text) -%}
<td class="table-field-date">
<span>{{ text }}</span>
</td>
{% endmacro %}
2016-02-19 15:02:13 +00:00
{% macro text_field(text) -%}
{% call field() %}
{{ text }}
{% endcall %}
{%- endmacro %}
2016-04-12 15:05:27 +01:00
{% macro link_field(text, link) -%}
{% call field() %}
<a href="{{ link }}">{{ text }}</a>
{% endcall %}
{%- endmacro %}
2016-02-19 15:02:13 +00:00
{% macro boolean_field(yes) -%}
{% call field(status='yes' if yes else 'no') %}
{{ "Yes" if yes else "No" }}
{% endcall %}
{%- endmacro %}
2015-12-17 11:14:19 +00:00
{% macro right_aligned_field_heading(text) %}
<span class="table-field-heading-right-aligned">{{ text }}</span>
{%- endmacro %}
2016-01-19 09:55:13 +00:00
{% macro hidden_field_heading(text) %}
<span class="visuallyhidden">{{ text }}</span>
{%- endmacro %}