feat: hide inactive teamers from list view, overridable in filter
addresses #869dv987y
This commit is contained in:
@@ -55,6 +55,10 @@ class TeamerFilterType extends AbstractType
|
||||
'label' => 'an keinen Fortbildungen teilgenommen',
|
||||
'required' => false,
|
||||
])
|
||||
->add('includeInactive', CheckboxType::class, [
|
||||
'label' => 'inaktive Teamer:innen anzeigen',
|
||||
'required' => false,
|
||||
])
|
||||
->add('apply', SubmitType::class, [
|
||||
'label' => 'filtern',
|
||||
])
|
||||
|
||||
@@ -12,6 +12,7 @@ class TeamerFilterDto extends AbstractFilterDto
|
||||
protected bool $snowboardLicense = false;
|
||||
protected bool $driverLicenseVerified = false;
|
||||
protected bool $noTrainings = false;
|
||||
protected bool $includeInactive = false;
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
@@ -106,4 +107,16 @@ class TeamerFilterDto extends AbstractFilterDto
|
||||
{
|
||||
$this->noTrainings = $noTrainings;
|
||||
}
|
||||
|
||||
public function isIncludeInactive(): bool
|
||||
{
|
||||
return $this->includeInactive;
|
||||
}
|
||||
|
||||
public function setIncludeInactive(bool $includeInactive): static
|
||||
{
|
||||
$this->includeInactive = $includeInactive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ class TeamerRepository extends ServiceEntityRepository
|
||||
{
|
||||
use QueryHelperTrait;
|
||||
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
public function __construct(
|
||||
ManagerRegistry $registry,
|
||||
private readonly string $teamerInactivePeriod,
|
||||
) {
|
||||
parent::__construct($registry, Teamer::class);
|
||||
}
|
||||
|
||||
@@ -104,6 +106,13 @@ class TeamerRepository extends ServiceEntityRepository
|
||||
;
|
||||
}
|
||||
|
||||
if (false === $filterDto->isIncludeInactive()) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->gte('user.lastLoginAt', ':lastLoginThreshold'))
|
||||
->setParameter('lastLoginThreshold', new \DateTimeImmutable($this->teamerInactivePeriod))
|
||||
;
|
||||
}
|
||||
|
||||
return $qb->getQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ class TeamerFilterHandler extends AbstractFilterHandler
|
||||
->setNoTrainings($data['no_trainings'])
|
||||
;
|
||||
|
||||
if (isset($data['include_inactive'])) {
|
||||
$filterDto->setIncludeInactive((bool) $data['include_inactive']);
|
||||
}
|
||||
|
||||
if (0 < count($data['job_profiles'])) {
|
||||
$jobProfiles = $this
|
||||
->entityManager
|
||||
@@ -52,6 +56,7 @@ class TeamerFilterHandler extends AbstractFilterHandler
|
||||
'snowboard_license' => $filterDto->hasSnowboardLicense(),
|
||||
'driver_license_verified' => $filterDto->hasDriverLicenseVerified(),
|
||||
'no_trainings' => $filterDto->hasNoTrainings(),
|
||||
'include_inactive' => $filterDto->isIncludeInactive(),
|
||||
'job_profiles' => array_map(function (JobProfile $jobProfile) {
|
||||
return $jobProfile->getId();
|
||||
}, $filterDto->getJobProfiles()),
|
||||
|
||||
Reference in New Issue
Block a user