mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: [export] review on CreatorFilter, CreatorJobAggregator, CreatorJobFilter
This commit is contained in:
parent
c05637bc72
commit
82d9ab8ca6
@ -62,15 +62,13 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
return 'Job';
|
||||
return 'export.aggregator.course.by_creator_job.Creator\'s job';
|
||||
}
|
||||
|
||||
if (null === $value) {
|
||||
if (null === $value || null === $j = $this->jobRepository->find($value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$j = $this->jobRepository->find($value);
|
||||
|
||||
return $this->translatableStringHelper->localize(
|
||||
$j->getLabel()
|
||||
);
|
||||
|
@ -11,10 +11,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
@ -32,17 +32,9 @@ class CreatorFilter implements FilterInterface
|
||||
$qb->join('acp.createdBy', 'acp_creator');
|
||||
}
|
||||
|
||||
$where = $qb->getDQLPart('where');
|
||||
$clause = $qb->expr()->in('acp_creator', ':creators');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
$qb->setParameter('creators', $data['accepted_creators']);
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('acp_creator', ':creators'))
|
||||
->setParameter('creators', $data['accepted_creators']);
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
@ -55,20 +47,15 @@ class CreatorFilter implements FilterInterface
|
||||
$builder
|
||||
->add('accepted_creators', PickUserDynamicType::class, [
|
||||
'multiple' => true,
|
||||
'label' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string'): array
|
||||
{
|
||||
$creators = [];
|
||||
|
||||
foreach ($data['accepted_creators'] as $c) {
|
||||
$creators[] = $c;
|
||||
}
|
||||
|
||||
return [
|
||||
'Filtered by creator: only %creators%', [
|
||||
'%creators%' => implode(', ', $creators),
|
||||
'%creators%' => implode(', ', array_map(static fn (User $u) => $u->getLabel(), $data['accepted_creators'])),
|
||||
], ];
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ class CreatorJobFilter implements FilterInterface
|
||||
},
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'label' => 'Job',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -1008,6 +1008,8 @@ export:
|
||||
Calc date: Date de calcul de la composition du ménage
|
||||
by_number_of_action:
|
||||
Number of actions: Nombre d'actions
|
||||
by_creator_job:
|
||||
Creator's job: Métier du créateur
|
||||
course_work:
|
||||
by_current_action:
|
||||
Current action ?: Action en cours ?
|
||||
|
Loading…
x
Reference in New Issue
Block a user