deblan.io-murph/core/Resources/views/admin/crud/index.html.twig

181 lines
10 KiB
Twig

{% extends '@Core/admin/layout.html.twig' %}
{% block title %}{{ configuration.pageTitle('index')|trans }} - {{ parent() }}{% endblock %}
{% block body %}
{% block header %}
<div class="bg-light pl-5 pr-4 pt-5 {% if pager.paginationData.pageCount < 2 %}{% if filters.show %}pb-3{% else %}pb-5{% endif %}{% endif %}">
<div class="crud-header">
{% block header_title %}
<h1 class="crud-header-title">{{ configuration.pageTitle('index')|trans }}</h1>
{% endblock %}
{% block header_actions %}
<div class="crud-header-actions">
<div class="btn-group">
{% if configuration.action('index', 'new', true) %}
<a href="{{ path(configuration.pageRoute('new')) }}" class="btn btn-primary">
<span class="fa fa-plus pr-1"></span>
{{ configuration.actionTitle('index', 'new', 'New')|trans }}
</a>
{% endif %}
</div>
</div>
{% endblock %}
</div>
{% block header_filter_pager %}
{% if filters.show %}
<div class="row pb-3">
<div class="col-auto ml-auto {% if pager.getPaginationData.pageCount > 1 %}mr-3{% endif %}">
<button data-modal="{{ path(configuration.pageRoute('filter')) }}" class="btn btn-sm btn-secondary">
{{ 'Filter'|trans }} {% if not filters.isEmpty %}({{ 'yes'|trans }}){% endif %}
</button>
</div>
<div class="col-auto">
{{ knp_pagination_render(pager) }}
</div>
</div>
{% else %}
{{ knp_pagination_render(pager) }}
{% endif %}
{% endblock %}
</div>
{% endblock %}
{% block list %}
<div class="table-responsive">
<table class="table">
{% block list_header %}
<thead class="thead-light">
<tr>
{% for label, config in configuration.fields('index') %}
{% set attr = config.options.attr is defined ? config.options.attr : [] %}
{% set isSortable = config.options.sort ?? false %}
<th {% for key, value in attr %}{{ key }}="{{ value }}"{% endfor %}>
{% if isSortable %}
{% if sort %}
{% if sort.label == label %}
{% if sort.direction == 'asc' %}
{% set newDirection = 'desc' %}
{% set icon = 'fa fa-sort-amount-down-alt' %}
{% else %}
{% set newDirection = 'asc' %}
{% set icon = 'fa fa-sort-amount-up-alt' %}
{% endif %}
{% set url = path(configuration.getPageRoute('index'), {
_sort: config.options.sort[0],
_sort_direction: newDirection,
}) %}
{% else %}
{% set url = path(configuration.getPageRoute('index'), {
_sort: config.options.sort[0],
_sort_direction: 'asc',
}) %}
{% set icon = null %}
{% endif %}
<a href="{{ url }}">
{% if icon is defined %}
<span class="{{ icon }}"></span>
{% endif %}
{{ label|trans }}
</a>
{% else %}
{{ label|trans }}
{% endif %}
{% else %}
{{ label|trans }}
{% endif %}
</th>
{% endfor %}
<th class="col-2 miw-100 text-right">
{{ 'Actions'|trans }}
</th>
</tr>
</thead>
{% endblock %}
{% block list_items %}
<tbody>
{% for item in pager %}
{% block list_item %}
{%- set dbClick %}
{% if configuration.action('index', 'show', true) %}
{{ path(configuration.pageRoute('show'), {entity: item.id}) }}
{% elseif configuration.action('index', 'edit', true) %}
{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}
{% endif %}
{% endset -%}
<tr data-dblclick="{{ dbClick }}">
{% for config in configuration.fields('index') %}
{% set attr = config.options.attr is defined ? config.options.attr : [] %}
{% set action = config.options.action is defined ? config.options.action : null %}
<td {% for key, value in attr %}{{ key }}="{{ value }}"{% endfor %}>
{% if action == 'show' %}
<a href="{{ path(configuration.pageRoute('show'), {entity: item.id}) }}">
{{ render_field(item, config, configuration.defaultLocale) }}
</a>
{% elseif action == 'edit' %}
<a href="{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}">
{{ render_field(item, config, configuration.defaultLocale) }}
</a>
{% else %}
{{ render_field(item, config, configuration.defaultLocale) }}
{% endif %}
</td>
{% endfor %}
{% if configuration.action('index', 'show', true) or configuration.action('index', 'edit', true) or configuration.action('index', 'delete', true) %}
<td class="col-2 miw-100 text-right">
{% if configuration.action('index', 'show', true) %}
<a href="{{ path(configuration.pageRoute('show'), {entity: item.id}) }}" class="btn btn-sm btn-secondary mr-1">
<span class="fa fa-eye"></span>
</a>
{% endif %}
{% if configuration.action('index', 'edit', true) %}
<a href="{{ path(configuration.pageRoute('edit'), {entity: item.id}) }}" class="btn btn-sm btn-primary mr-1">
<span class="fa fa-edit"></span>
</a>
{% endif %}
{% if configuration.action('index', 'delete', true) %}
<button type="submit" form="form-delete-{{ item.id }}" class="btn btn-sm btn-danger">
<span class="fa fa-trash"></span>
</button>
<form method="post" action="{{ path(configuration.pageRoute('delete'), {entity: item.id}) }}" id="form-delete-{{ item.id }}" data-form-confirm>
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ item.id) }}">
</form>
{% endif %}
</td>
{% endif %}
</tr>
{% endblock %}
{% else %}
<tr>
<td class="col-12 text-center p-4 text-black-50" colspan="{{ configuration.fields('index')|length + 1 }}">
<div class="display-1">
<span class="fa fa-search"></span>
</div>
<div class="display-5 mt-3">
Aucun résultat
</div>
</td>
</tr>
{% endfor %}
</tbody>
{% endblock %}
</table>
</div>
{% endblock %}
{% endblock %}