Skip to content

Commit

Permalink
[Admin] Add type filters for actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Remg committed Nov 5, 2024
1 parent 2b4460f commit 09c1ba7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Admin/AdministratorActionHistoryAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace App\Admin;

use App\History\AdministratorActionHistoryTypeEnum;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridInterface;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter;
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter;
use Symfony\Component\Form\Extension\Core\Type\EnumType;

class AdministratorActionHistoryAdmin extends AbstractAdmin
{
Expand Down Expand Up @@ -39,6 +42,18 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
],
],
])
->add('type', ChoiceFilter::class, [
'label' => 'Type',
'show_filter' => true,
'field_type' => EnumType::class,
'field_options' => [
'class' => AdministratorActionHistoryTypeEnum::class,
'choice_label' => static function (AdministratorActionHistoryTypeEnum $type): string {
return 'administrator_action_history.type.'.$type->value;
},
'multiple' => true,
],
])
;
}

Expand Down
15 changes: 15 additions & 0 deletions src/Admin/UserActionHistoryAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
namespace App\Admin;

use App\Entity\Adherent;
use App\History\UserActionHistoryTypeEnum;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridInterface;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Sonata\AdminBundle\Route\RouteCollectionInterface;
use Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter;
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter;
use Symfony\Component\Form\Extension\Core\Type\EnumType;

class UserActionHistoryAdmin extends AbstractAdmin
{
Expand Down Expand Up @@ -59,6 +62,18 @@ protected function configureDatagridFilters(DatagridMapper $filter): void
],
],
])
->add('type', ChoiceFilter::class, [
'label' => 'Type',
'show_filter' => true,
'field_type' => EnumType::class,
'field_options' => [
'class' => UserActionHistoryTypeEnum::class,
'choice_label' => static function (UserActionHistoryTypeEnum $type): string {
return 'user_action_history.type.'.$type->value;
},
'multiple' => true,
],
])
;
}

Expand Down

0 comments on commit 09c1ba7

Please sign in to comment.