From 1646740382e76dfb7e7372e38ef69f3a6fe9ebb4 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 3 Nov 2021 09:59:40 +0100 Subject: [PATCH 1/9] location: filter location endpoint by NULL names --- .../ChillMainBundle/Controller/LocationApiController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php index 5c0301959..c21eaaf26 100644 --- a/src/Bundle/ChillMainBundle/Controller/LocationApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/LocationApiController.php @@ -22,12 +22,15 @@ class LocationApiController extends ApiController ), $query->expr()->andX( $query->expr()->eq('e.availableForUsers', "'TRUE'"), - $query->expr()->eq('e.active', "'TRUE'") + $query->expr()->eq('e.active', "'TRUE'"), + $query->expr()->isNotNull('e.name'), + $query->expr()->neq('e.name', ':emptyString'), ) )) ->setParameters([ 'user' => $this->getUser(), - 'dateBefore' => (new \DateTime())->sub(new \DateInterval('P6M')) + 'dateBefore' => (new \DateTime())->sub(new \DateInterval('P6M')), + 'emptyString' => '', ]); } -} +} \ No newline at end of file From 999658e79290b6c9f54daeb96d225632a4c83cf9 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 3 Nov 2021 10:27:58 +0100 Subject: [PATCH 2/9] location: filter location-type by active and availableForUsers --- .../Controller/LocationTypeApiController.php | 25 +++++++++++++++++++ .../ChillMainExtension.php | 1 + 2 files changed, 26 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Controller/LocationTypeApiController.php diff --git a/src/Bundle/ChillMainBundle/Controller/LocationTypeApiController.php b/src/Bundle/ChillMainBundle/Controller/LocationTypeApiController.php new file mode 100644 index 000000000..2a3a6cc59 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/LocationTypeApiController.php @@ -0,0 +1,25 @@ +andWhere( + $query->expr()->andX( + $query->expr()->eq('e.availableForUsers', "'TRUE'"), + $query->expr()->eq('e.active', "'TRUE'"), + ) + ); + } +} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 972c046d9..71b642b43 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -520,6 +520,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, ], [ 'class' => \Chill\MainBundle\Entity\LocationType::class, + 'controller' => \Chill\MainBundle\Controller\LocationTypeApiController::class, 'name' => 'location_type', 'base_path' => '/api/1.0/main/location-type', 'base_role' => 'ROLE_USER', From c8bc6ac4952febe89fe3be6f7484ffac0d9bb266 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 3 Nov 2021 11:34:52 +0100 Subject: [PATCH 3/9] location: code refactoring: move saveNewLocation + order of fields --- .../vuejs/Activity/components/Location.vue | 27 +-- .../components/Location/NewLocation.vue | 167 +++++++++++------- 2 files changed, 110 insertions(+), 84 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue index 0dbf2652a..30a1c5bd9 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location.vue @@ -20,7 +20,7 @@ v-model="location"> - + @@ -30,7 +30,7 @@ import { mapState } from "vuex"; import VueMultiselect from 'vue-multiselect'; import NewLocation from './Location/NewLocation.vue'; -import { getLocations, postLocation } from '../api.js'; +import { getLocations } from '../api.js'; export default { name: "Location", @@ -67,29 +67,6 @@ export default { }, customLabel(value) { return `${value.locationType.title.fr} ${value.name}`; - }, - saveNewLocation(selected) { - console.log('saveNewLocation', selected); - let body = { - type: 'location', - name: selected.name, - address: { - id: selected.addressId - }, - locationType: { - id: selected.type, - type: 'location-type' - }, - phonenumber1: selected.phonenumber1, - phonenumber2: selected.phonenumber2, - email: selected.email, - } - postLocation(body).then(location => new Promise(resolve => { - console.log('postLocation', location); - this.locations.push(location); - this.$store.dispatch('updateLocation', location); - resolve(); - })); } } } diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue index 3ffb2a33f..2515e37fc 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue @@ -1,75 +1,86 @@