Skip to content

Commit

Permalink
[Admin] General conventions (#11427)
Browse files Browse the repository at this point in the history
* Change group for admin

* Update filters
  • Loading branch information
Remg authored Feb 6, 2025
1 parent 9a61942 commit ee7dc0b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
4 changes: 3 additions & 1 deletion config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ security:
- ROLE_APP_ADMIN_PROCURATION_V2_REQUEST_ALL
- ROLE_APP_ADMIN_PROCURATION_V2_PROXY_ALL
- ROLE_APP_ADMIN_PROCURATION_V2_PROCURATION_REQUEST_ALL
ROLE_ADMIN_TERRITOIRES_GENERAL_CONVENTIONS:

## Idées
ROLE_ADMIN_IDEES_GENERAL_CONVENTIONS:
- ROLE_APP_ADMIN_GENERAL_CONVENTION_ALL

## Application Mobile
Expand Down
8 changes: 7 additions & 1 deletion config/services/admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,14 @@
</service>
<service id="App\Admin\ReportAdmin" alias="app.admin.report" />

<!--
######################################################
# Idées
######################################################
-->

<service id="app.admin.general_convention" class="App\Admin\GeneralConventionAdmin">
<tag name="sonata.admin" manager-type="orm" label="États généraux" group="Territoires" />
<tag name="sonata.admin" manager-type="orm" label="États généraux" group="Idées" />

<argument />
<argument>App\Entity\GeneralConvention\GeneralConvention</argument>
Expand Down
72 changes: 72 additions & 0 deletions src/Admin/GeneralConventionAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Admin;

use App\Admin\Filter\ZoneAutocompleteFilter;
use App\Entity\Adherent;
use App\Entity\Geo\Zone;
use App\Form\Admin\SimpleMDEContent;
Expand All @@ -10,13 +11,84 @@
use App\GeneralConvention\ParticipantQuality;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter;
use Sonata\DoctrineORMAdminBundle\Filter\DateRangeFilter;
use Sonata\DoctrineORMAdminBundle\Filter\ModelFilter;
use Sonata\Form\Type\DateRangePickerType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;

class GeneralConventionAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
->add('departmentZone', ZoneAutocompleteFilter::class, [
'label' => 'Département',
'field_type' => ModelAutocompleteType::class,
'field_options' => [
'multiple' => false,
'minimum_input_length' => 1,
'items_per_page' => 20,
'property' => [
'name',
'code',
],
],
])
->add('districtZone', ZoneAutocompleteFilter::class, [
'label' => 'Circonscription',
'field_type' => ModelAutocompleteType::class,
'field_options' => [
'multiple' => false,
'minimum_input_length' => 1,
'items_per_page' => 20,
'property' => [
'name',
'code',
],
],
])
->add('committee', CallbackFilter::class, [
'label' => 'Comité',
'field_type' => ModelAutocompleteType::class,
'show_filter' => true,
'field_options' => [
'model_manager' => $this->getModelManager(),
'minimum_input_length' => 1,
'items_per_page' => 20,
'property' => 'name',
],
])
->add('reporter', ModelFilter::class, [
'label' => 'Auteur',
'show_filter' => true,
'field_type' => ModelAutocompleteType::class,
'field_options' => [
'model_manager' => $this->getModelManager(),
'property' => [
'search',
],
'to_string_callback' => static function (Adherent $adherent): string {
return \sprintf(
'%s (%s) [%s]',
$adherent->getFullName(),
$adherent->getEmailAddress(),
$adherent->getId()
);
},
],
])
->add('reportedAt', DateRangeFilter::class, [
'label' => 'Date de remontée',
'field_type' => DateRangePickerType::class,
])
;
}

protected function configureFormFields(FormMapper $form): void
{
$form
Expand Down
2 changes: 1 addition & 1 deletion src/DataFixtures/ORM/LoadAdminData.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function load(ObjectManager $manager): void
'ROLE_ADMIN_TERRITOIRES_JME_GENERAL_MEETING_REPORTS',
'ROLE_ADMIN_TERRITOIRES_JME_EMAIL_TEMPLATES',
'ROLE_ADMIN_TERRITOIRES_ELUS_NOTIFICATION',
'ROLE_ADMIN_TERRITOIRES_GENERAL_CONVENTIONS',
'ROLE_ADMIN_IDEES_GENERAL_CONVENTIONS',
'ROLE_ADMIN_PETITION',
]);

Expand Down
4 changes: 2 additions & 2 deletions src/DataFixtures/ORM/LoadAdministratorRoleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ private function getRoles(): \Generator
AdministratorRoleGroupEnum::ELECTIONS
);
yield $this->createRole(
'ROLE_ADMIN_TERRITOIRES_GENERAL_CONVENTIONS',
'ROLE_ADMIN_IDEES_GENERAL_CONVENTIONS',
'Administrateur des états généraux',
AdministratorRoleGroupEnum::TERRITOIRES
AdministratorRoleGroupEnum::IDEES
);
// Application Mobile
yield $this->createRole(
Expand Down

0 comments on commit ee7dc0b

Please sign in to comment.