From 21e24c60c7cedae14de0a3b5d95b38a867a10da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 15 Mar 2023 15:56:46 +0100 Subject: [PATCH] Feature: show list of geographical units which covers address in address details modal --- .../Controller/AddressToReferenceMatcher.php | 15 +++++ .../ChillMainExtension.php | 15 +++++ .../Entity/GeographicalUnitLayer.php | 4 ++ .../Resources/public/lib/api/address.ts | 11 +++- .../ChillMainBundle/Resources/public/types.ts | 13 +++++ .../AddressDetails/AddressDetailsContent.vue | 5 +- .../AddressDetailsGeographicalLayers.vue | 55 +++++++++++++++++++ .../Parts/AddressDetailsMap.vue | 10 ++-- 8 files changed, 119 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcher.php create mode 100644 src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/Parts/AddressDetailsGeographicalLayers.vue diff --git a/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcher.php b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcher.php new file mode 100644 index 000000000..2fbd6b0ec --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/AddressToReferenceMatcher.php @@ -0,0 +1,15 @@ + GeographicalUnitLayer::class, + 'name' => 'geographical-unit-layer', + 'base_path' => '/api/1.0/main/geographical-unit-layer', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_index' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + ], + ], + ], + ] ], ]); } diff --git a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php index bdea40563..b856c7a21 100644 --- a/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php +++ b/src/Bundle/ChillMainBundle/Entity/GeographicalUnitLayer.php @@ -14,6 +14,7 @@ namespace Chill\MainBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; /** * @ORM\Table(name="chill_main_geographical_unit_layer", uniqueConstraints={ @@ -27,16 +28,19 @@ class GeographicalUnitLayer * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") + * @Serializer\Groups({"read"}) */ private ?int $id = null; /** * @ORM\Column(type="json", nullable=false, options={"default": "[]"}) + * @Serializer\Groups({"read"}) */ private array $name = []; /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) + * @Serializer\Groups({"read"}) */ private string $refId = ''; diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/api/address.ts b/src/Bundle/ChillMainBundle/Resources/public/lib/api/address.ts index d039daf12..1f0d6ae8a 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/api/address.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/api/address.ts @@ -1,4 +1,5 @@ -import {Address} from "../../types"; +import {Address, GeographicalUnitLayer, SimpleGeographicalUnit} from "../../types"; +import {fetchResults, makeFetch} from "./apiMethods"; export const getAddressById = async (address_id: number): Promise
=> { @@ -12,3 +13,11 @@ export const getAddressById = async (address_id: number): Promise
=> throw Error('Error with request resource response'); }; + +export const getGeographicalUnitsByAddress = async (address: Address): Promise => { + return fetchResults(`/api/1.0/main/geographical-unit/by-address/${address.address_id}.json`); +} + +export const getAllGeographicalUnitLayers = async (): Promise => { + return fetchResults(`/api/1.0/main/geographical-unit-layer.json`); +} diff --git a/src/Bundle/ChillMainBundle/Resources/public/types.ts b/src/Bundle/ChillMainBundle/Resources/public/types.ts index 3deb1d229..b31b70897 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/types.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/types.ts @@ -115,6 +115,19 @@ export interface AddressReference { updatedAt: DateTime | null; } +export interface SimpleGeographicalUnit { + id: number; + layerId: number; + unitName: string; + unitRefId: string; +} + +export interface GeographicalUnitLayer { + id: number; + name: TranslatableString; + refId: string; +} + export interface Location { type: "location"; id: number; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsContent.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsContent.vue index 95378b543..5a9a97b46 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsContent.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/AddressDetailsContent.vue @@ -1,13 +1,14 @@ + + diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/Parts/AddressDetailsMap.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/Parts/AddressDetailsMap.vue index 967b16d8c..35a2bbc33 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/Parts/AddressDetailsMap.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddressDetails/Parts/AddressDetailsMap.vue @@ -3,8 +3,7 @@ Cette adresse est incomplète. La position géographique est approximative.
- Google Maps - OSM +

Voir sur Google Maps OSM