feat: hide inactive teamers from list view, overridable in filter
addresses #869dv987y
This commit is contained in:
@@ -7,6 +7,8 @@ parameters:
|
||||
default_email_from: '%env(APP_DEFAULT_EMAIL_FROM)%'
|
||||
default_email_to: '%env(APP_DEFAULT_EMAIL_TO)%'
|
||||
|
||||
teamer_inactive_period: '-2 years'
|
||||
|
||||
destinations:
|
||||
- Schwendi
|
||||
- Waldschlössli
|
||||
@@ -38,6 +40,7 @@ services:
|
||||
$destinations: '%destinations%'
|
||||
$xmlExport: '@xml_export.storage'
|
||||
$xmlDump: '@xml_dump.storage'
|
||||
$teamerInactivePeriod: '%teamer_inactive_period%'
|
||||
|
||||
App\:
|
||||
resource: '../src/'
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
{{ form_row(filterForm.snowboardLicense) }}
|
||||
{{ form_row(filterForm.driverLicenseVerified) }}
|
||||
{{ form_row(filterForm.noTrainings) }}
|
||||
{{ form_row(filterForm.includeInactive) }}
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
{{ form_widget(filterForm.apply, { 'attr': { 'class': 'btn' } }) }}
|
||||
|
||||
Reference in New Issue
Block a user