Feat: Add assignment filtering for teamers
This commit is contained in:
@@ -23,11 +23,14 @@ class AssignmentFilterHandler
|
||||
) {
|
||||
}
|
||||
|
||||
public function getForm(): FormInterface
|
||||
public function getForm(string $namespace = 'assignment_filter'): FormInterface
|
||||
{
|
||||
$filterDto = $this->getFilterSettings();
|
||||
$filterDto = $this->getFilterSettings($namespace);
|
||||
|
||||
$assignmentRepository = $this->entityManager->getRepository(Assignment::class);
|
||||
$assignmentRepository = $this
|
||||
->entityManager
|
||||
->getRepository(Assignment::class)
|
||||
;
|
||||
$filterOptions = $assignmentRepository->getFilterOptions();
|
||||
|
||||
return $this->formFactory->create(AssignmentFilterType::class, $filterDto, [
|
||||
@@ -38,35 +41,30 @@ class AssignmentFilterHandler
|
||||
]);
|
||||
}
|
||||
|
||||
public function handleRequest(FormInterface $form, Request $request): AssignmentFilterDto
|
||||
{
|
||||
public function handleRequest(
|
||||
FormInterface $form,
|
||||
Request $request,
|
||||
string $namespace = 'assignment_filter'
|
||||
): AssignmentFilterDto {
|
||||
$form->handleRequest($request);
|
||||
$filterDto = $form->getData();
|
||||
|
||||
if ($form->has('reset') && $form->get('reset')->isClicked()) {
|
||||
$filterDto = new AssignmentFilterDto();
|
||||
$filterDto->setReset(true);
|
||||
$this->getSession()->remove('assignment_filter');
|
||||
$filterDto = new AssignmentFilterDto(true);
|
||||
$this->getSession()->remove($namespace);
|
||||
} elseif ($form->has('apply') && $form->get('apply')->isClicked()) {
|
||||
$this->saveFilterSettings($filterDto);
|
||||
$this->saveFilterSettings($filterDto, $namespace);
|
||||
}
|
||||
|
||||
return $filterDto;
|
||||
}
|
||||
|
||||
public function getFilterSettings(): AssignmentFilterDto
|
||||
private function getFilterSettings(string $namespace): AssignmentFilterDto
|
||||
{
|
||||
if (null === $this->getSession()->get('assignment_filter')) {
|
||||
if (null === $data = $this->getSession()->get($namespace)) {
|
||||
return new AssignmentFilterDto();
|
||||
}
|
||||
|
||||
return $this->loadFilterSettings();
|
||||
}
|
||||
|
||||
public function loadFilterSettings(): AssignmentFilterDto
|
||||
{
|
||||
$data = $this->getSession()->get('assignment_filter');
|
||||
|
||||
$filterDto = new AssignmentFilterDto();
|
||||
|
||||
if (isset($data['date_from'])) {
|
||||
@@ -98,9 +96,9 @@ class AssignmentFilterHandler
|
||||
return $filterDto;
|
||||
}
|
||||
|
||||
public function saveFilterSettings(AssignmentFilterDto $filterDto): void
|
||||
private function saveFilterSettings(AssignmentFilterDto $filterDto, string $namespace): void
|
||||
{
|
||||
$this->getSession()->set('assignment_filter', [
|
||||
$this->getSession()->set($namespace, [
|
||||
'date_from' => $filterDto->getDateFrom()?->format('Y-m-d'),
|
||||
'date_to' => $filterDto->getDateTo()?->format('Y-m-d'),
|
||||
'job_profile' => $filterDto->getJobProfile()?->getId(),
|
||||
|
||||
Reference in New Issue
Block a user