{% from "components/primitives/canonical_table.html" import canonical_table %} {% set tb = block.toolbar %} {% set has_toolbar = tb.search or tb.entries or tb.actions or tb.fields or tb.hidden or tb.column_toggles or tb.reset or tb.apply %} {% macro column_chooser(toggles, locale) %} {% endmacro %} {% call canonical_table(title=block.title, description=block.description, pagination=block.pagination) %} {% if has_toolbar %}
{% if tb.hidden %}{% for hname, hvalue in tb.hidden.items() %}{% endfor %}{% endif %}
{% if tb.entries %}
{% if locale == 'ru' %}Показать{% else %}Show{% endif %} {% if locale == 'ru' %}записей{% else %}entries{% endif %}
{% endif %} {% set chooser = namespace(rendered=false) %} {% for field in tb.fields %} {% if field.type == "date_range" %}
{% if field.label %}{% endif %}
{% elif field.type == "text" %} {% if tb.column_toggles and not chooser.rendered %}{{ column_chooser(tb.column_toggles, locale) }}{% set chooser.rendered = true %}{% endif %} {% elif field.type == "select" %} {% elif field.type == "checkboxes" %} {% endif %} {% endfor %} {% if tb.column_toggles and not chooser.rendered %}{{ column_chooser(tb.column_toggles, locale) }}{% endif %}
{% for action in tb.actions %} {% if action.href %}{{ action.label }}{% else %}{{ action.label }}{% endif %} {% endfor %} {% if tb.search %} {% endif %} {% if tb.reset and tb.reset.href %}{{ tb.reset.label }}{% endif %} {% if tb.apply %}{% endif %}
{% endif %}
{% if block.columns %} {% if block.selectable %}{% endif %} {% for col in block.columns %} {% if col.sortable and col.sort_href %}{{ col.label }}{% if col.sort_active %}{% endif %} {% else %}{{ col.label }}{% endif %} {% endfor %} {% for row in block.rows %} {% if block.selectable %}{% endif %} {% for col in block.columns %} {% set cell = row.get(col.key, {}) %} {% if cell.type == "text" %} {% if cell.tone %}{{ cell.value }}{% else %}{{ cell.value }}{% endif %} {% elif cell.type == "link" %} {% if cell.href %}{{ cell.label }}{% else %}{{ cell.label }}{% endif %} {% elif cell.type == "badge" %} {{ cell.label }} {% elif cell.type == "status" %} {{ cell.label }} {% elif cell.type == "avatar_text" %}
{% if cell.initials %}{{ cell.initials }}{% else %}?{% endif %}
{{ cell.title }}
{% if cell.subtitle %}
{{ cell.subtitle }}
{% endif %}
{% elif cell.type == "progress" %}
{{ cell.label }}
{% elif cell.type == "actions" %}
{% for action in cell.get("items", []) %} {% if action.href %}{{ action.label }}{% else %}{{ action.label }}{% endif %} {% endfor %}
{% else %} {{ cell.value if cell.value else ("н/д" if locale == 'ru' else "n/a") }} {% endif %} {% endfor %}
{% endfor %} {% endif %}
{% endcall %}