diff --git a/assets/js/map-utils.js b/assets/js/map-utils.js new file mode 100644 index 0000000..0172253 --- /dev/null +++ b/assets/js/map-utils.js @@ -0,0 +1,161 @@ +// Fonctions utilitaires pour la gestion des marqueurs et popups sur la carte + +function getCompletionColor(completion) { + if (completion === undefined || completion === null) { + return '#808080'; // Gris pour pas d'information + } + // Convertir le pourcentage en couleur verte (0% = blanc, 100% = vert foncé) + const intensity = Math.floor((completion / 100) * 255); + return `rgb(0, ${intensity}, 0)`; +} + +function calculateCompletion(element) { + let completionCount = 0; + let totalFields = 0; + let missingFields = []; + + const fieldsToCheck = [ + { name: 'name', label: 'Nom du commerce' }, + { name: 'contact:street', label: 'Rue' }, + { name: 'contact:housenumber', label: 'Numéro' }, + { name: 'opening_hours', label: 'Horaires d\'ouverture' }, + { name: 'contact:website', label: 'Site web' }, + { name: 'contact:phone', label: 'Téléphone' }, + { name: 'wheelchair', label: 'Accessibilité PMR' } + ]; + + fieldsToCheck.forEach(field => { + totalFields++; + if (element.tags && element.tags[field.name]) { + completionCount++; + } else { + missingFields.push(field.label); + } + }); + + return { + percentage: (completionCount / totalFields) * 100, + missingFields: missingFields + }; +} + +function createPopupContent(element) { + const completion = calculateCompletion(element); + let content = ` +
${tag} | ${element.tags[tag]} |
lieux trouvés en plus: {{ new_places_counter }} diff --git a/templates/admin/stats.html.twig b/templates/admin/stats.html.twig index a4cf711..ca97e46 100644 --- a/templates/admin/stats.html.twig +++ b/templates/admin/stats.html.twig @@ -22,6 +22,13 @@ {% endblock %} +{% block javascripts %} + {{ parent() }} + + + +{% endblock %} + {% block body %}
Date | +Places | +Complétion | +
---|---|---|
{{ stat.date|date('d/m/Y') }} | +{{ stat.placesCount }} | +{{ stat.completionPercent }}% | +
Comment est calculé le score de complétion ?
+ +