mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-19 22:29:51 +00:00
Merge branch '400-add-filter-mes-actions' into 'master'
Add a filter to list for acpw where current user intervenes Closes #400 See merge request Chill-Projet/chill-bundles!859
This commit is contained in:
commit
c0826bc65c
6
.changes/unreleased/Feature-20250717-110850.yaml
Normal file
6
.changes/unreleased/Feature-20250717-110850.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
kind: Feature
|
||||||
|
body: Add filter to social actions list to filter out actions where current user intervenes
|
||||||
|
time: 2025-07-17T11:08:50.128269232+02:00
|
||||||
|
custom:
|
||||||
|
Issue: "400"
|
||||||
|
SchemaChange: No schema change
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
namespace Chill\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
|
||||||
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
||||||
@ -130,6 +131,7 @@ final class AccompanyingCourseWorkController extends AbstractController
|
|||||||
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::SEE, $period);
|
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::SEE, $period);
|
||||||
|
|
||||||
$filter = $this->buildFilterOrder($period);
|
$filter = $this->buildFilterOrder($period);
|
||||||
|
$currentUser = $this->getUser();
|
||||||
|
|
||||||
$filterData = [
|
$filterData = [
|
||||||
'types' => $filter->hasEntityChoice('typesFilter') ? $filter->getEntityChoiceData('typesFilter') : [],
|
'types' => $filter->hasEntityChoice('typesFilter') ? $filter->getEntityChoiceData('typesFilter') : [],
|
||||||
@ -138,6 +140,10 @@ final class AccompanyingCourseWorkController extends AbstractController
|
|||||||
'user' => $filter->getUserPickerData('userFilter'),
|
'user' => $filter->getUserPickerData('userFilter'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($filter->getSingleCheckboxData('currentUserFilter') && $currentUser instanceof User) {
|
||||||
|
$filterData['currentUser'] = $currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
$totalItems = $this->workRepository->countByAccompanyingPeriod($period);
|
$totalItems = $this->workRepository->countByAccompanyingPeriod($period);
|
||||||
$paginator = $this->paginator->create($totalItems);
|
$paginator = $this->paginator->create($totalItems);
|
||||||
|
|
||||||
@ -201,6 +207,8 @@ final class AccompanyingCourseWorkController extends AbstractController
|
|||||||
->addUserPicker('userFilter', 'accompanying_course_work.user_filter', ['required' => false])
|
->addUserPicker('userFilter', 'accompanying_course_work.user_filter', ['required' => false])
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$filterBuilder->addSingleCheckbox('currentUserFilter', 'accompanying_course_work.my_actions_filter');
|
||||||
|
|
||||||
return $filterBuilder->build();
|
return $filterBuilder->build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
* * first, opened works
|
* * first, opened works
|
||||||
* * then, closed works
|
* * then, closed works
|
||||||
*
|
*
|
||||||
* @param array{types?: list<SocialAction>, user?: list<User>, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
* @param array{types?: list<SocialAction>, user?: list<User>, currentUser?: User, after?: \DateTimeImmutable|null, before?: \DateTimeImmutable|null} $filters
|
||||||
*
|
*
|
||||||
* @return AccompanyingPeriodWork[]
|
* @return AccompanyingPeriodWork[]
|
||||||
*/
|
*/
|
||||||
@ -101,6 +101,7 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
|
|
||||||
$sql = "SELECT {$rsm} FROM chill_person_accompanying_period_work w
|
$sql = "SELECT {$rsm} FROM chill_person_accompanying_period_work w
|
||||||
LEFT JOIN chill_person_accompanying_period_work_referrer AS rw ON accompanyingperiodwork_id = w.id
|
LEFT JOIN chill_person_accompanying_period_work_referrer AS rw ON accompanyingperiodwork_id = w.id
|
||||||
|
AND (rw.enddate IS NULL OR rw.enddate > CURRENT_DATE)
|
||||||
WHERE accompanyingPeriod_id = :periodId";
|
WHERE accompanyingPeriod_id = :periodId";
|
||||||
|
|
||||||
// implement filters
|
// implement filters
|
||||||
@ -119,6 +120,10 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
.')';
|
.')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($filters['currentUser'])) {
|
||||||
|
$sql .= ' AND rw.user_id = :currentUser';
|
||||||
|
}
|
||||||
|
|
||||||
$sql .= " AND daterange(:after::date, :before::date) && daterange(w.startDate, w.endDate, '[]')";
|
$sql .= " AND daterange(:after::date, :before::date) && daterange(w.startDate, w.endDate, '[]')";
|
||||||
|
|
||||||
// if the start and end date were inversed, we inverse the order to avoid an error
|
// if the start and end date were inversed, we inverse the order to avoid an error
|
||||||
@ -152,6 +157,11 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository
|
|||||||
->setParameter('limit', $limit, Types::INTEGER)
|
->setParameter('limit', $limit, Types::INTEGER)
|
||||||
->setParameter('offset', $offset, Types::INTEGER);
|
->setParameter('offset', $offset, Types::INTEGER);
|
||||||
|
|
||||||
|
if (isset($filters['currentUser'])) {
|
||||||
|
$nq->setParameter('currentUser', $filters['currentUser']->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($filters['user'] as $key => $user) {
|
foreach ($filters['user'] as $key => $user) {
|
||||||
$nq->setParameter('user_'.$key, $user);
|
$nq->setParameter('user_'.$key, $user);
|
||||||
}
|
}
|
||||||
|
@ -926,7 +926,7 @@ accompanying_course_work:
|
|||||||
types_filter: Filtrer par type d'action
|
types_filter: Filtrer par type d'action
|
||||||
user_filter: Filtrer par intervenant
|
user_filter: Filtrer par intervenant
|
||||||
On-going works over total: Actions en cours / Actions du parcours
|
On-going works over total: Actions en cours / Actions du parcours
|
||||||
|
my_actions_filter: Mes actions (où j'interviens)
|
||||||
|
|
||||||
#
|
#
|
||||||
Person addresses: Adresses de résidence
|
Person addresses: Adresses de résidence
|
||||||
|
Loading…
x
Reference in New Issue
Block a user