do active center filtering in frontend for person creation

This commit is contained in:
Julie Lenaerts 2023-09-14 14:30:58 +02:00
parent b4f9501af5
commit cd85e37c1b
3 changed files with 5 additions and 5 deletions

View File

@ -63,6 +63,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface
'id' => $center->getId(), 'id' => $center->getId(),
'type' => 'center', 'type' => 'center',
'name' => $center->getName(), 'name' => $center->getName(),
'isActive' => $center->getIsActive()
]; ];
} }

View File

@ -53,8 +53,6 @@ class PersonApiController extends ApiController
{ {
$centers = $this->authorizedCenterOnPersonCreation->getCenters(); $centers = $this->authorizedCenterOnPersonCreation->getCenters();
// $centersActive = array_filter($centers, fn(Center $c) => $c->getIsActive());
return $this->json( return $this->json(
['showCenters' => $this->showCenters, 'centers' => $centers], ['showCenters' => $this->showCenters, 'centers' => $centers],
Response::HTTP_OK, Response::HTTP_OK,

View File

@ -329,12 +329,13 @@ export default {
if (this.action !== 'create') { if (this.action !== 'create') {
this.loadData(); this.loadData();
} else { } else {
console.log('show centers', this.showCenters); // console.log('show centers', this.showCenters);
getCentersForPersonCreation() getCentersForPersonCreation()
.then(params => { .then(params => {
this.config.centers = params.centers; this.config.centers = params.centers.filter(c => c.isActive);
this.showCenters = params.showCenters; this.showCenters = params.showCenters;
console.log('show centers inside', this.showCenters); // console.log('centers', this.config.centers)
// console.log('show centers inside', this.showCenters);
if (this.showCenters && this.config.centers.length === 1) { if (this.showCenters && this.config.centers.length === 1) {
this.person.center = this.config.centers[0]; this.person.center = this.config.centers[0];
} }