Merge remote-tracking branch 'origin/issue267_filter_household_of_the_person'

This commit is contained in:
Julien Fastré 2021-11-15 12:24:21 +01:00
commit 0aef40f23f
2 changed files with 16 additions and 6 deletions

View File

@ -11,8 +11,9 @@ and this project adheres to
## Unreleased
<!-- write down unreleased development here -->
* [main] fix adding multiple AddresseDeRelais (combine PickAddressType with ChillCollection)
* [main] fix adding multiple AddresseDeRelais (combine PickAddressType with ChillCollection)
* [person]: do not suggest the current household of the person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/51)
* unnecessary whitespace removed from person banner after person-id + double parentheses removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/290)
* [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36)
* [address]: Display of incomplete address adjusted.

View File

@ -47,13 +47,22 @@ class HouseholdApiController extends ApiController
$count = $this->householdRepository->countByAccompanyingPeriodParticipation($person);
$paginator = $this->getPaginatorFactory()->create($count);
if ($count === 0) {
$households = [];
} else {
$households = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
if ($count !== 0) {
$allHouseholds = $this->householdRepository->findByAccompanyingPeriodParticipation($person,
$paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
}
$currentHouseholdPerson = $person->getCurrentHousehold();
foreach ($allHouseholds as $h) {
if ($h !== $currentHouseholdPerson) {
array_push($households, $h);
}
}
if (null !== $currentHouseholdPerson) {
$count = $count - 1;
$paginator = $this->getPaginatorFactory()->create($count);
}
}
$collection = new Collection($households, $paginator);
return $this->json($collection, Response::HTTP_OK, [],