diff --git a/assets/app.js b/assets/app.js index 5dd8ae4..aeff00b 100644 --- a/assets/app.js +++ b/assets/app.js @@ -16,6 +16,56 @@ document.addEventListener('DOMContentLoaded', () => { console.log('DOMContentLoaded'); + function updateMapHeightForLargeScreens() { + + const map = document.querySelector('#map'); + // Vérifier si on est sur une page avec un titre h1 contenant "statistiques" + const h1Element = document.querySelector('h1'); + if (h1Element && h1Element.textContent.toLowerCase().includes('statistiques')) { + if (map && window.innerHeight > 800 && window.innerWidth > 800) { + map.style.height = '80vh'; + } + } + } + + updateMapHeightForLargeScreens() + + function check_validity(e) { + let errors = []; + document.querySelectorAll('.is-invalid').forEach(input => { + input.classList.remove('is-invalid'); + }); + + const nameInput = document.querySelector('input[name="commerce_tag_value__name"]'); + if (!nameInput.value.trim()) { + errors.push("Le nom de l'établissement est obligatoire"); + nameInput.classList.add('is-invalid'); + } + + const emailInput = document.querySelector('input[name="commerce_tag_value__contact:email"]'); + if (emailInput && emailInput.value) { + const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + if (!emailRegex.test(emailInput.value)) { + errors.push("L'adresse email n'est pas valide"); + emailInput.classList.add('is-invalid'); + } + } + + const phoneInput = document.querySelector('input[name="commerce_tag_value__contact:phone"]'); + if (phoneInput && phoneInput.value) { + const phoneRegex = /^(\+33|0)[1-9](\d{2}){4}$/; + if (!phoneRegex.test(phoneInput.value.replace(/\s/g, ''))) { + errors.push("Le numéro de téléphone n'est pas valide"); + phoneInput.classList.add('is-invalid'); + } + } + + if (errors.length > 0) { + e.preventDefault(); + document.querySelector('#validation_messages').innerHTML = errors.join('
'); + document.querySelector('#validation_messages').classList.add('is-invalid'); + } + } // Générer une couleur pastel aléatoire const genererCouleurPastel = () => { // Utiliser des valeurs plus claires (180-255) pour obtenir des tons pastel diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index e4c04cc..68b0035 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -172,13 +172,16 @@ class PublicController extends AbstractController // get stats $stats = $this->entityManager->getRepository(Stats::class)->findAll(); - $places = $this->entityManager->getRepository(Place::class)->findBy([], ['zip_code' => 'ASC', 'name' => 'ASC']); + + // Compter le nombre total de lieux + $placesCount = $this->entityManager->getRepository(Place::class)->count([]); return $this->render('public/dashboard.html.twig', [ 'controller_name' => 'PublicController', 'mapbox_token' => $_ENV['MAPBOX_TOKEN'], 'maptiler_token' => $_ENV['MAPTILER_TOKEN'], 'stats' => $stats, - 'places' => $places, + + 'places_count' => $placesCount, ]); } diff --git a/templates/public/dashboard.html.twig b/templates/public/dashboard.html.twig index 267d007..4a9f3cc 100644 --- a/templates/public/dashboard.html.twig +++ b/templates/public/dashboard.html.twig @@ -266,7 +266,7 @@ out skel qt;`; -

{{ places|length }} Lieux

+

{{ places_count }} Lieux

diff --git a/templates/public/edit.html.twig b/templates/public/edit.html.twig index 19fc160..af7bd91 100644 --- a/templates/public/edit.html.twig +++ b/templates/public/edit.html.twig @@ -174,42 +174,7 @@ {{ parent() }}