From 3afc15a86fcad2160ef531312f4f1287d4294e6c Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 27 May 2025 12:17:46 +0200 Subject: [PATCH] add icons in edit form --- config/packages/framework.yaml | 5 +- config/packages/translation.yaml | 2 +- src/Controller/AdminController.php | 5 + src/Controller/PublicController.php | 1 + src/Service/Motocultrice.php | 11 +- templates/base.html.twig | 32 ++-- templates/public/dashboard.html.twig | 4 +- templates/public/edit.html.twig | 140 +++++++++++------- templates/public/edit/ask_angela.html.twig | 21 +-- templates/public/edit/opening_hours.html.twig | 18 ++- templates/public/edit/tags.html.twig | 30 +++- templates/public/edit/wheelchair.html.twig | 2 +- templates/public/nav.html.twig | 20 +++ translations/messages.en.yaml | 1 + translations/messages.fr.yaml | 8 +- 15 files changed, 195 insertions(+), 105 deletions(-) create mode 100644 templates/public/nav.html.twig diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 5086845..c03e419 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -5,10 +5,7 @@ framework: http_method_override: false handle_all_throwables: true - default_locale: 'fr' - translator: - default_path: '%kernel.project_dir%/translations' - fallbacks: ['en'] + # Enables session support. Note that the session will ONLY be started if you read or write from it. # Remove or comment this section to explicitly disable session support. diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml index b3f8f9c..0af682d 100644 --- a/config/packages/translation.yaml +++ b/config/packages/translation.yaml @@ -1,5 +1,5 @@ framework: - default_locale: en + default_locale: fr translator: default_path: '%kernel.project_dir%/translations' fallbacks: diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 2541cf1..84c8ff6 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -64,6 +64,11 @@ final class AdminController extends AbstractController $this->entityManager->persist($stats); $this->entityManager->flush(); + $stats->computeCompletionPercent(); + $this->entityManager->persist($stats); + $this->entityManager->flush(); + + return $this->render('admin/stats.html.twig', [ 'stats' => $stats, 'zip_code' => $zip_code, diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 195a735..aa95e2f 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -65,6 +65,7 @@ class PublicController extends AbstractController 'commerce_overpass' => $commerce_overpass, 'name' => $name, 'commerce' => $place, + 'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render, 'osm_kind' => $place->getOsmKind(), "mapbox_token" => $_ENV['MAPBOX_TOKEN'], "maptiler_token" => $_ENV['MAPTILER_TOKEN'], diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index d743ff6..56007fe 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -10,17 +10,24 @@ class Motocultrice private $overpassApiUrl = 'https://overpass-api.de/api/interpreter'; private $osmApiUrl = 'https://www.openstreetmap.org/api/0.6'; + // ne pas lister les tags qui utilisent des morceaux particuliers de formulaire pour éviter que les gens aient besoin de connaître le tag OSM + public $excluded_tags_to_render = [ + 'name', + 'wheelchair', + 'harassment_prevention', + ]; + // les tags OSM que l'on estime nécessaires pour un commerce public $base_tags = [ 'name', 'opening_hours', 'contact:email', 'contact:phone', - 'wheelchair', 'addr:housenumber', 'addr:street', 'contact:website', 'contact:mastodon', - // 'EEEEEEEEEEEEEEEEEEE' + 'image', + 'note' ]; private $more_tags = ['image', 'ref:FR:SIRET']; public function __construct( diff --git a/templates/base.html.twig b/templates/base.html.twig index f625c57..2039b1b 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -5,6 +5,7 @@ {% block title %}Welcome!{% endblock %} + @@ -20,12 +21,12 @@ table, thead, tbody, tr{ width: 100%; } - table tr:nth-child(odd){ + {# table tr:nth-child(odd){ background-color:rgb(235, 235, 235); } table tr:nth-child(even){ background-color: #f8f9fa; - } + } #} {% block stylesheets %} @@ -54,26 +55,7 @@ {% endfor %}
- + {% include 'public/nav.html.twig' %}
@@ -85,6 +67,12 @@
+ {% include 'public/nav.html.twig' %} +
+
+
+
+

OpenStreetMap Mon Commerce

Licence AGPLv3+, fait par Tykayn de diff --git a/templates/public/dashboard.html.twig b/templates/public/dashboard.html.twig index 1cef998..000ab8f 100644 --- a/templates/public/dashboard.html.twig +++ b/templates/public/dashboard.html.twig @@ -21,7 +21,7 @@

Statistiques : {{ stats|length }} commerces

- +
@@ -41,7 +41,7 @@
Zone

Lieux

- +
diff --git a/templates/public/edit.html.twig b/templates/public/edit.html.twig index a65817d..397150c 100644 --- a/templates/public/edit.html.twig +++ b/templates/public/edit.html.twig @@ -19,6 +19,10 @@ .is-invalid #validation_messages { color: red; } + img{ + max-width: 100%; + max-height: 400px; + } {% endblock %} @@ -26,11 +30,18 @@
+ +
+ +
+
+
+
-

{{ 'display.welcome'|trans }}

+

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

{% if commerce_overpass is not empty %} @@ -55,76 +66,67 @@ {{ 'display.contact_humans'|trans }}
- {% if commerce.tags_converted.image is defined %} - Image du lieu + Image du lieu {% endif %}

{{ 'display.attributes'|trans }}

- -
-
- -
-
- -
-
- -
-
+ +
+
+ +
+
+ +
-
+ - {% include 'public/edit/ask_angela.html.twig' %} - {% include 'public/edit/wheelchair.html.twig' %} - {% include 'public/edit/opening_hours.html.twig' %} {% include 'public/edit/address.html.twig' %} + {% include 'public/edit/opening_hours.html.twig' %} + {% include 'public/edit/wheelchair.html.twig' %} + {% include 'public/edit/ask_angela.html.twig' %} {% include 'public/edit/tags.html.twig' %}
- + {% endif %}
- - {{ 'display.last_modification'|trans }}: {{ commerce_overpass['@attributes'].timestamp }}, - - {{ 'display.days_ago'|trans({'%days%': date(commerce_overpass['@attributes'].timestamp).diff(date()).days}) }} - {{ 'display.by'|trans }} - {{ commerce_overpass['@attributes'].user }} - - + - - -
-

- {{ 'display.disclaimer.title'|trans }}: - {{ 'display.disclaimer.text'|trans }} -

-
- -
+
+
- + + {{ 'display.last_modification'|trans }}: {{ commerce_overpass['@attributes'].timestamp }}, + + {{ 'display.days_ago'|trans({'%days%': date(commerce_overpass['@attributes'].timestamp).diff(date()).days}) }} + {{ 'display.by'|trans }} + {{ commerce_overpass['@attributes'].user }} + + + + +
+

+ {{ 'display.disclaimer.title'|trans }}: + {{ 'display.disclaimer.text'|trans }} +

+
+ +
{% block javascripts %} @@ -132,9 +134,9 @@ {% endblock %} {% endblock %} diff --git a/templates/public/edit/ask_angela.html.twig b/templates/public/edit/ask_angela.html.twig index c7e6b13..1d33eb9 100644 --- a/templates/public/edit/ask_angela.html.twig +++ b/templates/public/edit/ask_angela.html.twig @@ -1,18 +1,16 @@ {% block ask_angela %}
-
+

{{ 'display.ask_angela'|trans }}

-

{{ 'display.ask_angela_description'|trans }}

-

- {{ 'display.ask_angela_more_info'|trans }} -

+
+ Image du lieu +

+
- - {% if commerce_overpass.tags_converted.harassment_prevention is defined %} - {{ dump(commerce_overpass.tags_converted.harassment_prevention) }} - {% endif %} + +
+

+ {{ 'display.ask_angela_more_info'|trans }} +

+
+
{% endblock %} \ No newline at end of file diff --git a/templates/public/edit/opening_hours.html.twig b/templates/public/edit/opening_hours.html.twig index 00d611a..899323d 100644 --- a/templates/public/edit/opening_hours.html.twig +++ b/templates/public/edit/opening_hours.html.twig @@ -1,16 +1,24 @@
-

{{ 'display.opening_hours'|trans }}

+

+ + {{ 'display.opening_hours'|trans }}

{{ 'display.opening_hours_description'|trans }}

- {% if commerce_overpass.tags_converted.opening_hours is defined %} + {% if commerce_overpass.tags_converted.opening_hours is defined and commerce_overpass.tags_converted.opening_hours != '' %} {{ dump(commerce_overpass.tags_converted.opening_hours) }} + {% else %} - +
ajoutez les horaires au format OSM - - {% endif %} + Exemples : +
    +
  • Écrivez "24/7" pour indiquer que le commerce est ouvert 24 heures sur 24
  • +
  • Écrivez "Mo-Fr 9:00 - 18:00" pour indiquer que le commerce est ouvert du lundi au vendredi de 9h à 18h
  • +
  • Pour des horaires plus complexes, écrivez "Mo-Fr 9:00 - 18:00; Sa 9:00 - 12:00" pour indiquer que le commerce est ouvert du lundi au vendredi de 9h à 18h et le samedi de 9h à 12h
  • +
+ {# Lundi de diff --git a/templates/public/edit/tags.html.twig b/templates/public/edit/tags.html.twig index d6b93e8..527bba8 100644 --- a/templates/public/edit/tags.html.twig +++ b/templates/public/edit/tags.html.twig @@ -3,15 +3,39 @@
{% for k, v in commerce_overpass.tags_converted %} +
- - {{ ('display.keys.' ~ k)|trans }} + {% if k not in excluded_tags_to_render %} + {% if k == 'phone' or k == 'contact:phone' %} + + {% elseif k == 'addr:housenumber' or k == 'addr:street' or k == 'addr:city' or k == 'addr:postcode' or k == 'addr:country' %} + + {% elseif k == 'mastodon' %} + + {% elseif k == 'email' or k == 'contact:email' %} + + {% elseif k == 'website' or k == 'contact:website' %} + {% elseif k == 'opening_hours' %} + + {% else %} + + {% endif %} + {% endif %} + + {% if k not in excluded_tags_to_render %} + + {{ ('display.keys.' ~ k)|trans }} + {% endif %}
+ {% if k not in excluded_tags_to_render %} + -
+ {% endif %}
+
+ {% endfor %}
diff --git a/templates/public/edit/wheelchair.html.twig b/templates/public/edit/wheelchair.html.twig index 5c29e74..e19a7bb 100644 --- a/templates/public/edit/wheelchair.html.twig +++ b/templates/public/edit/wheelchair.html.twig @@ -1,5 +1,5 @@
-

{{ 'display.wheelchair'|trans }}

+

{{ 'display.wheelchair'|trans }}

diff --git a/templates/public/nav.html.twig b/templates/public/nav.html.twig new file mode 100644 index 0000000..5c852b3 --- /dev/null +++ b/templates/public/nav.html.twig @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 92e1c85..40abbe4 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -38,6 +38,7 @@ display: ask_angela: 'Ask Angela' ask_angela_yes: 'Yes' ask_angela_no: 'No' + keys: tags: 'tags' name: 'Name' diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 148499e..c479924 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -4,7 +4,7 @@ display: stats: "Statistiques" contact_humans: "Contacter des humains d'OSM France pour m'aider" modify: "Modifier" - welcome: "Bienvenue dans les commerces!" + welcome: "Modifier ce lieu:" modify_commerce: "Modifier votre commerce" tags: "Tags" submit: "Envoyer" @@ -22,6 +22,8 @@ display: attributes: "Attributs" opening_hours: "Horaires d'ouverture" opening_hours_description: "De bons horaires d'ouverture sont importants pour que les clients puissent vous trouver." + ask_angela_yes: "Oui" + ask_angela_no: "Non" values: wheelchair: yes: "le lieu est totalement praticable en fauteuil roulant" @@ -50,9 +52,10 @@ display: contact:website: "Contact du Site web" contact:mastodon: "Contact Mastodon" opening_hours: "Horaires d'ouverture" + opening_hours:signed: "Horaires d'ouverture signés" shop: "Type de commerce" tourism: "Tourisme" - wheelchair: "Accès PMR" + wheelchair: "Accès Personnes à mobilité réduite (PMR)" addr:housenumber: "Numéro de rue" addr:street: "Rue" addr:city: "Ville" @@ -60,6 +63,7 @@ display: amenity: "Équipement" source: "Source" ref:FR:SIRET: "SIRET" + image: "URL vers une Image" disclaimer: title: "Attention" text: "Ce site est un travail en cours, ceci est une démonstration sur un objet fictif qui utilise les données de l'API OpenStreetMap."
Nom