mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 11:33:49 +00:00
use different logic to decide whether mission type filter should be shown
This commit is contained in:
@@ -26,6 +26,7 @@ use Chill\TaskBundle\Event\TaskEvent;
|
||||
use Chill\TaskBundle\Event\UI\UIEvent;
|
||||
use Chill\TaskBundle\Form\SingleTaskType;
|
||||
use Chill\TaskBundle\Repository\SingleTaskAclAwareRepositoryInterface;
|
||||
use Chill\TaskBundle\Repository\SingleTaskRepository;
|
||||
use Chill\TaskBundle\Repository\SingleTaskStateRepository;
|
||||
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
||||
use LogicException;
|
||||
@@ -48,41 +49,18 @@ use function array_merge;
|
||||
|
||||
final class SingleTaskController extends AbstractController
|
||||
{
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
private FilterOrderHelperFactoryInterface $filterOrderHelperFactory;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository;
|
||||
|
||||
private TimelineBuilder $timelineBuilder;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
CenterResolverDispatcherInterface $centerResolverDispatcher,
|
||||
PaginatorFactory $paginatorFactory,
|
||||
SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
|
||||
TranslatorInterface $translator,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
TimelineBuilder $timelineBuilder,
|
||||
LoggerInterface $logger,
|
||||
FilterOrderHelperFactoryInterface $filterOrderHelperFactory,
|
||||
private SingleTaskStateRepository $singleTaskStateRepository
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher,
|
||||
private PaginatorFactory $paginatorFactory,
|
||||
private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
|
||||
private TranslatorInterface $translator,
|
||||
private EventDispatcherInterface $eventDispatcher,
|
||||
private TimelineBuilder $timelineBuilder,
|
||||
private LoggerInterface $logger,
|
||||
private FilterOrderHelperFactoryInterface $filterOrderHelperFactory,
|
||||
private SingleTaskStateRepository $singleTaskStateRepository,
|
||||
private SingleTaskRepository $singleTaskRepository
|
||||
) {
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->timelineBuilder = $timelineBuilder;
|
||||
$this->logger = $logger;
|
||||
$this->translator = $translator;
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
$this->singleTaskAclAwareRepository = $singleTaskAclAwareRepository;
|
||||
$this->filterOrderHelperFactory = $filterOrderHelperFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +278,7 @@ final class SingleTaskController extends AbstractController
|
||||
) {
|
||||
$this->denyAccessUnlessGranted(TaskVoter::SHOW, null);
|
||||
|
||||
$showMissionTypeFilter = $this->getParameter('show_mission_type_filter');
|
||||
$showMissionTypeFilter = $this->singleTaskRepository->countByDistinctTypes() > 2 ? true : false;
|
||||
|
||||
$filterOrder = $this->buildFilterOrder(true, $showMissionTypeFilter);
|
||||
|
||||
@@ -706,8 +684,12 @@ final class SingleTaskController extends AbstractController
|
||||
}
|
||||
|
||||
if ($includeMissionType) {
|
||||
$missionTypes = $this->getParameter('task_types');
|
||||
$filterBuilder->addCheckbox('missionTypePicker', $missionTypes);
|
||||
$missionTypes = $this->singleTaskRepository->findAllTasktypes();
|
||||
foreach ($missionTypes as $type) {
|
||||
$arrayOfTypes[] = $type['type'];
|
||||
}
|
||||
|
||||
$filterBuilder->addCheckbox('missionTypePicker', $arrayOfTypes);
|
||||
}
|
||||
|
||||
return $filterBuilder->build();
|
||||
|
Reference in New Issue
Block a user