From cb90be8ff2e692f084d34b39427b5a6a92659307 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sun, 1 Jun 2025 23:35:15 +0200 Subject: [PATCH] list notes --- migrations/Version20250601212218.php | 35 +++++++++++++++++++++ src/Controller/AdminController.php | 16 +++++++++- src/Controller/PublicController.php | 4 ++- src/DataFixtures/HistoryFixtures.php | 2 +- src/Entity/Place.php | 15 +++++++++ src/Service/Motocultrice.php | 18 +++++------ templates/admin/stats.html.twig | 34 +++++++++++++++++--- templates/public/dashboard.html.twig | 25 +++++---------- templates/public/edit.html.twig | 4 +-- templates/public/places_with_note.html.twig | 2 +- 10 files changed, 119 insertions(+), 36 deletions(-) create mode 100644 migrations/Version20250601212218.php diff --git a/migrations/Version20250601212218.php b/migrations/Version20250601212218.php new file mode 100644 index 0000000..557cad3 --- /dev/null +++ b/migrations/Version20250601212218.php @@ -0,0 +1,35 @@ +addSql(<<<'SQL' + ALTER TABLE place ADD note_content VARCHAR(255) DEFAULT NULL + SQL); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql(<<<'SQL' + ALTER TABLE place DROP note_content + SQL); + } +} diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index c7094e6..1993182 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -78,6 +78,19 @@ final class AdminController extends AbstractController ]); } + #[Route('/admin/placeType/{osm_kind}/{osm_id}', name: 'app_admin_by_osm_id')] + public function placeType(string $osm_kind, string $osm_id): Response + { + $place = $this->entityManager->getRepository(Place::class)->findOneBy(['osm_kind' => $osm_kind, 'osmId' => $osm_id]); + if($place) { + return $this->redirectToRoute('app_admin_commerce', ['id' => $place->getId()]); + } else { + $this->addFlash('error', 'Le lieu n\'existe pas.'); + return $this->redirectToRoute('app_public_index'); + } + } + + #[Route('/admin/commerce/{id}', name: 'app_admin_commerce')] public function commerce(int $id): Response { @@ -221,7 +234,8 @@ final class AdminController extends AbstractController ->setHasAddress(($result['tags'] && isset($result['tags']['address']) || $result['tags'] && isset($result['tags']['contact:address'])) ? isset($result['tags']['address']) : null) ->setHasWebsite($result['tags'] && isset($result['tags']['website']) ? $result['tags']['website'] : null) ->setHasWheelchair($result['tags'] && isset($result['tags']['wheelchair']) ? $result['tags']['wheelchair'] : null) - ->setHasNote($result['tags'] && isset($result['tags']['note']) ? $result['tags']['note'] : null) + ->setHasNote($result['tags'] && isset($result['tags']['note']) ? $result['tags']['note'] : null) + ->setNoteContent($result['tags'] && isset($result['tags']['note']) ? $result['tags']['note'] : null) ; $this->entityManager->persist($commerce); } diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 7e86e8e..af39e86 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -152,6 +152,7 @@ class PublicController extends AbstractController 'commerce_overpass' => $commerce_overpass, 'name' => $name, 'commerce' => $place, + 'zone' => $zipcode, 'completion_percentage' => $place->getCompletionPercentage(), 'hide_filled_inputs' => $this->hide_filled_inputs, 'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render, @@ -416,7 +417,8 @@ class PublicController extends AbstractController #[Route('/places_with_note', name: 'app_public_places_with_note')] public function places_with_note(): Response { - $places = $this->entityManager->getRepository(Place::class)->findBy(['note' => '']); + // Récupérer tous les commerces ayant une note + $places = $this->entityManager->getRepository(Place::class)->findBy(['has_note' => true]); return $this->render('public/places_with_note.html.twig', [ 'controller_name' => 'PublicController', 'places' => $places diff --git a/src/DataFixtures/HistoryFixtures.php b/src/DataFixtures/HistoryFixtures.php index 8a3aa87..4c1f7e1 100644 --- a/src/DataFixtures/HistoryFixtures.php +++ b/src/DataFixtures/HistoryFixtures.php @@ -49,7 +49,7 @@ class HistoryFixtures extends Fixture // Créer des statistiques de test for ($i = 0; $i < 3; $i++) { $stat = new Stats(); - $stat->setZone($faker->city . ' (mock)') + $stat->setZone($faker->numberBetween(10000, 99999) ) ->setCompletionPercent($faker->numberBetween(0, 100)) ->addPlace( $faker->randomElement($places_list)) ->addPlace( $faker->randomElement($places_list)) diff --git a/src/Entity/Place.php b/src/Entity/Place.php index 134e17e..285a9c4 100644 --- a/src/Entity/Place.php +++ b/src/Entity/Place.php @@ -79,6 +79,9 @@ class Place #[ORM\Column(nullable: true)] private ?string $main_tag = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $note_content = null; + public function getMainTag(): ?string { return $this->main_tag; @@ -416,4 +419,16 @@ class Place return $this; } + + public function getNoteContent(): ?string + { + return $this->note_content; + } + + public function setNoteContent(?string $note_content): static + { + $this->note_content = $note_content; + + return $this; + } } diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index ebaf6c0..34f00a7 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -128,17 +128,17 @@ class Motocultrice area["postal_code"="{$zone}"]->.searchArea; ( // Recherche des commerces et services avec email - nw["amenity"]["contact:email"](area.searchArea); - nw["amenity"]["email"](area.searchArea); - nw["shop"]["contact:email"](area.searchArea); - nw["shop"]["email"](area.searchArea); - nw["office"]["contact:email"](area.searchArea); - nw["office"]["email"](area.searchArea); + nw["amenity"]["contact:email"][name](area.searchArea); + nw["amenity"]["email"][name](area.searchArea); + nw["shop"]["contact:email"][name](area.searchArea); + nw["shop"]["email"][name](area.searchArea); + nw["office"]["contact:email"][name](area.searchArea); + nw["office"]["email"][name](area.searchArea); // Recherche des commerces et services sans email pour référence - nw["amenity"](area.searchArea); - nw["shop"](area.searchArea); - nw["office"](area.searchArea); + nw["amenity"][name](area.searchArea); + nw["shop"][name](area.searchArea); + nw["office"][name](area.searchArea); ); out body; >; diff --git a/templates/admin/stats.html.twig b/templates/admin/stats.html.twig index 5123775..ace16e4 100644 --- a/templates/admin/stats.html.twig +++ b/templates/admin/stats.html.twig @@ -36,10 +36,12 @@ Nom ({{ stats.getPlacesCount() }}) + Type Adresse ({{ stats.getAvecAdresse() }} / {{ stats.getPlacesCount() }}) Site web ({{ stats.getAvecSite() }} / {{ stats.getPlacesCount() }}) Accessibilité ({{ stats.getAvecAccessibilite() }} / {{ stats.getPlacesCount() }}) Note ({{ stats.getAvecNote() }} / {{ stats.getPlacesCount() }}) + Note ({{ stats.getAvecNote() }} / {{ stats.getPlacesCount() }}) @@ -48,10 +50,12 @@ {{ commerce.name }} + {{ commerce.mainTag }} {{ commerce.address }} {{ commerce.website }} {{ commerce.wheelchair }} - {{ commerce.note }} + {{ commerce.note }} + {{ commerce.noteContent }} {% endfor %} @@ -88,9 +92,15 @@ }); map.on('load', () => { - console.log(data.elements); + console.log('map chargé',data.elements); data.elements.forEach(element => { - if (element.lat && element.lon) { + if(element.tags){ + + console.log('element', element.tags['name'] , element); + } + + if (element.lat && element.lon && element.tags && element.tags['name']) { + const el = document.createElement('div'); el.className = 'marker'; el.style.width = '20px'; @@ -105,10 +115,26 @@ } tagstable += ''; + // Créer un élément div pour le texte du nom + const nameDiv = document.createElement('div'); + nameDiv.className = 'marker-name'; + nameDiv.style.position = 'absolute'; + nameDiv.style.backgroundColor = 'white'; + nameDiv.style.padding = '2px 5px'; + nameDiv.style.borderRadius = '3px'; + nameDiv.style.fontSize = '12px'; + nameDiv.style.whiteSpace = 'nowrap'; + nameDiv.style.transform = 'translate(-50%, -150%)'; + nameDiv.textContent = element.tags?.name || 'Sans nom'; + el.appendChild(nameDiv); + new maplibregl.Marker(el) .setLngLat([element.lon, element.lat]) .setPopup(new maplibregl.Popup({ offset: 25 }) - .setHTML(`

${element.tags?.name || 'Sans nom'}


${tagstable}`)) + .setHTML( + `

${element.tags?.name || 'Sans nom'}


OSM ${tagstable}` + ) + ) .addTo(map); } }); diff --git a/templates/public/dashboard.html.twig b/templates/public/dashboard.html.twig index 2cf5c97..992c006 100644 --- a/templates/public/dashboard.html.twig +++ b/templates/public/dashboard.html.twig @@ -21,7 +21,8 @@ {{ parent() }} - {% endblock %} diff --git a/templates/public/edit.html.twig b/templates/public/edit.html.twig index ad6bbe2..8f452eb 100644 --- a/templates/public/edit.html.twig +++ b/templates/public/edit.html.twig @@ -147,7 +147,7 @@ - + {{ 'display.view_stats'|trans }} @@ -225,7 +225,7 @@ new mapboxgl.Marker() .setLngLat([{{ commerce_overpass['@attributes'].lon }}, {{ commerce_overpass['@attributes'].lat }}]) - .setPopup(new mapboxgl.Popup({ offset: 25 }).setHTML('

{{ commerce_overpass.tags_converted.name }}

Completion:{{completion_percentage}}%

')) + .setPopup(new mapboxgl.Popup({ offset: 25 }).setHTML('

{{ commerce_overpass.tags_converted.name }}

')) .addTo(map); {% endif %} diff --git a/templates/public/places_with_note.html.twig b/templates/public/places_with_note.html.twig index 1ca7074..4d4c1ee 100644 --- a/templates/public/places_with_note.html.twig +++ b/templates/public/places_with_note.html.twig @@ -25,7 +25,7 @@ {{place.zipcode}} - {{ place.note }} + {{ place.noteContent }}