From ed9e5b6b476360faac3dcdcd91837e0579533eee Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sat, 12 Jul 2025 13:32:08 +0200 Subject: [PATCH] =?UTF-8?q?emoji=20pour=20le=20suivi=20de=20th=C3=A8me?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/utils.js | 11 ++++- src/Controller/AdminController.php | 52 ++++++++++++++----- templates/admin/followup_graph.html.twig | 2 +- templates/admin/stats.html.twig | 55 ++++++++++++++++++--- templates/public/stats_evolutions.html.twig | 2 +- 5 files changed, 101 insertions(+), 21 deletions(-) diff --git a/assets/utils.js b/assets/utils.js index 5abf5ad..9dd3c88 100644 --- a/assets/utils.js +++ b/assets/utils.js @@ -246,9 +246,16 @@ export function setupCitySearch(inputId, suggestionListId, onSelect) { suggestions.forEach(suggestion => { const item = document.createElement('div'); item.classList.add('suggestion-item'); - item.textContent = suggestion.display_name; + // Nouveau rendu : nom en gras, INSEE et CP en petit/gris + item.innerHTML = ` + ${suggestion.name} + + INSEE : ${suggestion.insee} + CP : ${Array.isArray(suggestion.postcodes) ? suggestion.postcodes.join(', ') : suggestion.postcode} + + `; item.addEventListener('click', () => { - searchInput.value = suggestion.display_name; + searchInput.value = suggestion.name; clearSuggestions(); if (onSelect) { onSelect(suggestion); diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 40e07f8..d60ecc0 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -1924,18 +1924,48 @@ final class AdminController extends AbstractController public static function getTagEmoji(string $mainTag): string { + // Si c'est un tag clรฉ=valeur, on garde le match existant + if (str_contains($mainTag, '=')) { + return match ($mainTag) { + 'amenity=restaurant', 'amenity=bar', 'amenity=cafe' => '๐Ÿฝ๏ธ', + 'amenity=townhall', 'amenity=community_centre' => '๐Ÿ›๏ธ', + 'amenity=bank', 'amenity=atm' => '๐Ÿฆ', + 'amenity=pharmacy', 'amenity=hospital', 'amenity=clinic' => '๐Ÿฅ', + 'amenity=school', 'amenity=kindergarten', 'amenity=university' => '๐ŸŽ“', + 'amenity=library', 'amenity=museum', 'amenity=artwork' => '๐Ÿ“š', + 'shop=car_repair', 'shop=car_parts', 'shop=car_wash' => '๐Ÿš—', + 'amenity=post_office' => '๐Ÿ“ฎ', + 'shop=convenience' => '๐Ÿช', + 'shop=supermarket' => '๐Ÿ›’', + 'shop=clothes' => '๐Ÿ‘•', + default => '๐Ÿท๏ธ', + }; + } + // Sinon, on regarde si c'est un tag principal simple return match ($mainTag) { - 'amenity=restaurant', 'amenity=bar', 'amenity=cafe' => '๐Ÿฝ๏ธ', - 'amenity=townhall', 'amenity=community_centre' => '๐Ÿ›๏ธ', - 'amenity=bank', 'amenity=atm' => '๐Ÿฆ', - 'amenity=pharmacy', 'amenity=hospital', 'amenity=clinic' => '๐Ÿฅ', - 'amenity=school', 'amenity=kindergarten', 'amenity=university' => '๐ŸŽ“', - 'amenity=library', 'amenity=museum', 'amenity=artwork' => '๐Ÿ“š', - 'shop=car_repair', 'shop=car_parts', 'shop=car_wash' => '๐Ÿš—', - 'amenity=post_office' => '๐Ÿ“ฎ', - 'shop=convenience' => '๐Ÿช', - 'shop=supermarket' => '๐Ÿ›’', - 'shop=clothes' => '๐Ÿ‘•', + 'bicycle_parking' => '๐Ÿšฒ', + 'building' => '๐Ÿข', + 'email' => '๐Ÿ“ง', + 'fire_hydrant' => '๐Ÿš’', + 'charging_station' => 'โšก', + 'toilets' => '๐Ÿšป', + 'bus_stop' => '๐ŸšŒ', + 'defibrillator' => 'โค๏ธโ€๐Ÿฉน', + 'camera' => '๐Ÿ“ท', + 'recycling' => 'โ™ป๏ธ', + 'substation' => '๐Ÿญ', + 'laboratory' => '๐Ÿงช', + 'school' => '๐Ÿซ', + 'police' => '๐Ÿ‘ฎ', + 'healthcare' => '๐Ÿฅ', + 'advertising_board' => '๐Ÿชง', + 'bench' => '๐Ÿช‘', + 'waste_basket' => '๐Ÿ—‘๏ธ', + 'street_lamp' => '๐Ÿ’ก', + 'drinking_water' => '๐Ÿšฐ', + 'tree' => '๐ŸŒณ', + 'places' => '๐Ÿ“', + 'power_pole' => 'โšก', default => '๐Ÿท๏ธ', }; } diff --git a/templates/admin/followup_graph.html.twig b/templates/admin/followup_graph.html.twig index ba93d4d..afebede 100644 --- a/templates/admin/followup_graph.html.twig +++ b/templates/admin/followup_graph.html.twig @@ -37,7 +37,7 @@ - {{ diff.label }} + {{ tag_emoji(type) }} {{ diff.label }} diff --git a/templates/admin/stats.html.twig b/templates/admin/stats.html.twig index a734129..71d00cc 100644 --- a/templates/admin/stats.html.twig +++ b/templates/admin/stats.html.twig @@ -655,6 +655,36 @@ document.addEventListener('DOMContentLoaded', function() { const geojsonData = {{ geojson|raw }}; const map_token = "{{ maptiler_token }}"; + // Liste des tags attendus pour la complรฉtion des lieux + const completionTags = {{ completion_tags['places']|json_encode|raw }}; + // Calcul de la complรฉtion et des tags manquants pour chaque lieu + geojsonData.features.forEach(f => { + let filled = 0; + let missing = []; + if (completionTags && completionTags.length > 0) { + completionTags.forEach(tag => { + if (f.properties && typeof f.properties[tag] !== 'undefined' && f.properties[tag] !== null && f.properties[tag] !== '') { + filled++; + } else { + missing.push(tag); + } + }); + } + f.properties.completion = completionTags && completionTags.length > 0 ? Math.round(100 * filled / completionTags.length) : null; + // Correction : toujours un tableau + f.properties.missing_tags = Array.isArray(f.properties.missing_tags) ? f.properties.missing_tags : (f.properties.missing_tags ? [f.properties.missing_tags] : []); + }); + // Fonction de couleur dรฉgradรฉe + function lerpColor(a, b, t) { + const ah = a.replace('#', ''); + const bh = b.replace('#', ''); + const ar = parseInt(ah.substring(0,2), 16), ag = parseInt(ah.substring(2,4), 16), ab = parseInt(ah.substring(4,6), 16); + const br = parseInt(bh.substring(0,2), 16), bg = parseInt(bh.substring(2,4), 16), bb = parseInt(bh.substring(4,6), 16); + const rr = Math.round(ar + (br-ar)*t); + const rg = Math.round(ag + (bg-ag)*t); + const rb = Math.round(ab + (bb-ab)*t); + return '#' + rr.toString(16).padStart(2,'0') + rg.toString(16).padStart(2,'0') + rb.toString(16).padStart(2,'0'); + } let map; let map_is_loaded = false; let currentMode = 'drop'; @@ -682,10 +712,9 @@ 'case', ['has', 'completion'], [ - 'rgb', - 0, - ['*', ['get', 'completion'], 2.55], - 0 + 'interpolate', ['linear'], ['get', 'completion'], + 0, '#cccccc', + 100, '#008000' ], '#cccccc' ], @@ -701,7 +730,16 @@ source: 'places', filter: ['!', ['has', 'point_count']], paint: { - 'circle-color': '#11b4da', + 'circle-color': [ + 'case', + ['has', 'completion'], + [ + 'interpolate', ['linear'], ['get', 'completion'], + 0, '#cccccc', + 100, '#008000' + ], + '#cccccc' + ], 'circle-radius': 8, 'circle-stroke-width': 2, 'circle-stroke-color': '#fff' @@ -795,7 +833,12 @@ if (properties.address) popupContent += `${properties.address}
`; if (properties.main_tag) popupContent += `${properties.main_tag}
`; if (properties.note) popupContent += `Note: ${properties.note}
`; - popupContent += `Voir sur OSM`; + popupContent += `Complรฉtion : ${properties.completion !== null ? properties.completion + '%' : 'โ€“'}`; + const missingTags = Array.isArray(properties.missing_tags) ? properties.missing_tags : []; + if (missingTags.length > 0) { + popupContent += `
Manque : ${missingTags.map(t => `${t}`).join(', ')}
`; + } + popupContent += `
Voir sur OSM`; while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) { coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360; diff --git a/templates/public/stats_evolutions.html.twig b/templates/public/stats_evolutions.html.twig index c6e945e..71cea2e 100644 --- a/templates/public/stats_evolutions.html.twig +++ b/templates/public/stats_evolutions.html.twig @@ -29,7 +29,7 @@ title="Voir le graphe dรฉtaillรฉ"> - {{ type }} + {{ tag_emoji(type) }} {{ type }} {{ evo.now }} {% for p in periods %}