mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixes for reasign list
* use existing method in UserRepository and use a method instead of building a query outside of the repository; * use renderString to render users * fix building of filter form (add $data). This make the use of the method "get" instead of post
This commit is contained in:
parent
f084078cf2
commit
293efc03b4
@ -51,11 +51,6 @@ final class UserRepository implements ObjectRepository
|
|||||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
|
||||||
{
|
|
||||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function find($id, $lockMode = null, $lockVersion = null): ?User
|
public function find($id, $lockMode = null, $lockVersion = null): ?User
|
||||||
{
|
{
|
||||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Repository\UserRepository;
|
use Chill\MainBundle\Repository\UserRepository;
|
||||||
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
@ -39,9 +40,11 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
|
private UserRender $userRender;
|
||||||
|
|
||||||
private UserRepository $userRepository;
|
private UserRepository $userRepository;
|
||||||
|
|
||||||
public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security)
|
public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, UserRender $userRender)
|
||||||
{
|
{
|
||||||
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
$this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository;
|
||||||
$this->engine = $engine;
|
$this->engine = $engine;
|
||||||
@ -49,6 +52,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
$this->userRepository = $userRepository;
|
$this->userRepository = $userRepository;
|
||||||
|
$this->userRender = $userRender;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,22 +90,18 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
|||||||
|
|
||||||
private function buildFilterForm(): FormInterface
|
private function buildFilterForm(): FormInterface
|
||||||
{
|
{
|
||||||
$builder = $this->formFactory->createBuilder(FormType::class, [
|
$data = [
|
||||||
|
'user' => null,
|
||||||
|
];
|
||||||
|
$builder = $this->formFactory->createBuilder(FormType::class, $data, [
|
||||||
'method' => 'get', 'csrf_protection' => false, ]);
|
'method' => 'get', 'csrf_protection' => false, ]);
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('user', EntityType::class, [
|
->add('user', EntityType::class, [
|
||||||
'class' => User::class,
|
'class' => User::class,
|
||||||
'query_builder' => function () {
|
'choices' => $this->userRepository->findByActive(['username' => 'ASC']),
|
||||||
$qb = $this->userRepository->createQueryBuilder('u');
|
'choice_label' => function (User $u) {
|
||||||
|
return $this->userRender->renderString($u, []);
|
||||||
$qb->where('u.enabled = true')
|
|
||||||
->orderBy('u.username', 'ASC');
|
|
||||||
|
|
||||||
return $qb;
|
|
||||||
},
|
|
||||||
'choice_label' => static function (User $u) {
|
|
||||||
return $u->getUsername();
|
|
||||||
},
|
},
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'label' => 'User',
|
'label' => 'User',
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
<h1>{{ block('title') }}</h1>
|
<h1>{{ block('title') }}</h1>
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
<div class="row filter-box" style="padding: 2rem 2rem 2rem 0;">
|
<div class="row filter-box">
|
||||||
<div class="col-md-6" style="display: flex; justify-content: space-between;">
|
<div class="col-md-6">
|
||||||
{{ form_label(form.user ) }}
|
{{ form_label(form.user ) }}
|
||||||
{{ form_widget(form.user, {'attr': {'class': 'select2'}}) }}
|
{{ form_widget(form.user, {'attr': {'class': 'select2'}}) }}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user