mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-06-20 01:44:42 +02:00
affichage de modif qui cache les champs déjà remplis
This commit is contained in:
parent
2628b1c7f7
commit
f11ab48bb9
8 changed files with 166 additions and 115 deletions
|
@ -12,9 +12,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
|
||||||
class PublicController extends AbstractController
|
class PublicController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private $hide_filled_inputs = true;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
private Motocultrice $motocultrice
|
private Motocultrice $motocultrice
|
||||||
|
@ -65,6 +68,7 @@ class PublicController extends AbstractController
|
||||||
'commerce_overpass' => $commerce_overpass,
|
'commerce_overpass' => $commerce_overpass,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'commerce' => $place,
|
'commerce' => $place,
|
||||||
|
'hide_filled_inputs' => $this->hide_filled_inputs,
|
||||||
'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render,
|
'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render,
|
||||||
'osm_kind' => $place->getOsmKind(),
|
'osm_kind' => $place->getOsmKind(),
|
||||||
"mapbox_token" => $_ENV['MAPBOX_TOKEN'],
|
"mapbox_token" => $_ENV['MAPBOX_TOKEN'],
|
||||||
|
@ -108,7 +112,7 @@ class PublicController extends AbstractController
|
||||||
$request_post = $this->motocultrice->map_post_values($request_post);
|
$request_post = $this->motocultrice->map_post_values($request_post);
|
||||||
|
|
||||||
foreach ($request_post as $key => $value) {
|
foreach ($request_post as $key => $value) {
|
||||||
// var_dump($key, $value);
|
|
||||||
if (strpos($key, 'commerce_tag_value__') === 0) {
|
if (strpos($key, 'commerce_tag_value__') === 0) {
|
||||||
$tagKey = str_replace('commerce_tag_value__', '', $key);
|
$tagKey = str_replace('commerce_tag_value__', '', $key);
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
|
@ -225,9 +229,13 @@ class PublicController extends AbstractController
|
||||||
|
|
||||||
// après envoi on récupère les données
|
// après envoi on récupère les données
|
||||||
$commerce = $this->motocultrice->get_osm_object_data($osm_kind, $osm_object_id);
|
$commerce = $this->motocultrice->get_osm_object_data($osm_kind, $osm_object_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $this->render('public/view.html.twig', [
|
return $this->render('public/view.html.twig', [
|
||||||
'controller_name' => 'PublicController',
|
'controller_name' => 'PublicController',
|
||||||
'commerce' => $commerce,
|
'commerce' => $commerce,
|
||||||
|
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'exception' => $exception,
|
'exception' => $exception,
|
||||||
'exception_message' => $exception_message,
|
'exception_message' => $exception_message,
|
||||||
|
|
|
@ -29,6 +29,36 @@ class Motocultrice
|
||||||
'image',
|
'image',
|
||||||
'note'
|
'note'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// quand un commerce a fermé, on peut supprimer ces tags
|
||||||
|
public $obsolete_tags = ["phone", "website", "email", "description", "brand", "opening_hours",
|
||||||
|
"check_date:opening_hours", "internet_access",
|
||||||
|
"indoor_seating", "takeaway", "female", "male", "unisex",
|
||||||
|
"ref:FR:NAF", "ref:FR:FINESS", "ref:FR:SIRET", "ref:FR:SIREN", "ref:vatin",
|
||||||
|
"healthcare", "dispensing", "lawyer", "vending", "vending_machine",
|
||||||
|
"self_service", "second_hand", "branch", "delivery", "start_date",
|
||||||
|
"beauty", "facebook", "tobacco", "bulk_purchase",
|
||||||
|
"drive_through", "pastry", "stroller", "fax", "trade", "network",
|
||||||
|
"mobile", "sport", "produce", "lottery", "supermarket", "information",
|
||||||
|
"tourism", "government", "brewery"
|
||||||
|
];
|
||||||
|
public $tags_to_remove = ["diet:", "contact:", "name:", "payment:", "delivery:", "type:FR:", "ref:FR:SDIS:",
|
||||||
|
"brand:", "fuel:", "service:", "description:", "operator:", "tickets:", "healthcare:"
|
||||||
|
];
|
||||||
|
public $tags_to_convert = ["shop" => "was:shop",
|
||||||
|
"information" => "was:information",
|
||||||
|
"office" => "was:office",
|
||||||
|
"amenity" => "was:amenity",
|
||||||
|
"craft" => "was:craft",
|
||||||
|
"operator" => "was:operator",
|
||||||
|
"clothes" => "was:clothes",
|
||||||
|
"cuisine" => "was:cuisine",
|
||||||
|
"official_name" => "was:official_name",
|
||||||
|
"short_name" => "was:short_name",
|
||||||
|
"alt_name" => "was:alt_name"
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
private $more_tags = ['image', 'ref:FR:SIRET'];
|
private $more_tags = ['image', 'ref:FR:SIRET'];
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private HttpClientInterface $client,
|
private HttpClientInterface $client,
|
||||||
|
@ -41,6 +71,11 @@ class Motocultrice
|
||||||
$has_ask_angela = false;
|
$has_ask_angela = false;
|
||||||
$remove_ask_angela = false;
|
$remove_ask_angela = false;
|
||||||
$has_opening_hours = false;
|
$has_opening_hours = false;
|
||||||
|
// $has_phone = false;
|
||||||
|
// $has_contact_phone = false;
|
||||||
|
|
||||||
|
// $has_email = false;
|
||||||
|
// $has_contact_email = false;
|
||||||
|
|
||||||
|
|
||||||
$modified_request_post = [];
|
$modified_request_post = [];
|
||||||
|
@ -171,12 +206,14 @@ QUERY;
|
||||||
foreach ($osm_object_data['node']['tag'] as $attribute) {
|
foreach ($osm_object_data['node']['tag'] as $attribute) {
|
||||||
$osm_object_data['node']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v'];
|
$osm_object_data['node']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v'];
|
||||||
}
|
}
|
||||||
|
$osm_object_data['node']['tags_converted'] = $this->migrate_tags($osm_object_data['node']['tags_converted']);
|
||||||
return $osm_object_data['node'];
|
return $osm_object_data['node'];
|
||||||
}
|
}
|
||||||
if(isset($osm_object_data['way'])){
|
if(isset($osm_object_data['way'])){
|
||||||
foreach ($osm_object_data['way']['tag'] as $attribute) {
|
foreach ($osm_object_data['way']['tag'] as $attribute) {
|
||||||
$osm_object_data['way']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v'];
|
$osm_object_data['way']['tags_converted'][$attribute['@attributes']['k']] = $attribute['@attributes']['v'];
|
||||||
}
|
}
|
||||||
|
$osm_object_data['way']['tags_converted'] = $this->migrate_tags($osm_object_data['way']['tags_converted']);
|
||||||
return $osm_object_data['way'];
|
return $osm_object_data['way'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +221,29 @@ QUERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function migrate_tags($osm_object_data) {
|
||||||
|
|
||||||
|
// migrer email vers contact:email
|
||||||
|
if(isset($osm_object_data['email']) && !isset($osm_object_data['contact:email'])){
|
||||||
|
$osm_object_data['contact:email'] = $osm_object_data['email'];
|
||||||
|
unset($osm_object_data['email']);
|
||||||
|
}
|
||||||
|
// migrer phone vers contact:phone
|
||||||
|
if(isset($osm_object_data['phone']) && !isset($osm_object_data['contact:phone'])){
|
||||||
|
$osm_object_data['contact:phone'] = $osm_object_data['phone'];
|
||||||
|
unset($osm_object_data['phone']);
|
||||||
|
}
|
||||||
|
// migrer website vers contact:website
|
||||||
|
if(isset($osm_object_data['website']) && !isset($osm_object_data['contact:website'])){
|
||||||
|
$osm_object_data['contact:website'] = $osm_object_data['website'];
|
||||||
|
unset($osm_object_data['website']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $osm_object_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function uuid_create() {
|
public function uuid_create() {
|
||||||
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||||
// 32 bits for "time_low"
|
// 32 bits for "time_low"
|
||||||
|
@ -212,7 +272,7 @@ QUERY;
|
||||||
$essentialTags = [
|
$essentialTags = [
|
||||||
'name',
|
'name',
|
||||||
'opening_hours',
|
'opening_hours',
|
||||||
'phone',
|
// 'phone',
|
||||||
'contact:email',
|
'contact:email',
|
||||||
'contact:phone',
|
'contact:phone',
|
||||||
'website',
|
'website',
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
.main-footer{
|
.main-footer{
|
||||||
padding-bottom: 3rem;
|
padding-bottom: 15rem;
|
||||||
|
margin-top: 5rem;
|
||||||
}
|
}
|
||||||
{# table tr:nth-child(odd){
|
{# table tr:nth-child(odd){
|
||||||
background-color:rgb(235, 235, 235);
|
background-color:rgb(235, 235, 235);
|
||||||
|
@ -53,10 +54,14 @@
|
||||||
<body>
|
<body>
|
||||||
<header class="main-header">
|
<header class="main-header">
|
||||||
<div id="completion_progress">
|
<div id="completion_progress">
|
||||||
|
<div class="container">
|
||||||
|
<div id="completion_display"></div>
|
||||||
|
|
||||||
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
<div class="progress" role="progressbar" aria-label="Basic example" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
||||||
<div class="progress-bar" style="width: 0%"></div>
|
<div class="progress-bar" style="width: 0%"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -84,7 +89,7 @@
|
||||||
<div class="body-landing">
|
<div class="body-landing">
|
||||||
{% block body %}{% endblock %}
|
{% block body %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
<footer class="main-footer">
|
<footer class="main-footer dark">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
@ -96,9 +101,11 @@
|
||||||
|
|
||||||
<p>OpenStreetMap Mon Commerce</p>
|
<p>OpenStreetMap Mon Commerce</p>
|
||||||
<p>Licence AGPLv3+,
|
<p>Licence AGPLv3+,
|
||||||
fait par Tykayn de
|
fait par <a href="https://mastodon.cipherbliss.com/@tykayn">Tykayn</a> de
|
||||||
<a href="https://www.cipherbliss.com">CipherBliss EI</a>, membre de la fédération des professionels d'OpenStreetMap, Sources des données : <a href="https://www.openstreetmap.org/">OpenStreetMap</a>.
|
<a href="https://www.cipherbliss.com">CipherBliss EI</a>, membre de la fédération des professionels d'OpenStreetMap, Sources des données : <a href="https://www.openstreetmap.org/">OpenStreetMap</a>.
|
||||||
<br> <a href="https://www.openstreetmap.org/copyright">OpenStreetMap France</a></p>
|
<br> <a href="https://www.openstreetmap.org/copyright">OpenStreetMap France</a>.
|
||||||
|
<br> <a href="https://www.openstreetmap.org/copyright">Sources du logiciel.</a>.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,35 +6,16 @@
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<link href='https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css' rel='stylesheet' />
|
<link href='https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css' rel='stylesheet' />
|
||||||
<style>
|
<style>
|
||||||
.hidden {
|
.hidden { display: none; }
|
||||||
display: none;
|
input[type="checkbox"] { width: 20px; height: 20px; }
|
||||||
}
|
.is-invalid { border: 1px solid red; }
|
||||||
input[type="checkbox"] {
|
.is-invalid #validation_messages { color: red; }
|
||||||
width: 20px;
|
img { max-width: 100%; max-height: 400px; }
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
.is-invalid {
|
|
||||||
border: 1px solid red;
|
|
||||||
}
|
|
||||||
.is-invalid #validation_messages {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
img{
|
|
||||||
max-width: 100%;
|
|
||||||
max-height: 400px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
|
@ -43,8 +24,6 @@
|
||||||
<div id="map" style="height: 400px; width: 100%;" class="rounded"></div>
|
<div id="map" style="height: 400px; width: 100%;" class="rounded"></div>
|
||||||
|
|
||||||
{% if commerce_overpass is not empty %}
|
{% if commerce_overpass is not empty %}
|
||||||
|
|
||||||
|
|
||||||
<form action="{{ path('app_public_submit', {'osm_object_id': commerce_overpass['@attributes'].id, 'version': commerce_overpass['@attributes'].version, 'changesetID': commerce_overpass['@attributes'].changeset }) }}" method="post" class="needs-validation">
|
<form action="{{ path('app_public_submit', {'osm_object_id': commerce_overpass['@attributes'].id, 'version': commerce_overpass['@attributes'].version, 'changesetID': commerce_overpass['@attributes'].changeset }) }}" method="post" class="needs-validation">
|
||||||
<input type="hidden" name="osm_kind" value="{{ osm_kind }}">
|
<input type="hidden" name="osm_kind" value="{{ osm_kind }}">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -60,7 +39,6 @@
|
||||||
</strong>
|
</strong>
|
||||||
</label>
|
</label>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a class="btn btn-info" href="{{ path('app_public_index') }}">{{ 'display.contact_humans'|trans }}</a>
|
<a class="btn btn-info" href="{{ path('app_public_index') }}">{{ 'display.contact_humans'|trans }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -69,8 +47,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2>{{ 'display.attributes'|trans }}</h2>
|
<h2>{{ 'display.attributes'|trans }}</h2>
|
||||||
|
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<label for="commerce_tag_value__name">{{'display.keys.name'|trans}}</label>
|
<label for="commerce_tag_value__name">{{'display.keys.name'|trans}}</label>
|
||||||
|
@ -80,40 +56,46 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if hide_filled_inputs and
|
||||||
|
(commerce_overpass.tags_converted['addr:street']) is defined and commerce_overpass.tags_converted['addr:street'] is not empty
|
||||||
|
%}
|
||||||
{% include 'public/edit/address.html.twig' %}
|
{% include 'public/edit/address.html.twig' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if hide_filled_inputs and (commerce_overpass.tags_converted.opening_hours) is defined and commerce_overpass.tags_converted.opening_hours is not empty %}
|
||||||
{% include 'public/edit/opening_hours.html.twig' %}
|
{% include 'public/edit/opening_hours.html.twig' %}
|
||||||
|
{% endif %}
|
||||||
|
{% if hide_filled_inputs and (commerce_overpass.tags_converted.wheelchair) is defined and commerce_overpass.tags_converted.wheelchair is not empty %}
|
||||||
{% include 'public/edit/wheelchair.html.twig' %}
|
{% include 'public/edit/wheelchair.html.twig' %}
|
||||||
|
{% endif %}
|
||||||
|
{% if hide_filled_inputs and (commerce_overpass.tags_converted.ask_angela) is defined and commerce_overpass.tags_converted.ask_angela is not empty %}
|
||||||
{% include 'public/edit/ask_angela.html.twig' %}
|
{% include 'public/edit/ask_angela.html.twig' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% include 'public/edit/tags.html.twig' %}
|
{% include 'public/edit/tags.html.twig' %}
|
||||||
|
|
||||||
<div id="validation_messages"></div>
|
<div id="validation_messages"></div>
|
||||||
<button type="submit" class="btn btn-primary">
|
<button type="submit" class="btn btn-primary">
|
||||||
<i class="bi bi-send"></i>
|
<i class="bi bi-send"></i>
|
||||||
|
{{ 'display.submit'|trans }}
|
||||||
{{ 'display.submit'|trans }}</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<span class="p-4">
|
<span class="p-4">
|
||||||
<span class="last-modification">{{ 'display.last_modification'|trans }}: {{ commerce_overpass['@attributes'].timestamp }}</span>,
|
<span class="last-modification">{{ 'display.last_modification'|trans }}: {{ commerce_overpass['@attributes'].timestamp }}</span>,
|
||||||
<strong>
|
<strong>{{ 'display.days_ago'|trans({'%days%': date(commerce_overpass['@attributes'].timestamp).diff(date()).days}) }}</strong>
|
||||||
{{ 'display.days_ago'|trans({'%days%': date(commerce_overpass['@attributes'].timestamp).diff(date()).days}) }} </strong>
|
|
||||||
{{ 'display.by'|trans }}
|
{{ 'display.by'|trans }}
|
||||||
<a href="https://www.openstreetmap.org/user/{{ commerce_overpass['@attributes'].user }}" target="_blank">{{ commerce_overpass['@attributes'].user }}</a>
|
<a href="https://www.openstreetmap.org/user/{{ commerce_overpass['@attributes'].user }}" target="_blank">{{ commerce_overpass['@attributes'].user }}</a>
|
||||||
|
|
||||||
<div class="lien-OpenStreetMap">
|
<div class="lien-OpenStreetMap">
|
||||||
<a href="https://www.openstreetmap.org/node/{{ commerce_overpass['@attributes'].id }}" target="_blank">{{ 'display.view_on_osm'|trans }}</a>
|
<a href="https://www.openstreetmap.org/node/{{ commerce_overpass['@attributes'].id }}" target="_blank">{{ 'display.view_on_osm'|trans }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
<div class="disclaimer p-3">
|
<div class="disclaimer p-3">
|
||||||
<p>
|
<p>
|
||||||
|
@ -123,31 +105,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<script src='https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.js'></script>
|
<script src='https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.js'></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
function check_validity(e) {
|
function check_validity(e) {
|
||||||
let errors = [];
|
let errors = [];
|
||||||
// Réinitialiser les classes d'erreur
|
|
||||||
document.querySelectorAll('.is-invalid').forEach(input => {
|
document.querySelectorAll('.is-invalid').forEach(input => {
|
||||||
input.classList.remove('is-invalid');
|
input.classList.remove('is-invalid');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Vérification du nom
|
|
||||||
const nameInput = document.querySelector('input[name="commerce_tag_value__name"]');
|
const nameInput = document.querySelector('input[name="commerce_tag_value__name"]');
|
||||||
if (!nameInput.value.trim()) {
|
if (!nameInput.value.trim()) {
|
||||||
errors.push("Le nom de l'établissement est obligatoire");
|
errors.push("Le nom de l'établissement est obligatoire");
|
||||||
nameInput.classList.add('is-invalid');
|
nameInput.classList.add('is-invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vérification de l'email
|
|
||||||
const emailInput = document.querySelector('input[name="commerce_tag_value__contact:email"]');
|
const emailInput = document.querySelector('input[name="commerce_tag_value__contact:email"]');
|
||||||
if (emailInput && emailInput.value) {
|
if (emailInput && emailInput.value) {
|
||||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
@ -157,7 +132,6 @@ function check_validity(e){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vérification du téléphone
|
|
||||||
const phoneInput = document.querySelector('input[name="commerce_tag_value__contact:phone"]');
|
const phoneInput = document.querySelector('input[name="commerce_tag_value__contact:phone"]');
|
||||||
if (phoneInput && phoneInput.value) {
|
if (phoneInput && phoneInput.value) {
|
||||||
const phoneRegex = /^(\+33|0)[1-9](\d{2}){4}$/;
|
const phoneRegex = /^(\+33|0)[1-9](\d{2}){4}$/;
|
||||||
|
@ -167,7 +141,6 @@ function check_validity(e){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage des erreurs si présentes
|
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
document.querySelector('#validation_messages').innerHTML = errors.join('<br>');
|
document.querySelector('#validation_messages').innerHTML = errors.join('<br>');
|
||||||
|
@ -180,27 +153,16 @@ function check_validity(e){
|
||||||
map = new mapboxgl.Map({
|
map = new mapboxgl.Map({
|
||||||
container: 'map',
|
container: 'map',
|
||||||
style: 'https://api.maptiler.com/maps/basic-v2/style.json?key={{ maptiler_token }}',
|
style: 'https://api.maptiler.com/maps/basic-v2/style.json?key={{ maptiler_token }}',
|
||||||
center: [
|
center: [{{ commerce_overpass['@attributes'].lon }}, {{ commerce_overpass['@attributes'].lat }}],
|
||||||
{{ commerce_overpass['@attributes'].lon }},
|
|
||||||
{{ commerce_overpass['@attributes'].lat }}
|
|
||||||
],
|
|
||||||
|
|
||||||
zoom: 14
|
zoom: 14
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ajout du marqueur
|
|
||||||
new mapboxgl.Marker()
|
new mapboxgl.Marker()
|
||||||
.setLngLat([
|
.setLngLat([{{ commerce_overpass['@attributes'].lon }}, {{ commerce_overpass['@attributes'].lat }}])
|
||||||
{{ commerce_overpass['@attributes'].lon }},
|
.setPopup(new mapboxgl.Popup({ offset: 25 }).setHTML('<h1>{{ commerce_overpass.tags_converted.name }}</h1>'))
|
||||||
{{ commerce_overpass['@attributes'].lat }}
|
|
||||||
])
|
|
||||||
.setPopup(new mapboxgl.Popup({
|
|
||||||
offset: 25
|
|
||||||
}).setHTML('<h1>{{ commerce_overpass.tags_converted.name }}</h1>'))
|
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
// Fonction pour calculer et mettre à jour la barre de progression
|
|
||||||
function updateCompletionProgress() {
|
function updateCompletionProgress() {
|
||||||
const inputs = document.querySelectorAll('input[type="text"]');
|
const inputs = document.querySelectorAll('input[type="text"]');
|
||||||
let filledInputs = 0;
|
let filledInputs = 0;
|
||||||
|
@ -214,20 +176,20 @@ function check_validity(e){
|
||||||
|
|
||||||
const completionPercentage = (filledInputs / totalInputs) * 100;
|
const completionPercentage = (filledInputs / totalInputs) * 100;
|
||||||
const progressBar = document.querySelector('#completion_progress .progress-bar');
|
const progressBar = document.querySelector('#completion_progress .progress-bar');
|
||||||
|
|
||||||
progressBar.style.width = completionPercentage + '%';
|
progressBar.style.width = completionPercentage + '%';
|
||||||
progressBar.setAttribute('aria-valuenow', completionPercentage);
|
progressBar.setAttribute('aria-valuenow', completionPercentage);
|
||||||
|
|
||||||
|
document.querySelector('#completion_display').innerHTML = `Votre commerce est complété à ${Math.round(completionPercentage)}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajouter les écouteurs d'événements sur tous les champs input
|
|
||||||
document.querySelectorAll('input[type="text"]').forEach(input => {
|
document.querySelectorAll('input[type="text"]').forEach(input => {
|
||||||
input.addEventListener('blur', updateCompletionProgress);
|
input.addEventListener('blur', updateCompletionProgress);
|
||||||
});
|
});
|
||||||
// Validation du formulaire avant envoi
|
|
||||||
document.querySelector('form').addEventListener('submit', check_validity);
|
|
||||||
|
|
||||||
// Calculer la progression initiale au chargement
|
document.querySelector('form').addEventListener('submit', check_validity);
|
||||||
document.addEventListener('DOMContentLoaded', updateCompletionProgress);
|
document.addEventListener('DOMContentLoaded', updateCompletionProgress);
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -5,20 +5,24 @@
|
||||||
<p class="description">{{ 'display.opening_hours_description'|trans }}</p>
|
<p class="description">{{ 'display.opening_hours_description'|trans }}</p>
|
||||||
|
|
||||||
{% if commerce_overpass.tags_converted.opening_hours is defined and commerce_overpass.tags_converted.opening_hours != '' %}
|
{% if commerce_overpass.tags_converted.opening_hours is defined and commerce_overpass.tags_converted.opening_hours != '' %}
|
||||||
{{ dump(commerce_overpass.tags_converted.opening_hours) }}
|
{# {{ dump(commerce_overpass.tags_converted.opening_hours) }} #}
|
||||||
<input type="text" placeholder="Remplissez" class="form-control" name="custom__opening_hours" value="{{ commerce_overpass.tags_converted.opening_hours }}">
|
<input type="text" placeholder="Remplissez" class="form-control" name="custom__opening_hours" value="{{ commerce_overpass.tags_converted.opening_hours }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="text" placeholder="Lundi de 10h à 12h et de 14h à 18h" class="form-control" name="custom__opening_hours" value="">
|
<input type="text" placeholder="Lundi de 10h à 12h et de 14h à 18h" class="form-control" name="custom__opening_hours" value="">
|
||||||
<br> ajoutez les horaires au format OSM
|
<br> ajoutez les horaires au format OSM
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<span class="examples">Exemples :</span>
|
<div class="examples d-none">
|
||||||
|
|
||||||
|
Exemples :
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Écrivez "24/7" pour indiquer que le commerce est ouvert 24 heures sur 24</li>
|
<li>Écrivez "24/7" pour indiquer que le commerce est ouvert 24 heures sur 24</li>
|
||||||
<li>Écrivez "Mo-Fr 9:00 - 18:00" pour indiquer que le commerce est ouvert du lundi au vendredi de 9h à 18h</li>
|
<li>Écrivez "Mo-Fr 9:00 - 18:00" pour indiquer que le commerce est ouvert du lundi au vendredi de 9h à 18h</li>
|
||||||
<li>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</li>
|
<li>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</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
{# <input type="checkbox" name="commerce_tag_value__opening_hours_1" value="yes">
|
{# <input type="checkbox" name="commerce_tag_value__opening_hours_1" value="yes">
|
||||||
Lundi de
|
Lundi de
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
|
|
||||||
{% for k, v in commerce_overpass.tags_converted %}
|
{% for k, v in commerce_overpass.tags_converted %}
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3 {% if hide_filled_inputs and v is not empty %}d-none{% endif %}">
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
{% if k not in excluded_tags_to_render %}
|
{% if k not in excluded_tags_to_render %}
|
||||||
{% if k == 'phone' or k == 'contact:phone' %}
|
{% if k == 'phone' or k == 'contact:phone' %}
|
||||||
<i class="bi bi-telephone"></i>
|
<i class="bi bi-telephone"></i>
|
||||||
{% elseif k == 'addr:housenumber' or k == 'addr:street' or k == 'addr:city' or k == 'addr:postcode' or k == 'addr:country' %}
|
{% elseif k == 'addr:housenumber' or k == 'addr:street' or k == 'addr:city' or k == 'addr:postcode' or k == 'addr:country' %}
|
||||||
<i class="bi bi-geo-alt"></i>
|
<i class="bi bi-geo-alt"></i>
|
||||||
{% elseif k == 'mastodon' %}
|
{% elseif k == 'contact:mastodon' %}
|
||||||
<i class="bi bi-mastodon"></i>
|
<i class="bi bi-mastodon"></i>
|
||||||
{% elseif k == 'email' or k == 'contact:email' %}
|
{% elseif k == 'email' or k == 'contact:email' %}
|
||||||
<i class="bi bi-envelope"></i>
|
<i class="bi bi-envelope"></i>
|
||||||
|
|
|
@ -13,18 +13,27 @@
|
||||||
<label class="form-check-label" for="wheelchair_yes">
|
<label class="form-check-label" for="wheelchair_yes">
|
||||||
{{'display.values.wheelchair.yes'|trans}}
|
{{'display.values.wheelchair.yes'|trans}}
|
||||||
</label>
|
</label>
|
||||||
|
<p>
|
||||||
|
toutes les pièces sont accessibles sans marche.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="commerce_tag_value__wheelchair" id="wheelchair_limited" value="limited" {% if commerce_overpass.tags_converted.wheelchair is defined and commerce_overpass.tags_converted.wheelchair == 'limited' %}checked{% endif %}>
|
<input class="form-check-input" type="radio" name="commerce_tag_value__wheelchair" id="wheelchair_limited" value="limited" {% if commerce_overpass.tags_converted.wheelchair is defined and commerce_overpass.tags_converted.wheelchair == 'limited' %}checked{% endif %}>
|
||||||
<label class="form-check-label" for="wheelchair_limited">
|
<label class="form-check-label" for="wheelchair_limited">
|
||||||
{{'display.values.wheelchair.limited'|trans}}
|
{{'display.values.wheelchair.limited'|trans}}
|
||||||
</label>
|
</label>
|
||||||
|
<p>
|
||||||
|
les pièces principales sont accessibles sans marche.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="commerce_tag_value__wheelchair" id="wheelchair_no" value="no" {% if commerce_overpass.tags_converted.wheelchair is defined and commerce_overpass.tags_converted.wheelchair == 'no' %}checked{% endif %}>
|
<input class="form-check-input" type="radio" name="commerce_tag_value__wheelchair" id="wheelchair_no" value="no" {% if commerce_overpass.tags_converted.wheelchair is defined and commerce_overpass.tags_converted.wheelchair == 'no' %}checked{% endif %}>
|
||||||
<label class="form-check-label" for="wheelchair_no">
|
<label class="form-check-label" for="wheelchair_no">
|
||||||
{{'display.values.wheelchair.no'|trans}}
|
{{'display.values.wheelchair.no'|trans}}
|
||||||
</label>
|
</label>
|
||||||
|
<p>
|
||||||
|
autres cas. une marche fait plus de 7cm, entrée trop étroite ou bien plusieurs marches.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -64,6 +64,7 @@ display:
|
||||||
source: "Source"
|
source: "Source"
|
||||||
ref:FR:SIRET: "SIRET"
|
ref:FR:SIRET: "SIRET"
|
||||||
image: "URL vers une Image"
|
image: "URL vers une Image"
|
||||||
|
note: "Champ libre, pour des informations complémentaires. Ne pas mettre de publicité"
|
||||||
disclaimer:
|
disclaimer:
|
||||||
title: "Attention"
|
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."
|
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."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue