mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch '232-filters-uj-and-serv-order-alphabetical' into 'master'
Resolve "Filtres sur les données: classer par ordre alphabétique les items à sélectionner" Closes #232 See merge request Chill-Projet/chill-bundles!662
This commit is contained in:
commit
27d76d9579
5
.changes/unreleased/UX-20240226-143943.yaml
Normal file
5
.changes/unreleased/UX-20240226-143943.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: UX
|
||||||
|
body: Order user jobs and services alphabetically in export filters
|
||||||
|
time: 2024-02-26T14:39:43.283296338+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "232"
|
@ -80,7 +80,7 @@ final readonly class CreatorJobFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('jobs', EntityType::class, [
|
->add('jobs', EntityType::class, [
|
||||||
'choices' => $this->userJobRepository->findAllOrderedByName(),
|
'choices' => $this->userJobRepository->findAllActive(),
|
||||||
'class' => UserJob::class,
|
'class' => UserJob::class,
|
||||||
'choice_label' => fn (UserJob $s) => $this->translatableStringHelper->localize(
|
'choice_label' => fn (UserJob $s) => $this->translatableStringHelper->localize(
|
||||||
$s->getLabel()
|
$s->getLabel()
|
||||||
|
@ -15,6 +15,7 @@ use Chill\ActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -26,7 +27,8 @@ class CreatorScopeFilter implements FilterInterface
|
|||||||
private const PREFIX = 'acp_act_filter_creator_scope';
|
private const PREFIX = 'acp_act_filter_creator_scope';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TranslatableStringHelper $translatableStringHelper
|
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||||
|
private readonly ScopeRepositoryInterface $scopeRepository,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +78,7 @@ class CreatorScopeFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('scopes', EntityType::class, [
|
->add('scopes', EntityType::class, [
|
||||||
'class' => Scope::class,
|
'class' => Scope::class,
|
||||||
|
'choices' => $this->scopeRepository->findAllActive(),
|
||||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
||||||
$s->getName()
|
$s->getName()
|
||||||
),
|
),
|
||||||
|
@ -16,6 +16,7 @@ use Chill\ActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -27,7 +28,8 @@ class UsersJobFilter implements FilterInterface
|
|||||||
private const PREFIX = 'act_filter_user_job';
|
private const PREFIX = 'act_filter_user_job';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||||
|
private readonly UserJobRepositoryInterface $userJobRepository
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +71,7 @@ class UsersJobFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('jobs', EntityType::class, [
|
->add('jobs', EntityType::class, [
|
||||||
'class' => UserJob::class,
|
'class' => UserJob::class,
|
||||||
|
'choices' => $this->userJobRepository->findAllActive(),
|
||||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
|
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
|
@ -16,6 +16,7 @@ use Chill\AsideActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -27,7 +28,8 @@ class ByUserJobFilter implements FilterInterface
|
|||||||
private const PREFIX = 'aside_act_filter_user_job';
|
private const PREFIX = 'aside_act_filter_user_job';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||||
|
private readonly UserJobRepositoryInterface $userJobRepository
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +71,7 @@ class ByUserJobFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('jobs', EntityType::class, [
|
->add('jobs', EntityType::class, [
|
||||||
'class' => UserJob::class,
|
'class' => UserJob::class,
|
||||||
|
'choices' => $this->userJobRepository->findAllActive(),
|
||||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
|
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
|
@ -15,6 +15,7 @@ use Chill\CalendarBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -26,7 +27,8 @@ final readonly class JobFilter implements FilterInterface
|
|||||||
private const PREFIX = 'cal_filter_job';
|
private const PREFIX = 'cal_filter_job';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private TranslatableStringHelper $translatableStringHelper
|
private TranslatableStringHelper $translatableStringHelper,
|
||||||
|
private UserJobRepositoryInterface $userJobRepository
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +76,7 @@ final readonly class JobFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('job', EntityType::class, [
|
->add('job', EntityType::class, [
|
||||||
'class' => UserJob::class,
|
'class' => UserJob::class,
|
||||||
|
'choices' => $this->userJobRepository->findAllActive(),
|
||||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
|
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
|
||||||
$j->getLabel()
|
$j->getLabel()
|
||||||
),
|
),
|
||||||
|
@ -15,6 +15,7 @@ use Chill\CalendarBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\Query\Expr\Join;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -28,7 +29,8 @@ class ScopeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected TranslatorInterface $translator,
|
protected TranslatorInterface $translator,
|
||||||
private readonly TranslatableStringHelper $translatableStringHelper
|
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||||
|
private readonly ScopeRepositoryInterface $scopeRepository
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +78,7 @@ class ScopeFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('scope', EntityType::class, [
|
->add('scope', EntityType::class, [
|
||||||
'class' => Scope::class,
|
'class' => Scope::class,
|
||||||
|
'choices' => $this->scopeRepository->findAllActive(),
|
||||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
||||||
$s->getName()
|
$s->getName()
|
||||||
),
|
),
|
||||||
|
@ -433,6 +433,7 @@ final class EventController extends AbstractController
|
|||||||
$builder->add('event_id', HiddenType::class, [
|
$builder->add('event_id', HiddenType::class, [
|
||||||
'data' => $event->getId(),
|
'data' => $event->getId(),
|
||||||
]);
|
]);
|
||||||
|
dump($event->getId());
|
||||||
|
|
||||||
return $builder->getForm();
|
return $builder->getForm();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Repository;
|
namespace Chill\MainBundle\Repository;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
@ -20,7 +21,7 @@ final class ScopeRepository implements ScopeRepositoryInterface
|
|||||||
{
|
{
|
||||||
private readonly EntityRepository $repository;
|
private readonly EntityRepository $repository;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $entityManager)
|
public function __construct(EntityManagerInterface $entityManager, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||||
{
|
{
|
||||||
$this->repository = $entityManager->getRepository(Scope::class);
|
$this->repository = $entityManager->getRepository(Scope::class);
|
||||||
}
|
}
|
||||||
@ -45,11 +46,11 @@ final class ScopeRepository implements ScopeRepositoryInterface
|
|||||||
|
|
||||||
public function findAllActive(): array
|
public function findAllActive(): array
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('s');
|
$scopes = $this->repository->findBy(['active' => true]);
|
||||||
|
|
||||||
$qb->where('s.active = \'TRUE\'');
|
usort($scopes, fn (Scope $a, Scope $b) => $this->translatableStringHelper->localize($a->getName()) <=> $this->translatableStringHelper->localize($b->getName()));
|
||||||
|
|
||||||
return $qb->getQuery()->getResult();
|
return $scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +40,11 @@ readonly class UserJobRepository implements UserJobRepositoryInterface
|
|||||||
|
|
||||||
public function findAllActive(): array
|
public function findAllActive(): array
|
||||||
{
|
{
|
||||||
return $this->repository->findBy(['active' => true]);
|
$jobs = $this->repository->findBy(['active' => true]);
|
||||||
|
|
||||||
|
usort($jobs, fn (UserJob $a, UserJob $b) => $this->translatableStringHelper->localize($a->getLabel()) <=> $this->translatableStringHelper->localize($b->getLabel()));
|
||||||
|
|
||||||
|
return $jobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAllOrderedByName(): array
|
public function findAllOrderedByName(): array
|
||||||
|
@ -84,13 +84,10 @@ readonly class JobWorkingOnCourseFilter implements FilterInterface
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder): void
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
{
|
{
|
||||||
$jobs = $this->userJobRepository->findAllActive();
|
|
||||||
usort($jobs, fn (UserJob $a, UserJob $b) => $this->translatableStringHelper->localize($a->getLabel()) <=> $this->translatableStringHelper->localize($b->getLabel()));
|
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('jobs', EntityType::class, [
|
->add('jobs', EntityType::class, [
|
||||||
'class' => UserJob::class,
|
'class' => UserJob::class,
|
||||||
'choices' => $jobs,
|
'choices' => $this->userJobRepository->findAllActive(),
|
||||||
'choice_label' => fn (UserJob $userJob) => $this->translatableStringHelper->localize($userJob->getLabel()),
|
'choice_label' => fn (UserJob $userJob) => $this->translatableStringHelper->localize($userJob->getLabel()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
|
@ -84,13 +84,10 @@ readonly class ScopeWorkingOnCourseFilter implements FilterInterface
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder): void
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
{
|
{
|
||||||
$scopes = $this->scopeRepository->findAllActive();
|
|
||||||
usort($scopes, fn (Scope $a, Scope $b) => $this->translatableStringHelper->localize($a->getName()) <=> $this->translatableStringHelper->localize($b->getName()));
|
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('scopes', EntityType::class, [
|
->add('scopes', EntityType::class, [
|
||||||
'class' => Scope::class,
|
'class' => Scope::class,
|
||||||
'choices' => $scopes,
|
'choices' => $this->scopeRepository->findAllActive(),
|
||||||
'choice_label' => fn (Scope $scope) => $this->translatableStringHelper->localize($scope->getName()),
|
'choice_label' => fn (Scope $scope) => $this->translatableStringHelper->localize($scope->getName()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
|
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
|
|||||||
|
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
||||||
@ -28,7 +29,8 @@ class JobFilter implements FilterInterface
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected TranslatorInterface $translator,
|
protected TranslatorInterface $translator,
|
||||||
private readonly TranslatableStringHelper $translatableStringHelper
|
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||||
|
private readonly UserJobRepositoryInterface $userJobRepository,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +63,7 @@ class JobFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('job', EntityType::class, [
|
->add('job', EntityType::class, [
|
||||||
'class' => UserJob::class,
|
'class' => UserJob::class,
|
||||||
|
'choices' => $this->userJobRepository->findAllActive(),
|
||||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
|
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize(
|
||||||
$j->getLabel()
|
$j->getLabel()
|
||||||
),
|
),
|
||||||
|
@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
|
|||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkReferrerHistory;
|
||||||
@ -28,7 +29,8 @@ class ScopeFilter implements FilterInterface
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected TranslatorInterface $translator,
|
protected TranslatorInterface $translator,
|
||||||
private readonly TranslatableStringHelper $translatableStringHelper
|
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||||
|
private readonly ScopeRepositoryInterface $scopeRepository
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +62,7 @@ class ScopeFilter implements FilterInterface
|
|||||||
$builder
|
$builder
|
||||||
->add('scope', EntityType::class, [
|
->add('scope', EntityType::class, [
|
||||||
'class' => Scope::class,
|
'class' => Scope::class,
|
||||||
|
'choices' => $this->scopeRepository->findAllActive(),
|
||||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize(
|
||||||
$s->getName()
|
$s->getName()
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user