Feature: [export] filter on accompanying period step: allow to check multiple steps

This commit is contained in:
Julien Fastré 2023-06-14 22:54:18 +02:00
parent 21f0f70350
commit 8fabfdd5c0
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 24 additions and 9 deletions

View File

@ -0,0 +1,6 @@
kind: Feature
body: '[Export] Filter accompanying period by step at date: allow to pick multiple
steps'
time: 2023-06-14T22:47:20.577100599+02:00
custom:
Issue: "113"

View File

@ -27,7 +27,11 @@ class StepFilter implements FilterInterface
{ {
private const A = 'acp_filter_bystep_stephistories'; private const A = 'acp_filter_bystep_stephistories';
private const DEFAULT_CHOICE = AccompanyingPeriod::STEP_CONFIRMED; private const DEFAULT_CHOICE = [
AccompanyingPeriod::STEP_CONFIRMED,
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT,
AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG,
];
private const P = 'acp_step_filter_date'; private const P = 'acp_step_filter_date';
@ -79,7 +83,7 @@ class StepFilter implements FilterInterface
$qb->expr()->in(self::A . '.step', ':acp_filter_by_step_steps') $qb->expr()->in(self::A . '.step', ':acp_filter_by_step_steps')
) )
->setParameter(self::P, $this->rollingDateConverter->convert($data['calc_date'])) ->setParameter(self::P, $this->rollingDateConverter->convert($data['calc_date']))
->setParameter('acp_filter_by_step_steps', $data['accepted_steps']); ->setParameter('acp_filter_by_step_steps', $data['accepted_steps_multi']);
} }
public function applyOn() public function applyOn()
@ -90,25 +94,30 @@ class StepFilter implements FilterInterface
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
{ {
$builder $builder
->add('accepted_steps', ChoiceType::class, [ ->add('accepted_steps_multi', ChoiceType::class, [
'choices' => self::STEPS, 'choices' => self::STEPS,
'multiple' => false, 'multiple' => true,
'expanded' => true, 'expanded' => true,
'empty_data' => self::DEFAULT_CHOICE,
'data' => self::DEFAULT_CHOICE,
]) ])
->add('calc_date', PickRollingDateType::class, [ ->add('calc_date', PickRollingDateType::class, [
'label' => 'export.filter.course.by_step.date_calc', 'label' => 'export.filter.course.by_step.date_calc',
'data' => new RollingDate(RollingDate::T_TODAY),
]); ]);
} }
public function getFormDefaultData(): array
{
return [
'accepted_steps_multi' => self::DEFAULT_CHOICE,
'calc_date' => new RollingDate(RollingDate::T_TODAY),
];
}
public function describeAction($data, $format = 'string') public function describeAction($data, $format = 'string')
{ {
$step = array_flip(self::STEPS)[$data['accepted_steps']]; $steps = array_map(fn (string $step) => $this->translator->trans(array_flip(self::STEPS)[$step]), $data['accepted_steps_multi']);
return ['Filtered by steps: only %step%', [ return ['Filtered by steps: only %step%', [
'%step%' => $this->translator->trans($step), '%step%' => implode(', ', $steps),
]]; ]];
} }