Bladeren bron

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/SovBundle into develop

tags/0.1
Guillaume 3 jaren geleden
bovenliggende
commit
11d65960ab
7 gewijzigde bestanden met toevoegingen van 113 en 56 verwijderingen
  1. +24
    -9
      Controller/Admin/AbstractCrudController.php
  2. +17
    -1
      EventSubscriber/Action/ActionEasyAdminSubscriber.php
  3. +18
    -0
      Resources/views/adminlte/block/breadcrumb.html.twig
  4. +27
    -18
      Resources/views/adminlte/crud/index.html.twig
  5. +1
    -1
      Resources/views/adminlte/crud/paginator.html.twig
  6. +23
    -27
      Resources/views/adminlte/crud/sort.html.twig
  7. +3
    -0
      Resources/views/adminlte/layout.html.twig

+ 24
- 9
Controller/Admin/AbstractCrudController.php Bestand weergeven

@@ -80,18 +80,20 @@ abstract class AbstractCrudController extends EaAbstractCrudController
Action::NEW => [
'icon' => 'plus',
'label' => 'Créer',
'add_class'=>'btn-sm'
],
Action::EDIT => [
'class' => 'btn btn-sm btn-primary',
'icon' => 'edit',
'label' => false,
'html_attributes'=> array('data-toggle'=> 'tooltip', 'title'=> 'Éditer')
],
Action::DELETE => [
'icon' => 'trash',
'dropdown' => true,
],
Action::BATCH_DELETE => [
'class' => 'btn btn-danger',
'class' => 'btn btn-sm btn-danger',
'icon' => 'trash',
],
];
@@ -99,7 +101,7 @@ abstract class AbstractCrudController extends EaAbstractCrudController
/* Boutons des actions dans l'édition */

$actionSaveAndReturn = [
'add-class' => 'float-right',
'add_class' => 'float-right',
'icon' => 'check',
];
$actionIndex = [
@@ -134,8 +136,7 @@ abstract class AbstractCrudController extends EaAbstractCrudController
if ($this->isInstanceOf(SortableInterface::class)) {
$sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort')
->linkToCrudAction('sort')
->setCssClass('btn btn-info')
->setHtmlAttributes(array('entityId' => 'ncihe'))
->setCssClass('btn btn-sm btn-success')
->createAsGlobalAction();

$actions->add(Crud::PAGE_INDEX, $sortAction);
@@ -143,11 +144,19 @@ abstract class AbstractCrudController extends EaAbstractCrudController


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)
->setLabel('')
->setHtmlAttributes(array('data-toggle'=> 'tooltip', 'title'=> 'Afficher les enfants'))
->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);
}

@@ -161,8 +170,8 @@ abstract class AbstractCrudController extends EaAbstractCrudController
$crudActionName,
$actionName,
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'])) {
@@ -181,6 +190,10 @@ abstract class AbstractCrudController extends EaAbstractCrudController
$action->addCssClass('in-dropdown');
}

if (isset($button['html_attributes']) && $button['html_attributes']) {
$action->setHtmlAttributes( $button['html_attributes']);
}

return $action;
}
);
@@ -204,7 +217,9 @@ abstract class AbstractCrudController extends EaAbstractCrudController
$crud = parent::configureCrud($crud);

$this->setMaxResults($crud);

if($this->isInstanceOf(SortableInterface::class)){
$crud->setDefaultSort(['position' => 'ASC']);
}
return $crud;
}


+ 17
- 1
EventSubscriber/Action/ActionEasyAdminSubscriber.php Bestand weergeven

@@ -37,7 +37,23 @@ class ActionEasyAdminSubscriber implements EventSubscriberInterface
{
$actions = $event->getResponseParameters()->get('global_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') {
$entityId = $event->getAdminContext()->getRequest()->get('entityId');
if ($entityId != null) {

+ 18
- 0
Resources/views/adminlte/block/breadcrumb.html.twig Bestand weergeven

@@ -0,0 +1,18 @@
{% 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 %}

+ 27
- 18
Resources/views/adminlte/crud/index.html.twig Bestand weergeven

@@ -14,24 +14,13 @@
{%- endapply -%}
{% endblock %}

{% block content_breadcrumb %}
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }}
{% endblock content_breadcrumb %}

{% 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 main %}
@@ -50,6 +39,25 @@
<span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total">
{{ paginator.numResults }} résultats
</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 %}
{% block body %}
<div class="table-responsive">
@@ -81,10 +89,11 @@
dir="{{ ea.i18n.textDirection }}">
{% if field.isSortable %}
<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>
{% else %}
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span>
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span>
{% endif %}
</th>
{% endif %}

+ 1
- 1
Resources/views/adminlte/crud/paginator.html.twig Bestand weergeven

@@ -18,7 +18,7 @@

<div class="col-sm-12 col-md-6">
<div class="float-sm-right">
<ul class="pagination">
<ul class="pagination pagination-sm">
<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"' }}>
<i class="ti ti-arrow-left"></i> <span class="btn-label">{{ 'paginator.previous'|trans }}</span>

+ 23
- 27
Resources/views/adminlte/crud/sort.html.twig Bestand weergeven

@@ -8,32 +8,17 @@
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %}

{% 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 %}


{% block content_breadcrumb %}
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }}
{% endblock content_breadcrumb %}

{% 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 %}
{# sort can be multiple; let's consider the sorting field the first one #}
@@ -53,6 +38,13 @@
<span data-toggle="tooltip" class="badge badge-light" data-original-title="Total" title="Total">
{{ paginator.numResults }} résultats
</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 %}
{% block body %}

@@ -65,11 +57,13 @@
<th></th>
{% for field in fields ?? [] %}
{% 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 %}"
dir="{{ ea.i18n.textDirection }}">
<span>{{ field.label|raw }}</span>
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span>
</th>
{% endif %}
{% endfor %}

</tr>
@@ -88,10 +82,12 @@
<i class="fa fa-fw fa-sort"></i>
</td>
{% for field in entity.fields %}
{% if field.isDisplayedOn('index') %}
<td class="{{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}"
dir="{{ ea.i18n.textDirection }}">
{{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
</td>
{% endif %}
{% endfor %}
</tr>
{% endif %}
@@ -122,9 +118,7 @@

</div>
{% endblock %}
{% endembed %}

{% embed '@LcSov/adminlte/embed/card.html.twig' %}
{% block footer %}
<div class="form-actions">
<div class="button-action">
@@ -136,6 +130,8 @@
</div>
{% endblock %}
{% endembed %}


{{ form_end(sortable_form) }}

{% endblock main %}

+ 3
- 0
Resources/views/adminlte/layout.html.twig Bestand weergeven

@@ -107,6 +107,9 @@
<h1 class="m-0 text-dark">
{% block content_title %}{% endblock %}
</h1>

{% block content_breadcrumb %}
{% endblock content_breadcrumb %}
{# {% block content_help %}
{% if has_help_message %}
<div class="text-muted">

Laden…
Annuleren
Opslaan