{% set _entity_config = easyadmin_entity(app.request.query.get('entity')) %}
{% trans_default_domain _entity_config.translation_domain %}
{% set _trans_parameters = { '%entity_name%': _entity_config.name|trans, '%entity_label%': _entity_config.label|trans } %}
{% extends '@!EasyAdmin/default/list.html.twig' %}
{% set _request_parameters = app.request.query.all|merge(_request_parameters|default({}))|merge({
action: app.request.get('action'),
entity: _entity_config.name,
menuIndex: app.request.get('menuIndex'),
submenuIndex: app.request.get('submenuIndex'),
sortField: app.request.get('sortField'),
sortDirection: app.request.get('sortDirection'),
page: app.request.get('page', 1),
filters: app.request.get('filters', []),
referer: null
}) %}
{% if 'search' == app.request.get('action') %}
{% set _request_parameters = _request_parameters|merge({
query: app.request.get('query')|default(''),
}) %}
{% endif %}
{% set _request_parameters = _request_parameters|merge({ referer: path('easyadmin', _request_parameters)|url_encode }) %}
{% set _has_batch_actions = batch_form is defined and batch_form.vars.batch_actions|length > 0 %}
{% set _has_filters = _entity_config.list.filters|default(false) %}
{% block global_actions %}
{% if easyadmin_action_is_enabled_for_list_view('new', _entity_config.name) %}
{% set _action = easyadmin_get_action_for_list_view('new', _entity_config.name) %}
{% block new_action %}
<a class="{{ _action.css_class|default('') }}" href="{{ path('easyadmin', _request_parameters|merge({ action: _action.name })) }}" target="{{ _action.target }}">
{% if _action.icon %}<i class="fa fa-fw fa-{{ _action.icon }}"></i>{% endif %}
{{ _action.label is defined and not _action.label is empty ? _action.label|trans(_trans_parameters) }}
</a>
{% endblock new_action %}
{% endif %}
{% endblock global_actions %}
{% block batch_actions %}
{% endblock batch_actions %}
{% block content_breadcrumb_link %}
{% set _default_title = 'list.page_title'|trans(_trans_parameters, 'EasyAdminBundle') %}
<li class="active"> {{ (_entity_config.list.title is defined ? _entity_config.list.title|trans(_trans_parameters) : _default_title)|raw }} </li>
{% endblock content_breadcrumb_link %}
{% block content_header_title %}
<i class="fa fa-{{ _entity_config.icon is defined ? _entity_config.icon : "cog" }}"></i>
{% apply spaceless %}
{% set _default_title = 'list.page_title'|trans(_trans_parameters, 'EasyAdminBundle') %}
{{ (_entity_config.list.title is defined ? _entity_config.list.title|trans(_trans_parameters) : _default_title)|raw }}
{% endapply %}
{% endblock %}
{% block main %}
{% set _fields_visible_by_user = fields|filter((metadata, field) => easyadmin_is_granted(metadata.permission)) %}
{% set _number_of_hidden_results = 0 %}
{% set _list_item_actions = easyadmin_get_actions_for_list_item(_entity_config.name) %}
<div class="panel">
<div class="panel-heading">
<div class="panel-control">
{{- block('global_actions') -}}
</div>
{% if _has_batch_actions %}
<div class="batch-actions" style="display: none; padding: 10px 15px; float: right;">
{% form_theme batch_form with easyadmin_config('design.form_theme') only %}
{{ form(batch_form) }}
{{ include('@EasyAdmin/default/includes/_batch_action_modal.html.twig', {
_translation_domain: _entity_config.translation_domain,
_trans_parameters: _trans_parameters,
_entity_config: _entity_config,
}, with_context = false) }}
</div>
{% endif %}
<h3 class="panel-title">{{- block('content_title') -}}</h3>
<div class="toast"> </div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-12 form-inline justify-content-end" style="margin-bottom: 15px;">
{% if easyadmin_action_is_enabled_for_list_view('search', _entity_config.name) %}
{% set _action = easyadmin_get_action_for_list_view('search', _entity_config.name) %}
{% block search_action %}
<div class="form-action form-action-search {{ _action.css_class|default('') }}" style="margin-right: 10px;">
<form method="get" action="{{ path('easyadmin') }}">
{% block search_form %}
<input type="hidden" name="action" value="search">
<input type="hidden" name="entity" value="{{ _request_parameters.entity }}">
{# if the Request query doesn't define 'sortField' and 'sortDirection', we add them in the
controller (but they don't appear in the request URI). When users click on a column to
sort results, 'sortField' and 'sortDirection' are added to the Request query and they
appear in the request URI too. So, checking if 'sortField' and 'sortDirection' is the
only way to differentiate between sorting made by user and sorting made by us. We only
need to persist the sorting if it's explicitly made by the user. #}
{% if 'sortField' in app.request.uri %}
<input type="hidden" name="sortField" value="{{ _request_parameters.sortField }}">
{% endif %}
{% if 'sortDirection' in app.request.uri %}
<input type="hidden" name="sortDirection" value="{{ _request_parameters.sortDirection }}">
{% endif %}
<input type="hidden" name="menuIndex" value="{{ _request_parameters.menuIndex }}">
<input type="hidden" name="submenuIndex" value="{{ _request_parameters.submenuIndex }}">
{% for name, value in _request_parameters.filters|easyadmin_form_hidden_params('filters') %}
<input type="hidden" name="{{ name }}" value="{{ value }}">
{% endfor %}
<div class="form-group">
<div class="form-widget">
<input class="form-control" type="search" name="query" value="{{ app.request.get('query')|default('') }}" placeholder="{{ _action.label|default('action.search')|trans(_trans_parameters) }}">
</div>
</div>
{% endblock %}
</form>
</div>
{% endblock search_action %}
{% endif %}
{% if _has_filters %}
{% set _applied_filters = app.request.attributes.get('easyadmin').filters.applied|default(false) %}
{% block filters_action %}
<div class="btn-group action-filters">
<a href="{{ path('easyadmin', _request_parameters|merge({ action: 'filters', referer_action: app.request.get('action') })) }}" class="btn btn-secondary btn-labeled-right action-filters-button {{ _applied_filters ? 'action-filters-applied' }}" data-modal="#modal-filters">
<i class="fa fa-filter fa-fw"></i> {{ 'filter.title'|trans(_trans_parameters, 'EasyAdminBundle') }}{% if _applied_filters %} <span class="text-primary">({{ _applied_filters|length }})</span>{% endif %}
</a>
{% if _applied_filters %}
<a href="{{ path('easyadmin', _request_parameters|merge({ filters: null })) }}" class="btn btn-secondary action-filters-reset">
<i class="fa fa-close"></i>
</a>
{% endif %}
</div>
{% endblock filters_action %}
{% endif %}
</div>
</div>
<table class="table table-striped table-bordered datagrid">
<thead>
{% block table_head %}
<tr>
{% if _has_batch_actions %}
<th width="1px"><span><input type="checkbox" class="form-batch-checkbox-all"></span></th>
{% endif %}
{% for field, metadata in _fields_visible_by_user %}
{% set isSortingField = (metadata.property == app.request.get('sortField')) or ('association' == metadata.type and app.request.get('sortField') starts with metadata.property ~ '.') %}
{% set nextSortDirection = isSortingField ? (app.request.get('sortDirection') == 'DESC' ? 'ASC' : 'DESC') : 'DESC' %}
{% set _column_label = metadata.label|trans(_trans_parameters) %}
{% set _column_icon = isSortingField ? (nextSortDirection == 'DESC' ? 'fa-arrow-up' : 'fa-arrow-down') : 'fa-sort' %}
<th class="{{ isSortingField ? 'sorted' }} {{ metadata.virtual ? 'virtual' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
{% if metadata.sortable %}
<a href="{{ path('easyadmin', _request_parameters|merge({ page: 1, sortField: metadata.property, sortDirection: nextSortDirection })) }}">
{{ _column_label|raw }} <i class="fa fa-fw {{ _column_icon }}"></i>
</a>
{% else %}
<span>{{ _column_label|raw }}</span>
{% endif %}
</th>
{% endfor %}
{% if _list_item_actions|length > 0 %}
<th {% if _entity_config.list.collapse_actions %}width="10px"{% endif %} {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
<span class="sr-only">{{ 'list.row_actions'|trans(_trans_parameters, 'EasyAdminBundle') }}</span>
</th>
{% endif %}
</tr>
{% endblock table_head %}
</thead>
<tbody>
{% block table_body %}
{% for item in paginator.currentPageResults %}
{% if not easyadmin_is_granted(_entity_config.list.item_permission, item) %}
{% set _number_of_hidden_results = _number_of_hidden_results + 1 %}
{% else %}
{# the empty string concatenation is needed when the primary key is an object (e.g. an Uuid object) #}
{% set _item_id = '' ~ attribute(item, _entity_config.primary_key_field_name) %}
<tr data-id="{{ _item_id }}">
{% if _has_batch_actions %}
<td><input type="checkbox" class="form-batch-checkbox" value="{{ _item_id }}"></td>
{% endif %}
{% for field, metadata in _fields_visible_by_user %}
{% set isSortingField = metadata.property == app.request.get('sortField') %}
{% set _column_label = (metadata.label ?: field|humanize)|trans(_trans_parameters) %}
<td class="{{ isSortingField ? 'sorted' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
{{ easyadmin_render_field_for_list_view(_entity_config.name, item, metadata) }}
</td>
{% endfor %}
{% if _list_item_actions|length > 0 %}
{% set _column_label = 'list.row_actions'|trans(_trans_parameters, 'EasyAdminBundle') %}
<td class="actions">
{% block item_actions %}
{% set _actions_template = _entity_config.list.collapse_actions
? '@EasyAdmin/default/includes/_actions_dropdown.html.twig'
: '@EasyAdmin/default/includes/_actions.html.twig'
%}
{{ include(_actions_template, {
actions: _list_item_actions,
entity_config: _entity_config,
request_parameters: _request_parameters,
translation_domain: _entity_config.translation_domain,
trans_parameters: _trans_parameters,
item_id: _item_id,
item: item
}, with_context = false) }}
{% endblock item_actions %}
</td>
{% endif %}
</tr>
{% endif %}
{% else %}
<tr>
<td class="no-results" colspan="{{ _fields_visible_by_user|length + 1 }}">
{{ 'search.no_results'|trans(_trans_parameters, 'EasyAdminBundle') }}
</td>
</tr>
{% endfor %}
{% if _number_of_hidden_results > 0 %}
<tr class="datagrid-row-empty">
<td class="text-center" colspan="{{ _fields_visible_by_user|length + 1 }}">
<span class="datagrid-row-empty-message"><i class="fa fa-lock mr-1"></i> {{ 'security.list.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
</td>
</tr>
{% endif %}
{% endblock table_body %}
</tbody>
</table>
</div>
<div class="panel-footer">
{{ include(_entity_config.templates.paginator) }}
</div>
</div>
{% block delete_form %}
{% set referer = paginator.currentPage == paginator.nbPages and 1 != paginator.currentPage and 1 == paginator.currentPageResults|length
? path('easyadmin', app.request.query|merge({ page: app.request.query.get('page') - 1 }))
: app.request.requestUri
%}
{{ include('@EasyAdmin/default/includes/_delete_form.html.twig', {
view: 'list',
referer: referer,
delete_form: delete_form_template,
_translation_domain: _entity_config.translation_domain,
_trans_parameters: _trans_parameters,
_entity_config: _entity_config,
}, with_context = false) }}
{% endblock delete_form %}
{% endblock main %}
{% block content_footer_wrapper '' %}
{% block body_javascript %}
{{ parent() }}
{{ include('@EasyAdmin/default/includes/_body_javascript.html.twig') }}
{% endblock body_javascript %}