From cd85e37c1bf02cabe011aca75dee54fa99146cee Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 14 Sep 2023 14:30:58 +0200 Subject: [PATCH] do active center filtering in frontend for person creation --- .../Serializer/Normalizer/CenterNormalizer.php | 1 + .../ChillPersonBundle/Controller/PersonApiController.php | 2 -- .../Resources/public/vuejs/_components/OnTheFly/Person.vue | 7 ++++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php index e0b2a3e96..578fc4ce2 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php @@ -63,6 +63,7 @@ class CenterNormalizer implements DenormalizerInterface, NormalizerInterface 'id' => $center->getId(), 'type' => 'center', 'name' => $center->getName(), + 'isActive' => $center->getIsActive() ]; } diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php index 0ca3bd94a..78dfc268c 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -53,8 +53,6 @@ class PersonApiController extends ApiController { $centers = $this->authorizedCenterOnPersonCreation->getCenters(); - // $centersActive = array_filter($centers, fn(Center $c) => $c->getIsActive()); - return $this->json( ['showCenters' => $this->showCenters, 'centers' => $centers], Response::HTTP_OK, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 16a76c780..46d78b77c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -329,12 +329,13 @@ export default { if (this.action !== 'create') { this.loadData(); } else { - console.log('show centers', this.showCenters); + // console.log('show centers', this.showCenters); getCentersForPersonCreation() .then(params => { - this.config.centers = params.centers; + this.config.centers = params.centers.filter(c => c.isActive); 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) { this.person.center = this.config.centers[0]; }