mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Fixed: fix the evaluation maxDateFilter to use correct alias
Some weird code is also removed in describeAction
This commit is contained in:
@@ -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';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user