Files
notifications-admin/app/templates/components/table.html
Leo Hemsted 816ba32b25 add id field containg obj id to table if available
useful for finding out a notification ID when investigating support issues
2016-09-09 15:50:55 +01:00

107 lines
2.9 KiB
HTML

{% macro mapping_table(caption='', field_headings=[], field_headings_visible=True, caption_visible=True) -%}
<table class="table">
<caption class="heading-medium table-heading{{ ' visuallyhidden' 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 %}">
{% if field_headings_visible %}
{{ field_heading }}
{% else %}
<span class="visuallyhidden">{{ 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) -%}
{% set parent_caller = caller %}
{% call mapping_table(caption, field_headings, field_headings_visible, caption_visible) %}
{% 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 %}id="{{id}}"{% endif %}>
{{ caller() }}
</tr>
{%- endmacro %}
{% 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>
</td>
{%- endmacro %}
{% macro row_heading() -%}
<th class="table-field">
<span>{{ caller() }}</span>
</th>
{%- endmacro %}
{% macro index_field(text) -%}
<td class="table-field-index">
<span>{{ text }}</span>
</td>
{%- endmacro %}
{% macro date_field(text) -%}
<td class="table-field-date">
<span>{{ text }}</span>
</td>
{% endmacro %}
{% macro text_field(text, status='') -%}
{% call field(status=status) %}
{{ text }}
{% endcall %}
{%- endmacro %}
{% macro link_field(text, link) -%}
{% call field() %}
<a href="{{ link }}">{{ text }}</a>
{% endcall %}
{%- endmacro %}
{% macro edit_field(text, link) -%}
{% call field(align='right') %}
<a href="{{ link }}">{{ text }}</a>
{% endcall %}
{%- endmacro %}
{% macro boolean_field(yes) -%}
{% call field(status='yes' if yes else 'no') %}
{{ "Yes" if yes else "No" }}
{% endcall %}
{%- endmacro %}
{% macro right_aligned_field_heading(text) %}
<span class="table-field-heading-right-aligned">{{ text }}</span>
{%- endmacro %}
{% macro hidden_field_heading(text) %}
<span class="visuallyhidden">{{ text }}</span>
{%- endmacro %}