From 1eb1e2ec24db330d3cf0181b1c66a0874353edab Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 12 Dec 2022 19:25:51 +0100 Subject: [PATCH] Fixed: [scope] api, picker and admin form consider 'active' property * add active field in admin scope form * issue: https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/675 --- .../Controller/ScopeApiController.php | 16 ++++++++++++++++ .../DependencyInjection/ChillMainExtension.php | 1 + src/Bundle/ChillMainBundle/Form/ScopeType.php | 9 ++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/Controller/ScopeApiController.php diff --git a/src/Bundle/ChillMainBundle/Controller/ScopeApiController.php b/src/Bundle/ChillMainBundle/Controller/ScopeApiController.php new file mode 100644 index 000000000..018674fb4 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/ScopeApiController.php @@ -0,0 +1,16 @@ +andWhere($query->expr()->eq('e.active', "'TRUE'")); + } + } +} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 2a785af42..378d90aa2 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -625,6 +625,7 @@ class ChillMainExtension extends Extension implements ], [ 'class' => \Chill\MainBundle\Entity\Scope::class, + 'controller' => \Chill\MainBundle\Controller\ScopeApiController::class, 'name' => 'scope', 'base_path' => '/api/1.0/main/scope', 'base_role' => 'ROLE_USER', diff --git a/src/Bundle/ChillMainBundle/Form/ScopeType.php b/src/Bundle/ChillMainBundle/Form/ScopeType.php index 691328500..923bc0778 100644 --- a/src/Bundle/ChillMainBundle/Form/ScopeType.php +++ b/src/Bundle/ChillMainBundle/Form/ScopeType.php @@ -13,6 +13,7 @@ namespace Chill\MainBundle\Form; use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -21,7 +22,13 @@ class ScopeType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('name', TranslatableStringFormType::class); + ->add('name', TranslatableStringFormType::class) + ->add('active', ChoiceType::class, [ + 'choices' => [ + 'Active' => true, + 'Inactive' => false, + ]]) + ; } /**