Action::NEW => [ | Action::NEW => [ | ||||
'icon' => 'plus', | 'icon' => 'plus', | ||||
'label' => 'Créer', | 'label' => 'Créer', | ||||
'add_class'=>'btn-sm' | |||||
], | ], | ||||
Action::EDIT => [ | Action::EDIT => [ | ||||
'class' => 'btn btn-sm btn-primary', | 'class' => 'btn btn-sm btn-primary', | ||||
'icon' => 'edit', | 'icon' => 'edit', | ||||
'label' => false, | 'label' => false, | ||||
'html_attributes'=> array('data-toggle'=> 'tooltip', 'title'=> 'Éditer') | |||||
], | ], | ||||
Action::DELETE => [ | Action::DELETE => [ | ||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
'dropdown' => true, | 'dropdown' => true, | ||||
], | ], | ||||
Action::BATCH_DELETE => [ | Action::BATCH_DELETE => [ | ||||
'class' => 'btn btn-danger', | |||||
'class' => 'btn btn-sm btn-danger', | |||||
'icon' => 'trash', | 'icon' => 'trash', | ||||
], | ], | ||||
]; | ]; | ||||
/* Boutons des actions dans l'édition */ | /* Boutons des actions dans l'édition */ | ||||
$actionSaveAndReturn = [ | $actionSaveAndReturn = [ | ||||
'add-class' => 'float-right', | |||||
'add_class' => 'float-right', | |||||
'icon' => 'check', | 'icon' => 'check', | ||||
]; | ]; | ||||
$actionIndex = [ | $actionIndex = [ | ||||
if ($this->isInstanceOf(SortableInterface::class)) { | if ($this->isInstanceOf(SortableInterface::class)) { | ||||
$sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort') | $sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort') | ||||
->linkToCrudAction('sort') | ->linkToCrudAction('sort') | ||||
->setCssClass('btn btn-info') | |||||
->setHtmlAttributes(array('entityId' => 'ncihe')) | |||||
->setCssClass('btn btn-sm btn-success') | |||||
->createAsGlobalAction(); | ->createAsGlobalAction(); | ||||
$actions->add(Crud::PAGE_INDEX, $sortAction); | $actions->add(Crud::PAGE_INDEX, $sortAction); | ||||
if ($this->isInstanceOf(TreeInterface::class)) { | if ($this->isInstanceOf(TreeInterface::class)) { | ||||
$indexChildAction = Action::new('index_children', 'Afficher les enfants', 'fa fa-sort') | |||||
$indexChildAction = Action::new('index_children', 'Afficher les enfants', 'fa fa-list') | |||||
->linkToCrudAction(Action::INDEX) | ->linkToCrudAction(Action::INDEX) | ||||
->setLabel('') | |||||
->setHtmlAttributes(array('data-toggle'=> 'tooltip', 'title'=> 'Afficher les enfants')) | |||||
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | ||||
->setCssClass('btn btn-info'); | |||||
->setCssClass('btn btn-sm btn-success'); | |||||
$backParentAction = Action::new('index_parent', 'Retour au parent', 'fa fa-chevron-left') | |||||
->linkToCrudAction(Action::INDEX) | |||||
->setCssClass('btn btn-sm btn-info') | |||||
->createAsGlobalAction(); | |||||
$actions->add(Crud::PAGE_INDEX, $backParentAction); | |||||
$actions->add(Crud::PAGE_INDEX, $indexChildAction); | $actions->add(Crud::PAGE_INDEX, $indexChildAction); | ||||
} | } | ||||
$crudActionName, | $crudActionName, | ||||
$actionName, | $actionName, | ||||
function (Action $action) use ($button) { | function (Action $action) use ($button) { | ||||
if (isset($button['add-class'])) { | |||||
$action->addCssClass($button['add-class']); | |||||
if (isset($button['add_class'])) { | |||||
$action->addCssClass($button['add_class']); | |||||
} | } | ||||
if (isset($button['class'])) { | if (isset($button['class'])) { | ||||
$action->addCssClass('in-dropdown'); | $action->addCssClass('in-dropdown'); | ||||
} | } | ||||
if (isset($button['html_attributes']) && $button['html_attributes']) { | |||||
$action->setHtmlAttributes( $button['html_attributes']); | |||||
} | |||||
return $action; | return $action; | ||||
} | } | ||||
); | ); | ||||
$crud = parent::configureCrud($crud); | $crud = parent::configureCrud($crud); | ||||
$this->setMaxResults($crud); | $this->setMaxResults($crud); | ||||
if($this->isInstanceOf(SortableInterface::class)){ | |||||
$crud->setDefaultSort(['position' => 'ASC']); | |||||
} | |||||
return $crud; | return $crud; | ||||
} | } | ||||
{ | { | ||||
$actions = $event->getResponseParameters()->get('global_actions'); | $actions = $event->getResponseParameters()->get('global_actions'); | ||||
if ($actions) { | if ($actions) { | ||||
foreach ($actions as $action) { | |||||
foreach ($actions as $i=>$action) { | |||||
//récriture du bouton 'retour au parent' | |||||
if ($action->getName() == 'index_parent') { | |||||
$entity = $event->getAdminContext()->getEntity()->getInstance(); | |||||
if ($entity !== null) { | |||||
if($entity->getParent() !==null){ | |||||
$url = $this->adminUrlGenerator | |||||
->setController($event->getAdminContext()->getCrud()->getControllerFqcn()) | |||||
->set('entityId', $entity->getParent()->getId()) | |||||
->generateUrl(); | |||||
$action->setLinkUrl($url); | |||||
} | |||||
}else{ | |||||
unset($actions[$i]); | |||||
} | |||||
} | |||||
if ($action->getName() == 'sort') { | if ($action->getName() == 'sort') { | ||||
$entityId = $event->getAdminContext()->getRequest()->get('entityId'); | $entityId = $event->getAdminContext()->getRequest()->get('entityId'); | ||||
if ($entityId != null) { | if ($entityId != null) { |
{% if ea.entity.instance is not null %} | |||||
<nav aria-label="breadcrumb"> | |||||
<ol class="breadcrumb"> | |||||
<li class="breadcrumb-item"><a href="{{ ea_url().unset('entityId').generateUrl() }}">Index</a></li> | |||||
{% set parent = ea.entity.instance.parent %} | |||||
{% if parent is not null %} | |||||
<li class="breadcrumb-item"><a href="{{ ea_url({ entityId: parent.id }).generateUrl() }}">{{ parent.title }}</a></li> | |||||
{% set grand_parent = parent.parent %} | |||||
{% if grand_parent is not null %} | |||||
<li class="breadcrumb-item"><a href="{{ ea_url({ entityId: grand_parent.id }).generateUrl() }}">{{ grand_parent.title }}</a></li> | |||||
{% endif %} | |||||
{% endif %} | |||||
<li class="breadcrumb-item active" aria-current="page">{{ ea.entity.instance.title }}</li> | |||||
</ol> | |||||
</nav> | |||||
{% endif %} |
{%- endapply -%} | {%- endapply -%} | ||||
{% endblock %} | {% endblock %} | ||||
{% block content_breadcrumb %} | |||||
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | |||||
{% endblock content_breadcrumb %} | |||||
{% set has_batch_actions = batch_actions|length > 0 %} | {% set has_batch_actions = batch_actions|length > 0 %} | ||||
{% block page_actions %} | {% block page_actions %} | ||||
{% block global_actions %} | |||||
<div class="global-actions"> | |||||
{% for action in global_actions %} | |||||
{{ include(action.templatePath, { action: action }, with_context = false) }} | |||||
{% endfor %} | |||||
</div> | |||||
{% endblock global_actions %} | |||||
{% block batch_actions %} | |||||
{% if has_batch_actions %} | |||||
<div class="batch-actions" style="display: none"> | |||||
{% for action in batch_actions %} | |||||
{{ include(action.templatePath, { action: action }, with_context = false) }} | |||||
{% endfor %} | |||||
</div> | |||||
{% endif %} | |||||
{% endblock %} | |||||
{% endblock page_actions %} | {% endblock page_actions %} | ||||
{% block main %} | {% block main %} | ||||
<span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total"> | <span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total"> | ||||
{{ paginator.numResults }} résultats | {{ paginator.numResults }} résultats | ||||
</span> | </span> | ||||
<div class="btn-list float-sm-right"> | |||||
{% block global_actions %} | |||||
<div class="global-actions"> | |||||
{% for action in global_actions %} | |||||
{{ include(action.templatePath, { action: action }, with_context = false) }} | |||||
{% endfor %} | |||||
</div> | |||||
{% endblock global_actions %} | |||||
{% block batch_actions %} | |||||
{% if has_batch_actions %} | |||||
<div class="batch-actions" style="display: none"> | |||||
{% for action in batch_actions %} | |||||
{{ include(action.templatePath, { action: action }, with_context = false) }} | |||||
{% endfor %} | |||||
</div> | |||||
{% endif %} | |||||
{% endblock %} | |||||
</div> | |||||
{% endblock %} | {% endblock %} | ||||
{% block body %} | {% block body %} | ||||
<div class="table-responsive"> | <div class="table-responsive"> | ||||
dir="{{ ea.i18n.textDirection }}"> | dir="{{ ea.i18n.textDirection }}"> | ||||
{% if field.isSortable %} | {% if field.isSortable %} | ||||
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> | <a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> | ||||
{{ field.label ? field.label|raw : field.getProperty|raw }} <i class="fa fa-fw {{ column_icon }}"></i> | |||||
{{ field.label ? field.label|raw : field.getProperty|raw }} <i | |||||
class="fa fa-fw {{ column_icon }}"></i> | |||||
</a> | </a> | ||||
{% else %} | {% else %} | ||||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||||
{% endif %} | {% endif %} | ||||
</th> | </th> | ||||
{% endif %} | {% endif %} |
<div class="col-sm-12 col-md-6"> | <div class="col-sm-12 col-md-6"> | ||||
<div class="float-sm-right"> | <div class="float-sm-right"> | ||||
<ul class="pagination"> | |||||
<ul class="pagination pagination-sm"> | |||||
<li class="page-item {{ not paginator.hasPreviousPage ? 'disabled' }}"> | <li class="page-item {{ not paginator.hasPreviousPage ? 'disabled' }}"> | ||||
<a class="page-link" href="{{ not paginator.hasPreviousPage ? '#' : paginator.generateUrlForPage(paginator.previousPage) }}" {{ not paginator.hasPreviousPage ? 'aria-disabled="true"' }}> | <a class="page-link" href="{{ not paginator.hasPreviousPage ? '#' : paginator.generateUrlForPage(paginator.previousPage) }}" {{ not paginator.hasPreviousPage ? 'aria-disabled="true"' }}> | ||||
<i class="ti ti-arrow-left"></i> <span class="btn-label">{{ 'paginator.previous'|trans }}</span> | <i class="ti ti-arrow-left"></i> <span class="btn-label">{{ 'paginator.previous'|trans }}</span> |
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Tri position | |||||
{# {%- apply spaceless -%} | |||||
{% set default_title = ea.crud.defaultPageTitle('index')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('index')|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} #} | |||||
Édition position | |||||
{% endblock %} | {% endblock %} | ||||
{% block content_breadcrumb %} | |||||
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | |||||
{% endblock content_breadcrumb %} | |||||
{% set has_batch_actions = batch_actions|length > 0 %} | {% set has_batch_actions = batch_actions|length > 0 %} | ||||
{% block page_actions %} | |||||
{# {% block global_actions %} | |||||
<div class="global-actions"> | |||||
{% for action in global_actions %} | |||||
{{ include(action.templatePath, { action: action }, with_context = false) }} | |||||
{% endfor %} | |||||
</div> | |||||
{% endblock global_actions %} | |||||
{% block batch_actions %} | |||||
{% if has_batch_actions %} | |||||
<div class="batch-actions" style="display: none"> | |||||
{% for action in batch_actions %} | |||||
{{ include(action.templatePath, { action: action }, with_context = false) }} | |||||
{% endfor %} | |||||
</div> | |||||
{% endif %} | |||||
{% endblock %} #} | |||||
{% endblock page_actions %} | |||||
{% block page_actions %}{% endblock page_actions %} | |||||
{% block main %} | {% block main %} | ||||
{# sort can be multiple; let's consider the sorting field the first one #} | {# sort can be multiple; let's consider the sorting field the first one #} | ||||
<span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total"> | <span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total"> | ||||
{{ paginator.numResults }} résultats | {{ paginator.numResults }} résultats | ||||
</span> | </span> | ||||
<div class="btn-list float-sm-right"> | |||||
<a href=" {{ ea_url({crudAction: 'index'}).generateUrl() }}" class="btn btn-sm btn-info"> | |||||
<i class="fa fa-chevron-left"></i> | |||||
Retour à la liste | |||||
</a> | |||||
</div> | |||||
{% endblock %} | {% endblock %} | ||||
{% block body %} | {% block body %} | ||||
<th></th> | <th></th> | ||||
{% for field in fields ?? [] %} | {% for field in fields ?? [] %} | ||||
{% set field = field.getAsDto() %} | {% set field = field.getAsDto() %} | ||||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||||
{% if field.isDisplayedOn('index') %} | |||||
{% set is_sorting_field = ea.search.isSortingField(field.property) %} | |||||
<th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}" | <th class="{{ is_sorting_field ? 'sorted' }} {{ field.isVirtual ? 'field-virtual' }} {% if field.textAlign %}text-{{ field.textAlign }}{% endif %}" | ||||
dir="{{ ea.i18n.textDirection }}"> | dir="{{ ea.i18n.textDirection }}"> | ||||
<span>{{ field.label|raw }}</span> | |||||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||||
</th> | </th> | ||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
</tr> | </tr> | ||||
<i class="fa fa-fw fa-sort"></i> | <i class="fa fa-fw fa-sort"></i> | ||||
</td> | </td> | ||||
{% for field in entity.fields %} | {% for field in entity.fields %} | ||||
{% if field.isDisplayedOn('index') %} | |||||
<td class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" | <td class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" | ||||
dir="{{ ea.i18n.textDirection }}"> | dir="{{ ea.i18n.textDirection }}"> | ||||
{{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }} | {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }} | ||||
</td> | </td> | ||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
</tr> | </tr> | ||||
{% endif %} | {% endif %} | ||||
</div> | </div> | ||||
{% endblock %} | {% endblock %} | ||||
{% endembed %} | |||||
{% embed '@LcSov/adminlte/embed/card.html.twig' %} | |||||
{% block footer %} | {% block footer %} | ||||
<div class="form-actions"> | <div class="form-actions"> | ||||
<div class="button-action"> | <div class="button-action"> | ||||
</div> | </div> | ||||
{% endblock %} | {% endblock %} | ||||
{% endembed %} | {% endembed %} | ||||
{{ form_end(sortable_form) }} | {{ form_end(sortable_form) }} | ||||
{% endblock main %} | {% endblock main %} |
<h1 class="m-0 text-dark"> | <h1 class="m-0 text-dark"> | ||||
{% block content_title %}{% endblock %} | {% block content_title %}{% endblock %} | ||||
</h1> | </h1> | ||||
{% block content_breadcrumb %} | |||||
{% endblock content_breadcrumb %} | |||||
{# {% block content_help %} | {# {% block content_help %} | ||||
{% if has_help_message %} | {% if has_help_message %} | ||||
<div class="text-muted"> | <div class="text-muted"> |