Skip to content

Commit

Permalink
fix(trash): menu
Browse files Browse the repository at this point in the history
  • Loading branch information
koromerzhin committed Aug 28, 2021
1 parent f2bee51 commit a1f1bb6
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
34 changes: 34 additions & 0 deletions apps/src/Controller/Admin/MenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Labstag\Controller\Admin;

use Labstag\Annotation\IgnoreSoftDelete;
use Labstag\Entity\Menu;
use Labstag\Form\Admin\Menu\LinkType;
use Labstag\Form\Admin\Menu\PrincipalType;
Expand All @@ -23,6 +24,39 @@ class MenuController extends AdminControllerLib

protected string $urlHome = 'admin_menu_index';


/**
* @Route("/trash", name="admin_menu_trash", methods={"GET"})
*
* @param MenuRepository $repository
* @return Response
* @IgnoreSoftDelete
*/
public function trash(MenuRepository $repository): Response
{
return $this->listOrTrash(
$repository,
[
'trash' => 'findTrashForAdmin',
'all' => 'findAllForAdmin',
],
'admin/menu/trash.html.twig',
[
'new' => 'admin_menu_new',
'empty' => 'api_action_empty',
'trash' => 'admin_menu_trash',
'list' => 'admin_menu_index',
],
[
'list' => 'admin_menu_index',
'edit' => 'admin_menu_edit',
'delete' => 'api_action_delete',
'destroy' => 'api_action_destroy',
'restore' => 'api_action_restore',
]
);
}

/**
* @Route("/", name="admin_menu_index", methods={"GET"})
*/
Expand Down
4 changes: 2 additions & 2 deletions apps/src/EventSubscriber/KernelSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class KernelSubscriber implements EventSubscriberInterface
];
public const LABSTAG_CONTROLLER = '/(Labstag)/';

public const ERRORNUMBER = 500;
public const CLIENTNUMBER = 400;

public const ERROR_CONTROLLER = [
'error_controller',
Expand All @@ -86,7 +86,7 @@ public function onKernelResponse($event)
return;
}

if ('html' != $request->getRequestFormat() || self::ERRORNUMBER == $response->getStatusCode()) {
if ('html' != $request->getRequestFormat() || $response->getStatusCode() >= self::CLIENTNUMBER) {
return;
}

Expand Down
40 changes: 40 additions & 0 deletions apps/templates/admin/menu/trash.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% import "admin/macro.html.twig" as macro_admin %}
{% extends 'admin/menu/layout.html.twig' %}
{% block body %}
<table
is="table-datatable"
data-action="Actions"
data-multiple
data-multipleall="Tout sélectionner"
data-multipleelement="Selection"
data-empty="No records found"
data-count={{ pagination|length }}
>
<thead>
<tr>
<th>Libelle</th>
<th>Icon</th>
<th>Position</th>
<th>Data</th>
<th>Separateur</th>
<th>Clef</th>
<th></th>
</tr>
</thead>
<tbody>
{% for entity in pagination %}
<tr data-id="{{ entity.id }}">
<td>{{ entity.libelle }}</td>
<td>{{ entity.icon }}</td>
<td>{{ entity.position }}</td>
<td>{{ entity.data ? entity.data|json_encode : '' }}</td>
<td>{{ entity.separateur ? 'Yes' : 'No' }}</td>
<td>{{ entity.clef }}</td>
<td>
{{ macro_admin.actions(entity, actions) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

0 comments on commit a1f1bb6

Please sign in to comment.