affichage de modif qui cache les champs déjà remplis

This commit is contained in:
Tykayn 2025-05-27 19:13:35 +02:00 committed by tykayn
parent 2628b1c7f7
commit f11ab48bb9
8 changed files with 166 additions and 115 deletions

View file

@ -12,9 +12,12 @@ use Symfony\Component\Routing\Annotation\Route;
use GuzzleHttp\Client;
use Symfony\Component\HttpFoundation\Request;
class PublicController extends AbstractController
{
private $hide_filled_inputs = true;
public function __construct(
private EntityManagerInterface $entityManager,
private Motocultrice $motocultrice
@ -65,6 +68,7 @@ class PublicController extends AbstractController
'commerce_overpass' => $commerce_overpass,
'name' => $name,
'commerce' => $place,
'hide_filled_inputs' => $this->hide_filled_inputs,
'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render,
'osm_kind' => $place->getOsmKind(),
"mapbox_token" => $_ENV['MAPBOX_TOKEN'],
@ -108,7 +112,7 @@ class PublicController extends AbstractController
$request_post = $this->motocultrice->map_post_values($request_post);
foreach ($request_post as $key => $value) {
// var_dump($key, $value);
if (strpos($key, 'commerce_tag_value__') === 0) {
$tagKey = str_replace('commerce_tag_value__', '', $key);
if (!empty($value)) {
@ -225,9 +229,13 @@ class PublicController extends AbstractController
// après envoi on récupère les données
$commerce = $this->motocultrice->get_osm_object_data($osm_kind, $osm_object_id);
return $this->render('public/view.html.twig', [
'controller_name' => 'PublicController',
'commerce' => $commerce,
'status' => $status,
'exception' => $exception,
'exception_message' => $exception_message,

View file

@ -26,9 +26,39 @@ class Motocultrice
'addr:street',
'contact:website',
'contact:mastodon',
'image',
'image',
'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'];
public function __construct(
private HttpClientInterface $client,
@ -41,6 +71,11 @@ class Motocultrice
$has_ask_angela = false;
$remove_ask_angela = false;
$has_opening_hours = false;
// $has_phone = false;
// $has_contact_phone = false;
// $has_email = false;
// $has_contact_email = false;
$modified_request_post = [];
@ -171,12 +206,14 @@ QUERY;
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'] = $this->migrate_tags($osm_object_data['node']['tags_converted']);
return $osm_object_data['node'];
}
if(isset($osm_object_data['way'])){
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'] = $this->migrate_tags($osm_object_data['way']['tags_converted']);
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() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
@ -212,7 +272,7 @@ QUERY;
$essentialTags = [
'name',
'opening_hours',
'phone',
// 'phone',
'contact:email',
'contact:phone',
'website',