From 2bcec59281cf886ddae834ae786f030ae799df8d Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 7 Jul 2025 23:06:04 +0200 Subject: [PATCH] ajout infos formulaire envoi --- src/Controller/PublicController.php | 24 +++-- src/Service/Motocultrice.php | 20 ++-- templates/admin/stats/row.html.twig | 7 ++ templates/admin/stats/table-head.html.twig | 4 + templates/public/_tags_textarea.html.twig | 4 + templates/public/edit.html.twig | 62 ++++++++---- templates/public/edit/ask_angela.html.twig | 5 +- templates/public/edit/social_media.html.twig | 13 ++- templates/public/edit/tags.html.twig | 5 +- .../edit/yenaunpeuplusjevouslemets.html.twig | 32 +++---- templates/public/view.html.twig | 96 +++++++++++++++++++ 11 files changed, 211 insertions(+), 61 deletions(-) create mode 100644 templates/public/_tags_textarea.html.twig diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 00248df..5d98a8e 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -316,16 +316,26 @@ class PublicController extends AbstractController $osm_kind = $request->request->get('osm_kind', 'node'); // Récupérer tous les tags du formulaire $tags = []; - $request_post = $request->request->all(); + $request_post = $request->request->all(); $request_post = $this->motocultrice->map_post_values($request_post); + $request_post = $request_post ?? []; + // Log temporaire pour debug POST + file_put_contents('/tmp/debug_post.txt', print_r($request_post, true)); + // Debug visuel immédiat + $excluded_post_fields = []; foreach ($request_post as $key => $value) { if (strpos($key, 'commerce_tag_value__') === 0) { $tagKey = str_replace('commerce_tag_value__', '', $key); - if (!empty($value)) { - $tags[$tagKey] = trim($value); - } + // On ajoute la clé même si la valeur est vide (pour affichage suppression) + $tags[$tagKey] = trim($value); + } else { + $excluded_post_fields[] = $key; } } + // Récupérer les tags Overpass avant modification + $currentObjectData = $this->motocultrice->get_osm_object_data($osm_kind, $osm_object_id); + $tags_before_modif = $currentObjectData['tags_converted'] ?? []; + $tags_after_modif = $tags; // var_dump('POST brut', $_POST); // var_dump('request->request->all()', $request->request->all()); // var_dump('tags extraits', $tags); @@ -359,9 +369,6 @@ class PublicController extends AbstractController $newChangesetId = $changesetResponse->getBody()->getContents(); - // Récupérer les données actuelles de l'objet - $currentObjectData = $this->motocultrice->get_osm_object_data($osm_kind, $osm_object_id); - // 2. Modifier l'objet avec le nouveau changeset $xml = new \SimpleXMLElement(''); $object = $xml->addChild($osm_kind); @@ -474,6 +481,9 @@ class PublicController extends AbstractController 'maptiler_token' => $_ENV['MAPTILER_TOKEN'], 'hide_filled_inputs' => false, 'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render, + 'tags_before_modif' => $tags_before_modif ?? null, + 'tags_after_modif' => $tags_after_modif ?? null, + 'excluded_post_fields' => $excluded_post_fields ?? null, ]); } diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index 742486e..75db507 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -123,22 +123,25 @@ out meta;'; ) { } + /** + * fait le lien entre les tags du formulaire et les tags OSM pour les champs personnalisés + * + * @param [type] $request_post + * @return void + */ public function map_post_values($request_post) { - $has_ask_angela = false; - $remove_ask_angela = false; + $has_ask_angela = false; $has_opening_hours = false; $modified_request_post = []; - + foreach ($request_post as $key => $value) { if (strpos($key, 'custom__ask_angela') === 0 ) { if($value == 'ask_angela'){ $has_ask_angela = true; - }else{ - $remove_ask_angela = true; - } + } } if (strpos($key, 'custom__opening_hours') === 0 && $value != '') { $has_opening_hours = true; @@ -148,10 +151,7 @@ out meta;'; if($has_ask_angela) { $modified_request_post['commerce_tag_value__harassment_prevention'] = 'ask_angela'; - } - if($remove_ask_angela) { - unset($modified_request_post['commerce_tag_value__harassment_prevention']); - } + } if($has_opening_hours) { $modified_request_post['commerce_tag_value__opening_hours'] = $request_post['commerce_tag_value__opening_hours']; diff --git a/templates/admin/stats/row.html.twig b/templates/admin/stats/row.html.twig index 01cb0d5..f87966c 100644 --- a/templates/admin/stats/row.html.twig +++ b/templates/admin/stats/row.html.twig @@ -97,6 +97,13 @@ {% endif %} + + {% if stats.population > 0 %} + {{ (1 / (stats.population / stats.places|length))|number_format(3, '.', ' ') }} + {% else %} + - + {% endif %} + {# (si siret clos) #} diff --git a/templates/admin/stats/table-head.html.twig b/templates/admin/stats/table-head.html.twig index ccd3d8d..17bd360 100644 --- a/templates/admin/stats/table-head.html.twig +++ b/templates/admin/stats/table-head.html.twig @@ -63,5 +63,9 @@ Osm kind + + + Lieux par habitants + \ No newline at end of file diff --git a/templates/public/_tags_textarea.html.twig b/templates/public/_tags_textarea.html.twig new file mode 100644 index 0000000..305f31e --- /dev/null +++ b/templates/public/_tags_textarea.html.twig @@ -0,0 +1,4 @@ +{# Partial pour afficher un textarea de tags OSM clé=valeur #} + \ No newline at end of file diff --git a/templates/public/edit.html.twig b/templates/public/edit.html.twig index c652304..749d398 100644 --- a/templates/public/edit.html.twig +++ b/templates/public/edit.html.twig @@ -8,7 +8,7 @@
-

{{ 'display.welcome'|trans }} {{ commerce_overpass.tags_converted.name }}

+

{{ 'display.welcome'|trans }} {{ commerce_overpass.tags_converted.name }} - {{ commerce.stats.name }}

{% include 'public/edit/address.html.twig' %} @@ -29,10 +29,18 @@
- + {% if commerce_overpass.tags_converted.image is defined and commerce_overpass.tags_converted.image|length > 0 %} + + {% endif %} + + + + {% if commerce_overpass.tags_converted.image is defined and commerce_overpass.tags_converted.image|length > 0 %} + Image de la façade + {% endif %} + {{ commerce_overpass.tags_converted.image }} - url d'image de la facade : {{ commerce_overpass.tags_converted.image }} {% if commerce_overpass.tags_converted.panoramax is defined or commerce_overpass.tags_converted.wikimedia_commons is defined %} url d'image sur Panoramax : {{ commerce_overpass.tags_converted.panoramax is defined ? commerce_overpass.tags_converted.panoramax : '' }} @@ -71,25 +79,47 @@ {% endif %} {% include 'public/edit/ask_angela.html.twig' %} + +
+ + +
+ + + Téléphone + + +
+ +
+ {% include 'public/edit/social_media.html.twig' %} -
- - - Téléphone - - -
- {% include 'public/edit/tags.html.twig' with { 'excluded_tags_to_render': excluded_tags_to_render, + {# {% include 'public/edit/tags.html.twig' with { 'excluded_tags_to_render': excluded_tags_to_render, 'commerce_overpass': commerce_overpass, 'hide_filled_inputs': hide_filled_inputs } %} + #} + {% include 'public/edit/tags.html.twig' with { 'excluded_tags_to_render': {}, + 'commerce_overpass': commerce_overpass, + 'hide_filled_inputs': hide_filled_inputs } %} + +
+ +
+

Prévisualisation des tags OSM (texte à copier-coller)

+ {% set tags_for_textarea = {} %} + {% for k, v in commerce_overpass.tags_converted %} + {% if v is not empty %} + {% set tags_for_textarea = tags_for_textarea|merge({ (k): v }) %} + {% endif %} + {% endfor %} + {% include 'public/_tags_textarea.html.twig' with { 'tags': tags_for_textarea } %}
diff --git a/templates/public/edit/ask_angela.html.twig b/templates/public/edit/ask_angela.html.twig index 7a0198b..4690efe 100644 --- a/templates/public/edit/ask_angela.html.twig +++ b/templates/public/edit/ask_angela.html.twig @@ -4,13 +4,13 @@

{{ 'display.ask_angela'|trans }}

-
+ -
+

+
{% endblock %} \ No newline at end of file diff --git a/templates/public/edit/social_media.html.twig b/templates/public/edit/social_media.html.twig index d1040cc..b72ae70 100644 --- a/templates/public/edit/social_media.html.twig +++ b/templates/public/edit/social_media.html.twig @@ -11,24 +11,31 @@ 'tiktok': { 'icon': 'bi-tiktok', 'label': 'TikTok' }, 'youtube': { 'icon': 'bi-youtube', 'label': 'YouTube' }, 'linkedin': { 'icon': 'bi-linkedin', 'label': 'LinkedIn' }, + 'pinterest': { 'icon': 'bi-pinterest', 'label': 'Pinterest' }, + + } %}
{% for key, social in social_medias %} {% set tag_name = 'contact:' ~ key %}
- + - {{ social.label }} + {{ social.label }}
{% endfor %}
+ +{#
+{{ dump(commerce_overpass.tags_converted) }}
+
#} {% endblock social_medias %} \ No newline at end of file diff --git a/templates/public/edit/tags.html.twig b/templates/public/edit/tags.html.twig index d134f6f..31a7338 100644 --- a/templates/public/edit/tags.html.twig +++ b/templates/public/edit/tags.html.twig @@ -24,11 +24,10 @@ {% endif %} {{ ('display.keys.' ~ k)|trans }}
- {% endif %}
- {% if k not in excluded_tags_to_render %} + {# {% if k not in excluded_tags_to_render %} #}
- {% endif %} + {# {% endif %} #}
{% endfor %} diff --git a/templates/public/edit/yenaunpeuplusjevouslemets.html.twig b/templates/public/edit/yenaunpeuplusjevouslemets.html.twig index 3130bee..7794395 100644 --- a/templates/public/edit/yenaunpeuplusjevouslemets.html.twig +++ b/templates/public/edit/yenaunpeuplusjevouslemets.html.twig @@ -62,36 +62,28 @@ moyens de paiement proposés médias sociaux
- - - - - - - - - + + + + + + + + +
-
+
téléphone
contact:phone - +
phone: - -
-
-
-
- -
-
- +
diff --git a/templates/public/view.html.twig b/templates/public/view.html.twig index 8ef74fe..106d3a1 100644 --- a/templates/public/view.html.twig +++ b/templates/public/view.html.twig @@ -13,6 +13,102 @@ {% if status == "Les tags ont été mis à jour avec succès" %} {{status}} + {# Tableau comparatif des tags avant/après modification #} + {% if tags_before_modif is defined and tags_after_modif is defined %} +

Comparatif des tags avant/après modification

+
+ + + + + + + + + + {# Construction manuelle de la liste des clés sans filtre unique #} + {% set all_keys = [] %} + {% for k in tags_before_modif|keys %}{% if k not in all_keys %}{% set all_keys = all_keys|merge([k]) %}{% endif %}{% endfor %} + {% for k in tags_after_modif|keys %}{% if k not in all_keys %}{% set all_keys = all_keys|merge([k]) %}{% endif %}{% endfor %} + {% set all_keys = all_keys|sort %} + {% for key in all_keys %} + {% set before = tags_before_modif[key]|default(null) %} + {% set after = tags_after_modif[key]|default(null) %} + {% if before is not null and (after is null or after == '') %} + {# Suppression #} + + + + + + {% elseif before is null and after is not null and after != '' %} + {# Ajout #} + + + + + + {% elseif before != after and after != '' %} + {# Modification #} + + + + + + {% else %} + + + + + + {% endif %} + {% endfor %} + +
TagAvantAprès
{{ key }}{{ before }}(supprimé)
{{ key }}(nouveau){{ after }}
{{ key }}{{ before }}{{ after }}
{{ key }}{{ before }}{{ after }}
+ +   supprimé   +   modifié   +   ajouté + +
+ {% if excluded_post_fields is defined and excluded_post_fields|length > 0 %} +
+ Champs du formulaire non pris en compte dans OpenStreetMap : +
    + {% for field in excluded_post_fields %} +
  • {{ field }}
  • + {% endfor %} +
+
+ {% endif %} + {% endif %} + + {# Affichage en lecture seule des nouveaux tags #} +

Nouveaux tags enregistrés

+
+ + + + + + + + + {% for key, value in tags_after_modif %} + {% if value is not empty %} + + + + + {% endif %} + {% endfor %} + +
TagValeur
{{ key }}{{ value }}
+
+ +

Tags OSM (texte à copier-coller)

+ {% include 'public/_tags_textarea.html.twig' with { 'tags': tags_after_modif } %} +

Merci d'avoir contribué à l'amélioration de la base de données OSM, votre contribution sera visible sur de nombreux sites web et dans la base adresse nationale des lieux et commerces.