Skip to content

Commit

Permalink
♻️ 🌐 [Admin] Big refacto on trans keys, only snake case on trans file
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAresu committed Mar 18, 2024
1 parent cd5310c commit 3b13f71
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 231 deletions.
23 changes: 23 additions & 0 deletions src/Controller/Admin/AbstractWorkshopSectionCrudController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Controller\Admin;

use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

class AbstractWorkshopSectionCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return '';
}

public function configureFields(string $pageName): iterable
{
return [
IntegerField::new('id', 'ID')->hideOnForm(),
TextField::new('name')->setLabel('name'),
];
}
}
16 changes: 6 additions & 10 deletions src/Controller/Admin/AgeBreakpointCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
namespace App\Controller\Admin;

use App\Entity\AgeBreakpoint;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

class AgeBreakpointCrudController extends AbstractCrudController
class AgeBreakpointCrudController extends AbstractWorkshopSectionCrudController
{
public static function getEntityFqcn(): string
{
return AgeBreakpoint::class;
}

/*
public function configureFields(string $pageName): iterable
public function configureCrud(Crud $crud): Crud
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
return $crud
->setEntityLabelInSingular('age_breakpoint')
->setEntityLabelInPlural('age_breakpoints');
}
*/
}
10 changes: 5 additions & 5 deletions src/Controller/Admin/CenterCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ public static function getEntityFqcn(): string
public function configureCrud(Crud $crud): Crud
{
return $crud
->setEntityLabelInSingular('Center')
->setEntityLabelInPlural('Center')
->setEntityLabelInSingular('center')
->setEntityLabelInPlural('centers')
->setSearchFields(['id', 'name']);
}

public function configureFields(string $pageName): iterable
{
$name = TextField::new('name');
$place = TextField::new('place')->setRequired(false)->setEmptyData(Center::PLACE_DEFAULT_VALUE);
$name = TextField::new('name')->setLabel('name');
$place = TextField::new('place')->setRequired(false)->setEmptyData(Center::PLACE_DEFAULT_VALUE)->setLabel('place');
$permanences = AssociationField::new('permanences')->setLabel('permanences_count');
$workshops = AssociationField::new('workshops')->setLabel('workshops_count');
$tags = AssociationField::new('tags')->setFormTypeOption('by_reference', false);
$tags = AssociationField::new('tags')->setFormTypeOption('by_reference', false)->setLabel('center_tags');
$id = IntegerField::new('id', 'ID');
$workshop = BooleanField::new('workshop');
$permanence = BooleanField::new('permanence');
Expand Down
20 changes: 15 additions & 5 deletions src/Controller/Admin/CenterTagCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
namespace App\Controller\Admin;

use App\Entity\CenterTag;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

class CenterTagCrudController extends AbstractCrudController
{
Expand All @@ -12,14 +15,21 @@ public static function getEntityFqcn(): string
return CenterTag::class;
}

/*
public function configureCrud(Crud $crud): Crud
{
return $crud
->setEntityLabelInSingular('center_tag')
->setEntityLabelInPlural('center_tags')
->setSearchFields(['id', 'name']);
}

public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
IntegerField::new('id', 'ID')->hideOnForm(),
TextField::new('name')->setLabel('name'),
TextField::new('color')->setLabel('color'),
TextField::new('category')->setLabel('category'),
];
}
*/
}
24 changes: 12 additions & 12 deletions src/Controller/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ public function configureMenuItems(): iterable
{
yield MenuItem::linkToLogout('Logout', 'fas fa-sign-out-alt text-danger')->setCssClass('text-danger');
yield MenuItem::section('Interventions');
yield MenuItem::linkToCrud('Permanence', 'fas fa-home', Permanence::class);
yield MenuItem::linkToCrud('Workshop', 'fas fa-briefcase', Workshop::class);
yield MenuItem::linkToCrud('permanences', 'fas fa-home', Permanence::class);
yield MenuItem::linkToCrud('workshops', 'fas fa-briefcase', Workshop::class);

if ($this->isGranted('ROLE_SUPER_ADMIN')) {
yield MenuItem::section('Utilisateurs et Centres');
yield MenuItem::linkToCrud('User', 'fas fa-users', User::class);
yield MenuItem::linkToCrud('Center', 'fas fa-home', Center::class);
yield MenuItem::linkToCrud('Tag', 'fas fa-tags', CenterTag::class);
yield MenuItem::linkToCrud('users', 'fas fa-users', User::class);
yield MenuItem::linkToCrud('centers', 'fas fa-home', Center::class);
yield MenuItem::linkToCrud('center_tags', 'fas fa-tags', CenterTag::class);
yield MenuItem::section('Données');
yield MenuItem::linkToCrud('Topic', 'fas fa-comment', Topic::class);
yield MenuItem::linkToCrud('Skill', 'fas fa-hand-paper', Skill::class);
yield MenuItem::linkToCrud('AgeBreakpoint', 'fas fa-birthday-cake', AgeBreakpoint::class);
yield MenuItem::linkToCrud('Duration', 'fas fa-clock', Duration::class);
yield MenuItem::linkToCrud('ParticipantKind', 'fas fa-users', ParticipantKind::class);
yield MenuItem::linkToCrud('EquipmentSupplier', 'fas fa-truck', EquipmentSupplier::class);
yield MenuItem::linkToCrud('UsedEquipment', 'fas fa-tools', UsedEquipment::class);
yield MenuItem::linkToCrud('topics', 'fas fa-comment', Topic::class);
yield MenuItem::linkToCrud('skills', 'fas fa-hand-paper', Skill::class);
yield MenuItem::linkToCrud('age_breakpoints', 'fas fa-birthday-cake', AgeBreakpoint::class);
yield MenuItem::linkToCrud('durations', 'fas fa-clock', Duration::class);
yield MenuItem::linkToCrud('participant_kinds', 'fas fa-users', ParticipantKind::class);
yield MenuItem::linkToCrud('equipment_supplier', 'fas fa-truck', EquipmentSupplier::class);
yield MenuItem::linkToCrud('used_equipments', 'fas fa-tools', UsedEquipment::class);
}
}
}
17 changes: 7 additions & 10 deletions src/Controller/Admin/DurationCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
namespace App\Controller\Admin;

use App\Entity\Duration;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

class DurationCrudController extends AbstractCrudController
class DurationCrudController extends AbstractWorkshopSectionCrudController
{
public static function getEntityFqcn(): string
{
return Duration::class;
}

/*
public function configureFields(string $pageName): iterable
public function configureCrud(Crud $crud): Crud
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
return $crud
->setEntityLabelInSingular('duration')
->setEntityLabelInPlural('durations')
->setSearchFields(['id', 'name']);
}
*/
}
17 changes: 7 additions & 10 deletions src/Controller/Admin/EquipmentSupplierCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
namespace App\Controller\Admin;

use App\Entity\EquipmentSupplier;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

class EquipmentSupplierCrudController extends AbstractCrudController
class EquipmentSupplierCrudController extends AbstractWorkshopSectionCrudController
{
public static function getEntityFqcn(): string
{
return EquipmentSupplier::class;
}

/*
public function configureFields(string $pageName): iterable
public function configureCrud(Crud $crud): Crud
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
return $crud
->setEntityLabelInSingular('equipment_supplier')
->setEntityLabelInPlural('equipment_supplier')
->setSearchFields(['id', 'name']);
}
*/
}
17 changes: 7 additions & 10 deletions src/Controller/Admin/ParticipantKindCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
namespace App\Controller\Admin;

use App\Entity\ParticipantKind;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

class ParticipantKindCrudController extends AbstractCrudController
class ParticipantKindCrudController extends AbstractWorkshopSectionCrudController
{
public static function getEntityFqcn(): string
{
return ParticipantKind::class;
}

/*
public function configureFields(string $pageName): iterable
public function configureCrud(Crud $crud): Crud
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
return $crud
->setEntityLabelInSingular('participant_kind')
->setEntityLabelInPlural('participant_kinds')
->setSearchFields(['id', 'name']);
}
*/
}
54 changes: 28 additions & 26 deletions src/Controller/Admin/PermanenceCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter;
use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter;
use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter;
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;

Expand Down Expand Up @@ -63,11 +65,11 @@ public static function getEntityFqcn(): string
public function configureFilters(Filters $filters): Filters
{
return $filters
->add('date')
->add('author')
->add('attendees')
->add('createdAt')
->add('updatedAt')
->add(DateTimeFilter::new('date', 'date'))
->add(EntityFilter::new('author', 'author'))
->add(TextFilter::new('attendees', 'attendees'))
->add(DateTimeFilter::new('createdAt', 'created_at'))
->add(DateTimeFilter::new('updatedAt', 'updated_at'))
->add(EntityFilter::new('center')->setFormTypeOption('value_type_options.multiple', 'true'))
->add(AssociationFilter::new('center.tags.id')->setLabel('tags')->setFormType(EntityType::class)->setFormTypeOption('class', CenterTag::class));
}
Expand All @@ -76,32 +78,32 @@ public function configureCrud(Crud $crud): Crud
{
return $crud
->overrideTemplate('crud/index', 'bundles/EasyAdminBundle/Permanence/index.html.twig')
->setEntityLabelInSingular('Permanence')
->setEntityLabelInPlural('Permanences')
->setEntityLabelInSingular('permanence')
->setEntityLabelInPlural('permanences')
->setSearchFields(['id', 'hours', 'nbPros', 'nbProAccounts', 'nbBeneficiaries', 'nbBeneficiariesAccounts', 'nbStoredDocs', 'beneficiariesNotes', 'proNotes', 'reconnectNotes', 'attendees']);
}

public function configureFields(string $pageName): \Generator
{
yield IntegerField::new('id')->hideOnForm()->setColumns(3);
yield DateField::new('date')->setColumns(3);
yield IntegerField::new('hours')->setColumns(3);
yield TextField::new('place')->onlyOnForms()->setColumns(3);
yield TextField::new('attendees')->hideOnIndex()->setColumns(3);
yield AssociationField::new('author')->hideOnIndex()->setColumns(6);
yield AssociationField::new('center')->hideOnIndex()->setColumns(6);
yield IntegerField::new('nbPros')->setColumns(3);
yield IntegerField::new('nbBeneficiaries')->setColumns(3);
yield IntegerField::new('nbBeneficiariesAccounts')->setColumns(3);
yield IntegerField::new('nbUninterestedBeneficiaries', 'nbUninterestedBeneficiaries')->setColumns(3);
yield IntegerField::new('nbHelpedBeneficiaries', 'nbHelpedBeneficiaries')->setColumns(3);
yield IntegerField::new('nbStoredDocs')->setColumns(6)->hideOnIndex();
yield IntegerField::new('maleCount')->setColumns(3)->setRequired(true)->hideOnIndex();
yield IntegerField::new('femaleCount')->setColumns(3)->setRequired(true)->hideOnIndex();
yield IntegerField::new('noGenderCount')->setColumns(3)->setRequired(true)->hideOnIndex();
yield TextareaField::new('beneficiariesNotes')->hideOnIndex()->setColumns(6);
yield TextareaField::new('proNotes')->hideOnIndex()->setColumns(6);
yield DateTimeField::new('createdAt')->onlyOnDetail();
yield DateTimeField::new('updatedAt')->onlyOnDetail();
yield DateField::new('date')->setColumns(3)->setLabel('date');
yield IntegerField::new('hours')->setColumns(3)->setLabel('hours');
yield TextField::new('place')->onlyOnForms()->setColumns(3)->setLabel('place');
yield TextField::new('attendees')->hideOnIndex()->setColumns(3)->setLabel('attendees');
yield AssociationField::new('author')->hideOnIndex()->setColumns(6)->setLabel('author');
yield AssociationField::new('center')->hideOnIndex()->setColumns(6)->setLabel('center');
yield IntegerField::new('nbPros')->setColumns(3)->setLabel('pros_count');
yield IntegerField::new('nbBeneficiaries')->setColumns(3)->setLabel('beneficiaries_count');
yield IntegerField::new('nbBeneficiariesAccounts')->setColumns(3)->setLabel('beneficiaries_accounts_count');
yield IntegerField::new('nbUninterestedBeneficiaries', 'nbUninterestedBeneficiaries')->setColumns(3)->setLabel('unintested_beneficiaries_count');
yield IntegerField::new('nbHelpedBeneficiaries', 'nbHelpedBeneficiaries')->setColumns(3)->setLabel('helped_beneficiaries_count');
yield IntegerField::new('nbStoredDocs')->setColumns(6)->hideOnIndex()->setLabel('stored_docs_count');
yield IntegerField::new('maleCount')->setColumns(3)->setRequired(true)->hideOnIndex()->setLabel('male_count');
yield IntegerField::new('femaleCount')->setColumns(3)->setRequired(true)->hideOnIndex()->setLabel('female_count');
yield IntegerField::new('noGenderCount')->setColumns(3)->setRequired(true)->hideOnIndex()->setLabel('no_gender_count');
yield TextareaField::new('beneficiariesNotes')->hideOnIndex()->setColumns(6)->setLabel('beneficiaries_notes');
yield TextareaField::new('proNotes')->hideOnIndex()->setColumns(6)->setLabel('pro_notes');
yield DateTimeField::new('createdAt')->onlyOnDetail()->setLabel('created_at');
yield DateTimeField::new('updatedAt')->onlyOnDetail()->setLabel('updated_at');
}
}
18 changes: 11 additions & 7 deletions src/Controller/Admin/SkillCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
namespace App\Controller\Admin;

use App\Entity\Skill;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

class SkillCrudController extends AbstractCrudController
class SkillCrudController extends AbstractWorkshopSectionCrudController
{
public static function getEntityFqcn(): string
{
return Skill::class;
}

public function configureCrud(Crud $crud): Crud
{
return $crud
->setEntityLabelInSingular('skill')
->setEntityLabelInPlural('skills');
}

public function configureFields(string $pageName): iterable
{
return [
IdField::new('id')->hideOnForm(),
TextField::new('name'),
AssociationField::new('topic'),
...parent::configureFields($pageName),
AssociationField::new('topic')->setLabel('topic'),
];
}
}
16 changes: 6 additions & 10 deletions src/Controller/Admin/TopicCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
namespace App\Controller\Admin;

use App\Entity\Topic;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;

class TopicCrudController extends AbstractCrudController
class TopicCrudController extends AbstractWorkshopSectionCrudController
{
public static function getEntityFqcn(): string
{
return Topic::class;
}

/*
public function configureFields(string $pageName): iterable
public function configureCrud(Crud $crud): Crud
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
return $crud
->setEntityLabelInSingular('topic')
->setEntityLabelInPlural('topics');
}
*/
}
Loading

0 comments on commit 3b13f71

Please sign in to comment.