75 lines
3.1 KiB
Twig
75 lines
3.1 KiB
Twig
<tbody>
|
||
{% if items is defined and items|length > 0 %}
|
||
{% for item in items %}
|
||
<tr{% if onRowClick is defined and onRowClick %} onclick="{{ onRowClick }}({{ item.id }})" style="cursor: pointer;"{% endif %}>
|
||
{# Рендерим каждую колонку #}
|
||
{% for key, column in columns %}
|
||
<td>
|
||
{{ render_cell(item, key, column)|raw }}
|
||
</td>
|
||
{% endfor %}
|
||
|
||
{# Колонка действий #}
|
||
{% if actionsConfig is defined and actionsConfig|length > 0 %}
|
||
<td class="actions-cell text-end"{% if onRowClick is defined and onRowClick %} onclick="event.stopPropagation();"{% endif %}>
|
||
{# Фильтруем действия на основе прав доступа #}
|
||
{% set visibleActions = [] %}
|
||
{% for action in actionsConfig %}
|
||
{% set showAction = true %}
|
||
{% if action.type is defined %}
|
||
{% if action.type == 'edit' and not (can_edit|default(true)) %}
|
||
{% set showAction = false %}
|
||
{% elseif action.type == 'delete' and not (can_delete|default(true)) %}
|
||
{% set showAction = false %}
|
||
{% endif %}
|
||
{% endif %}
|
||
{% if showAction %}
|
||
{% set visibleActions = visibleActions|merge([action]) %}
|
||
{% endif %}
|
||
{% endfor %}
|
||
|
||
{% if visibleActions|length > 0 %}
|
||
{{ render_actions(item, visibleActions)|raw }}
|
||
{% else %}
|
||
<span class="text-muted small">—</span>
|
||
{% endif %}
|
||
</td>
|
||
{% endif %}
|
||
</tr>
|
||
{% endfor %}
|
||
{% else %}
|
||
{# Пустое состояние #}
|
||
<tr>
|
||
<td colspan="{{ columns|length + (actions is defined and actions ? 1 : 0) }}"
|
||
class="text-center py-5">
|
||
{% if emptyIcon is defined and emptyIcon %}
|
||
<div class="mb-3">
|
||
<i class="{{ emptyIcon }} text-muted" style="font-size: 3rem;"></i>
|
||
</div>
|
||
{% endif %}
|
||
<p class="text-muted mb-3">{{ emptyMessage|default('Нет данных') }}</p>
|
||
{% if emptyActionUrl is defined and emptyActionUrl %}
|
||
<a href="{{ emptyActionUrl }}" class="btn btn-primary">
|
||
{% if emptyActionIcon is defined and emptyActionIcon %}
|
||
<i class="{{ emptyActionIcon }} me-2"></i>
|
||
{% endif %}
|
||
{{ emptyActionLabel|default('Добавить') }}
|
||
</a>
|
||
{% endif %}
|
||
</td>
|
||
</tr>
|
||
{% endif %}
|
||
</tbody>
|
||
|
||
{# Футер с пагинацией #}
|
||
<tfoot>
|
||
<tr>
|
||
<td colspan="{{ columns|length + 1 }}">
|
||
{{ include('@components/table/pagination.twig', {
|
||
pagination: pagerDetails,
|
||
id: id
|
||
}) }}
|
||
</td>
|
||
</tr>
|
||
</tfoot>
|