-
Notifications
You must be signed in to change notification settings - Fork 0
[FO - Formulaire police] BatId en cas d'adresse forcee #5704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
| attacheAutocompleteAddressEvent, | ||
| initComponentAddress, | ||
| } from '../../services/component/component_search_address'; | ||
| import { jsonResponseHandler } from '../../services/component/component_json_response_handler'; | ||
|
|
||
| import axios from 'axios'; | ||
|
|
||
| attachFormServiceSecoursEvent(); | ||
|
|
@@ -81,6 +83,58 @@ | |
|
|
||
| initDesordresAutreToggle(); | ||
| initUploadPhotos(); | ||
| initPickLocalisationButton(); | ||
| } | ||
|
|
||
| function initPickLocalisationButton() { | ||
| const adresseInput = document.querySelector('#service_secours_step2_adresseOccupant'); | ||
| const cpInput = document.querySelector('#service_secours_step2_cpOccupant'); | ||
| const pickButton = document.querySelector('.btn-pick-localisation'); | ||
| const modal = document.querySelector('#fr-modal-pick-localisation'); | ||
|
|
||
| if (!adresseInput || !cpInput || !pickButton || !modal) { | ||
| return; | ||
| } | ||
|
|
||
| function updatePickButton() { | ||
| const address = adresseInput.value.trim(); | ||
| const postcode = cpInput.value.trim(); | ||
| if (address && postcode) { | ||
| pickButton.classList.remove('fr-hidden'); | ||
| modal.setAttribute('data-address', address); | ||
|
Check failure on line 104 in assets/scripts/vanilla/controllers/front_service_secours/front_service_secours.js
|
||
| modal.setAttribute('data-postcode', postcode); | ||
|
Check failure on line 105 in assets/scripts/vanilla/controllers/front_service_secours/front_service_secours.js
|
||
| } else { | ||
| pickButton.classList.add('fr-hidden'); | ||
| } | ||
| } | ||
|
|
||
| adresseInput.addEventListener('input', updatePickButton); | ||
| cpInput.addEventListener('input', updatePickButton); | ||
|
|
||
| updatePickButton(); | ||
|
|
||
| const submitBtn = document.getElementById('fr-modal-pick-localisation-submit'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus nécessaire si on supprime la route |
||
| if (submitBtn) { | ||
| const form = submitBtn.form; | ||
| form.addEventListener('submit', async (event) => { | ||
| event.preventDefault(); | ||
| const formData = new FormData(form); | ||
| const response = await fetch(form.action, { | ||
| method: 'POST', | ||
| body: JSON.stringify(Object.fromEntries(formData)), | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }); | ||
| const responseClone = response.clone(); | ||
| const data = await response.json(); | ||
|
|
||
| jsonResponseHandler(responseClone); | ||
| if (data.success) { | ||
| document.getElementById('service_secours_step2_lat').value = data.lat; | ||
| document.getElementById('service_secours_step2_lng').value = data.lng; | ||
| document.getElementById('service_secours_step2_rnbId').value = data.rnbId; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| function initUploadPhotos() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| use App\Messenger\Message\SignalementServiceSecoursFileMessage; | ||
| use App\Repository\DesordreCritereRepository; | ||
| use App\Repository\SignalementRepository; | ||
| use App\Service\Gouv\Rnb\RnbService; | ||
| use App\Service\Mailer\NotificationMail; | ||
| use App\Service\Mailer\NotificationMailerRegistry; | ||
| use App\Service\Mailer\NotificationMailerType; | ||
|
|
@@ -101,6 +102,82 @@ | |
| ]); | ||
| } | ||
|
|
||
| #[Route( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je ne comprends pas l'utilité de cette route. Il me semble que ca permettrais de simplifier je met des autres com sur les élément à supprimer si on cette option. |
||
| '/services-secours/{slug:serviceSecoursRoute}/{uuid:serviceSecoursRoute}/completer/localisation', | ||
| name: 'service_secours_complete_localisation', | ||
| methods: 'POST', | ||
| defaults: ['_signed' => true] | ||
| )] | ||
| public function completeLocalisation( | ||
|
Check warning on line 111 in src/Controller/ServiceSecours/ServiceSecoursController.php
|
||
| ServiceSecoursRoute $serviceSecoursRoute, // Valide la route (slug/uuid/domaine) | ||
| Request $request, | ||
| RnbService $rnbService, | ||
| ): JsonResponse { | ||
| $requestData = json_decode($request->getContent(), true); | ||
| $rnbId = $requestData['rnbId'] ?? null; | ||
| $token = $requestData['_token'] ?? null; | ||
| if (!$this->isCsrfTokenValid('service_secours_set_rnb', $token)) { | ||
| $errorMsg = 'Token CSRF invalide, veuillez recharger la page'; | ||
|
|
||
| return $this->json([ | ||
| 'success' => false, | ||
| 'stayOnPage' => true, | ||
| 'flashMessages' => [ | ||
| [ | ||
| 'type' => 'alert', | ||
| 'title' => 'Erreur', | ||
| 'message' => $errorMsg, | ||
| ], | ||
| ], | ||
| ], Response::HTTP_BAD_REQUEST); | ||
| } | ||
|
|
||
| if (!$rnbId) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. la partie gestion d'erreur pourrait être concaténée dans un service, non ? on a 3 fois les mêmes tests pour ça |
||
| return $this->json([ | ||
| 'success' => false, | ||
| 'stayOnPage' => true, | ||
| 'flashMessages' => [ | ||
| [ | ||
| 'type' => 'alert', | ||
| 'title' => 'Erreur', | ||
| 'message' => 'RNB ID manquant ou bâtiment non trouvé.', | ||
| ], | ||
| ], | ||
| ], Response::HTTP_BAD_REQUEST); | ||
| } | ||
|
|
||
| $building = $rnbService->getBuilding($rnbId); | ||
| if (!$building) { | ||
| return $this->json([ | ||
| 'success' => false, | ||
| 'stayOnPage' => true, | ||
| 'flashMessages' => [ | ||
| [ | ||
| 'type' => 'alert', | ||
| 'title' => 'Erreur', | ||
| 'message' => 'Bâtiment introuvable.', | ||
| ], | ||
| ], | ||
| ], Response::HTTP_NOT_FOUND); | ||
| } | ||
|
|
||
| return $this->json([ | ||
| 'success' => true, | ||
| 'stayOnPage' => true, | ||
| 'closeModal' => true, | ||
| 'lat' => $building->getLat(), | ||
| 'lng' => $building->getLng(), | ||
| 'rnbId' => $building->getRnbId(), | ||
| 'flashMessages' => [ | ||
| [ | ||
| 'type' => 'success', | ||
| 'title' => 'Succès', | ||
| 'message' => 'Bâtiment sélectionné avec succès.', | ||
| ], | ||
| ], | ||
| ]); | ||
| } | ||
|
|
||
| #[Route( | ||
| '/services-secours/{slug:serviceSecoursRoute}/{uuid:serviceSecoursRoute}/pdf/{uuidSignalement}', | ||
| name: 'service_secours_pdf', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,12 @@ class FormServiceSecoursStep2 | |
|
|
||
| public ?string $inseeOccupant = null; | ||
|
|
||
| public ?string $rnbId = null; | ||
|
|
||
| public ?float $lat = null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus nécessaire si on supprime la route |
||
|
|
||
| public ?float $lng = null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus nécessaire si on supprime la route |
||
|
|
||
| #[Assert\Length(max: 255, groups: ['step2'])] | ||
| public ?string $adresseAutreOccupant = null; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void | |
| 'data-autocomplete-insee' => 'true', | ||
| ], | ||
| ]) | ||
| ->add('rnbId', HiddenType::class, [ | ||
| 'required' => false, | ||
| ]) | ||
| ->add('lat', HiddenType::class, [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus nécessaire si on supprime la route |
||
| 'required' => false, | ||
| ]) | ||
| ->add('lng', HiddenType::class, [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus nécessaire si on supprime la route |
||
| 'required' => false, | ||
| ]) | ||
|
|
||
| ->add('adresseAutreOccupant', TextType::class, [ | ||
| 'label' => 'Complément d\'adresse', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,15 @@ | |
| $hasViolation = true; | ||
| } | ||
|
|
||
| if ($value instanceof FormServiceSecoursStep2) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. si on fait ça, il faut vérifier que l'adresse est manuelle, sinon ça bloque pour les cas simples
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En effet ca alerte y compris en adresse automatique, je pense cependant qu'il ne faut pas du tout mettre de validation à ce niveau. Vu le peu d'élément obligatoire je ne vois pas pourquoi le |
||
| if (empty($value->rnbId)) { | ||
|
Check warning on line 67 in src/Validator/AdresseOccupantValidator.php
|
||
| $this->context->buildViolation($constraint->messageRnbId) | ||
| ->atPath('adresseCompleteOccupant') | ||
| ->addViolation(); | ||
| $hasViolation = true; | ||
| } | ||
| } | ||
|
|
||
| // S'il y a des violations, on s'arrête ici | ||
| if ($hasViolation) { | ||
| return; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,68 @@ | ||
| {% extends 'service_secours/base.html.twig' %} | ||
|
|
||
| {% block stylesheets %} | ||
| <link rel="stylesheet" href="{{ asset('build/leaflet/leaflet.css')}}"> | ||
| {% endblock %} | ||
|
|
||
| {% block body %} | ||
| <main class="fr-container fr-mb-5w" id="content"> | ||
| {% include "flash-messages.html.twig" %} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plus nécessaire si on supprime la route |
||
| <div id="flash-messages-live-container"></div> | ||
| {% set current_step = form.vars.cursor.currentStep %} | ||
| {% if current_step == 'step2' %} | ||
| <div data-ajax-form> | ||
| <form action="{{ sign_url(path('service_secours_complete_localisation', { | ||
| 'slug': 'ppp', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pourquoi
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ben ça devait être chez toi, il faudrait que tu modifies, ça ne fonctionne pas chez moi |
||
| 'uuid': 'serviceSecoursRoute.uuid', | ||
| 'domain': root_domain(app.request.host) | ||
| }), 3600) }}" method="POST" id="fr-modal-pick-localisation-form"> | ||
|
|
||
| <dialog | ||
| aria-labelledby="fr-modal-pick-localisation-title" | ||
| id="fr-modal-pick-localisation" | ||
| class="fr-modal" | ||
| data-address="{{form.step2.adresseOccupant.vars.value}}" | ||
| data-postcode="{{form.step2.cpOccupant.vars.value}}" | ||
| data-loaded="false" | ||
| > | ||
| <div class="fr-container fr-container--fluid fr-container-md"> | ||
| <div class="fr-grid-row fr-grid-row--center"> | ||
| <div class="fr-col-12 fr-col-md-8 fr-col-lg-6"> | ||
| <div class="fr-modal__body"> | ||
| <div class="fr-modal__header"> | ||
| <button type="button" class="fr-btn--close fr-btn" aria-controls="fr-modal-pick-localisation">Fermer</button> | ||
| </div> | ||
| <div class="fr-modal__content"> | ||
| <h1 class="fr-modal__title">Sélectionner le bâtiment correspondant au logement</h1> | ||
| <div id="fr-modal-pick-localisation-message">Chargement en cours</div> | ||
| <div id="fr-modal-pick-localisation-map"></div> | ||
| </div> | ||
| <input type="hidden" name="rnbId" id="fr-modal-pick-localisation-rnb-id"> | ||
| <input type="hidden" name="_token" id="fr-modal-pick-localisation-token" value="{{ csrf_token('service_secours_set_rnb') }}"> | ||
| <div class="fr-modal__footer"> | ||
| <ul class="fr-btns-group fr-btns-group--right fr-btns-group--inline-reverse fr-btns-group--inline-lg fr-btns-group--icon-left"> | ||
| <li> | ||
| <button class="fr-btn fr-icon-check-line" id="fr-modal-pick-localisation-submit" disabled type="submit" form="fr-modal-pick-localisation-form"> | ||
| Valider | ||
| </button> | ||
| </li> | ||
| <li> | ||
| <button type="button" class="fr-btn fr-btn--secondary fr-icon-close-line" aria-controls="fr-modal-pick-localisation"> | ||
| Annuler | ||
| </button> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </dialog> | ||
| </form> | ||
| </div> | ||
| {% endif %} | ||
| <section class="fr-grid-row fr-grid-row--center"> | ||
| <div class="fr-mt-5v fr-col-md-12"> | ||
| {% set current_step = form.vars.cursor.currentStep %} | ||
| {% if current_step === 'step1' %} | ||
| {% set step_number = 1 %} | ||
| {% set step_title = 'Vos coordonnées' %} | ||
|
|
@@ -76,6 +134,17 @@ | |
| {{ form_row(form.step2.cpOccupant) }} | ||
| {{ form_row(form.step2.villeOccupant) }} | ||
| {{ form_row(form.step2.inseeOccupant) }} | ||
| {{ form_widget(form.step2.rnbId) }} | ||
| {{ form_widget(form.step2.lat) }} | ||
| {{ form_widget(form.step2.lng) }} | ||
| <button | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. il manque le picto sur le bouton (il faut inclure des css dsfr, il me semble) |
||
| type="button" | ||
| class="fr-btn fr-btn--sm fr-btn--icon-left fr-icon-map-pin-2-line btn-pick-localisation fr-hidden" | ||
| data-fr-opened="false" | ||
| aria-controls="fr-modal-pick-localisation" | ||
| > | ||
| Sélectionner le bâtiment sur la carte | ||
| </button> | ||
| </div> | ||
| {{ form_row(form.step2.adresseAutreOccupant) }} | ||
| {{ form_row(form.step2.isLogementSocial, {display_mode: 'block'}) }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus nécessaire si on supprime la route
service_secours_complete_localisation