Fixed: fix the evaluation maxDateFilter to use correct alias

Some weird code is also removed in describeAction
This commit is contained in:
Julien Fastré 2022-10-08 01:03:21 +02:00
parent 5592e906f2
commit 6585662087
2 changed files with 12 additions and 24 deletions

View File

@ -22,8 +22,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class MaxDateFilter implements FilterInterface
{
private const MAXDATE_CHOICES = [
'is specified' => true,
'is not specified' => false,
'maxdate is specified' => true,
'maxdate is not specified' => false,
];
private TranslatorInterface $translator;
@ -40,21 +40,13 @@ class MaxDateFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
if (true === $data['maxdate']) {
$clause = $qb->expr()->isNotNull('eval.maxDate');
$clause = $qb->expr()->isNotNull('workeval.maxDate');
} else {
$clause = $qb->expr()->isNull('eval.maxDate');
$clause = $qb->expr()->isNull('workeval.maxDate');
}
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->andWhere($clause);
}
public function applyOn(): string
@ -73,19 +65,15 @@ class MaxDateFilter implements FilterInterface
public function describeAction($data, $format = 'string'): array
{
foreach (self::MAXDATE_CHOICES as $k => $v) {
if ($v === $data['maxdate']) {
$choice = $k;
}
}
return ['Filtered by maxdate: only %choice%', [
'%choice%' => $this->translator->trans($choice),
'%choice%' => $this->translator->trans(
$data['maxdate'] ? 'maxdate is specified': 'maxdate is not specified'
),
]];
}
public function getTitle(): string
{
return 'Filter by maxdate';
return 'Filter evaluations by maxdate mention';
}
}

View File

@ -581,10 +581,10 @@ Accepted evaluationtype: Évaluations
Group by evaluation type: Grouper les évaluations par type
Evaluation type: Type d'évaluation
Filter by maxdate: Filtrer les évaluations par date d'échéance
Filter evaluations by maxdate mention: Filtrer les évaluations qui possèdent une date d'échéance
Maxdate: ''
is specified: La date d'échéance est spécifiée
is not specified: La date d'échéance n'est pas spécifiée
maxdate is specified: la date d'échéance est spécifiée
maxdate is not specified: la date d'échéance n'est pas spécifiée
"Filtered by maxdate: only %choice%": "Filtré par date d'échéance: uniquement si %choice%"
## household filters/aggr