From ec884865ed9714b78198295bfa981d837baea12f Mon Sep 17 00:00:00 2001 From: PY Date: Fri, 10 Jan 2025 12:07:50 +0100 Subject: [PATCH 1/5] add cta and text to project view --- envergo/petitions/views.py | 21 +++++++++---- envergo/static/sass/project_haie.scss | 5 +++ .../haie/moulinette/petition_project.html | 31 +++++++++++++++++++ .../haie/moulinette/result_base.html | 2 +- 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 envergo/templates/haie/moulinette/petition_project.html diff --git a/envergo/petitions/views.py b/envergo/petitions/views.py index c3ca79f68..72c1f4efe 100644 --- a/envergo/petitions/views.py +++ b/envergo/petitions/views.py @@ -348,7 +348,7 @@ def form_invalid(self, form): class PetitionProjectDetail(MoulinetteMixin, FormView): - template_name = "haie/moulinette/result_plantation.html" + template_name = "haie/moulinette/petition_project.html" def __init__(self, **kwargs): super().__init__(**kwargs) @@ -357,11 +357,11 @@ def __init__(self, **kwargs): def get(self, request, *args, **kwargs): # Instanciate the moulinette object from the petition project in order to use the MoulinetteMixin - petition_project = get_object_or_404( + self.petition_project = get_object_or_404( PetitionProject.objects.select_related("hedge_data"), reference=self.kwargs["reference"], ) - parsed_url = urlparse(petition_project.moulinette_url) + parsed_url = urlparse(self.petition_project.moulinette_url) query_string = parsed_url.query # We need to convert the query string to a flat dict raw_data = QueryDict(query_string) @@ -370,7 +370,7 @@ def get(self, request, *args, **kwargs): self.request.moulinette_data = raw_data moulinette_data = raw_data.dict() - moulinette_data["haies"] = petition_project.hedge_data + moulinette_data["haies"] = self.petition_project.hedge_data MoulinetteClass = get_moulinette_class_from_site(self.request.site) self.moulinette = MoulinetteClass( @@ -386,7 +386,7 @@ def get(self, request, *args, **kwargs): logger.warning( "A petition project has missing data. This should not happen unless regulations have changed." "We should implement static simulation/project to avoid this case.", - extra={"reference": petition_project.reference}, + extra={"reference": self.petition_project.reference}, ) raise NotImplementedError("We do not handle uncompleted project") @@ -396,7 +396,7 @@ def get(self, request, *args, **kwargs): "projet", "consultation", self.request, - **petition_project.get_log_event_data(), + **self.petition_project.get_log_event_data(), **get_matomo_tags(self.request), ) @@ -410,6 +410,15 @@ def get_context_data(self, **kwargs): context["plantation_evaluation"] = PlantationEvaluator( self.moulinette, self.moulinette.catalog["haies"] ) + context["demarches_simplifiees_dossier_number"] = ( + self.petition_project.demarches_simplifiees_dossier_number + ) + context["created_at"] = self.petition_project.created_at + context["moulinette_url"] = self.petition_project.moulinette_url + context["ds_url"] = ( + f"https://www.demarches-simplifiees.fr/dossiers/" + f"{self.petition_project.demarches_simplifiees_dossier_number}" + ) return context diff --git a/envergo/static/sass/project_haie.scss b/envergo/static/sass/project_haie.scss index edccb8143..92fa2f7e1 100644 --- a/envergo/static/sass/project_haie.scss +++ b/envergo/static/sass/project_haie.scss @@ -354,3 +354,8 @@ div#form-group-haies { margin-bottom: 1rem; } } + +div#go-to-ds-btn { + display: flex; + justify-content: flex-end; +} diff --git a/envergo/templates/haie/moulinette/petition_project.html b/envergo/templates/haie/moulinette/petition_project.html new file mode 100644 index 000000000..ffca530da --- /dev/null +++ b/envergo/templates/haie/moulinette/petition_project.html @@ -0,0 +1,31 @@ +{% extends 'haie/moulinette/result_plantation.html' %} + +{% block result_title %} +
+ Voir le dossier sur Démarches simplifiées +
+

Dossier n° {{ demarches_simplifiees_dossier_number }}

+

+ Déposé le {{ created_at }} +

+{% endblock %} + +{% block result_header %} +

Vous souhaitez modifier votre simulation ?

+

Cette simulation n’est plus modifiable car elle a été pris en compte dans votre dossier.

+

+ Vous pouvez dupliquer cette version, la modifier comme vous le souhaitez puis recréer un dossier pour déposer votre demande. +

+ Dupliquer cette simulation + +

Besoin d’échanger sur votre projet ?

+ + Contacter le guichet unique + +

Résultats de la simulation réglementaire

+ {{ block.super }} +{% endblock %} diff --git a/envergo/templates/haie/moulinette/result_base.html b/envergo/templates/haie/moulinette/result_base.html index dfca3f9f1..08fa6bf1c 100644 --- a/envergo/templates/haie/moulinette/result_base.html +++ b/envergo/templates/haie/moulinette/result_base.html @@ -31,7 +31,7 @@ cette page grâce à votre statut d'admin. {% endif %} -

Simulation réglementaire

+ {% block result_title %}

Simulation réglementaire

{% endblock %} {% block result_header %}{% endblock %} {% group_regulations_for_display moulinette as grouped_regulations %} From 4b64b6e9736f87c18e29c2e02a962fa1424cf98a Mon Sep 17 00:00:00 2001 From: PY Date: Mon, 13 Jan 2025 16:46:32 +0100 Subject: [PATCH 2/5] read only hedges --- envergo/hedges/static/hedge_input/app.js | 25 +++++-------------- ...es_input_plantation.js => hedges_input.js} | 4 +-- .../haie/moulinette/petition_project.html | 16 ++++++++++++ envergo/templates/haie/moulinette/result.html | 3 ++- envergo/templates/hedges/input.html | 24 ++++++++---------- 5 files changed, 35 insertions(+), 37 deletions(-) rename envergo/static/js/libs/{hedges_input_plantation.js => hedges_input.js} (91%) diff --git a/envergo/hedges/static/hedge_input/app.js b/envergo/hedges/static/hedge_input/app.js index 24a9ca270..34cd6c1ad 100644 --- a/envergo/hedges/static/hedge_input/app.js +++ b/envergo/hedges/static/hedge_input/app.js @@ -266,14 +266,14 @@ createApp({ // Cacher la bulle d'aide à la fin du tracé newHedge.polyline.on('editable:drawing:end', () => { showHelpBubble.value = false; - showHedgeModal(newHedge); + showHedgeModal(newHedge, mode === "plantation" ? TO_PLANT : TO_REMOVE); }); return newHedge; }; // Show the "description de la haie" form modal - const showHedgeModal = (hedge, isReadonly) => { + const showHedgeModal = (hedge, hedgeType) => { const fillBooleanField = (fieldElement, fieldName, data) => { if(fieldElement && data.hasOwnProperty(fieldName)) { @@ -281,10 +281,8 @@ createApp({ } } - // There is two edge data dialogs as edges to plant and to remove have differrent properties - // By default we take the dialog of the current mode. - // If the form is readonly, then we display the other mode dialog. - const dialogMode = isReadonly ? (mode === "removal" ? "plantation" : "removal") : mode; + const isReadonly = (hedgeType !== TO_PLANT || mode !== "plantation") && (hedgeType !== TO_REMOVE || mode !== "removal"); + const dialogMode = hedgeType === TO_PLANT ? "plantation" : "removal"; const dialogId= `${dialogMode}-hedge-data-dialog` const dialog = document.getElementById(dialogId); @@ -395,16 +393,6 @@ createApp({ dsfr(dialog).modal.disclose(); }; - // Open the form modal to edit an existing hedge - const editHedge = (hedge) => { - showHedgeModal(hedge, false); - }; - - // Open the form modal to display an existing hedge - const displayHedge = (hedge) => { - showHedgeModal(hedge, true); - }; - const startDrawingToPlant = () => { return addHedge(TO_PLANT); }; @@ -466,7 +454,7 @@ createApp({ // We confirm with a modal if some hedges have been drawn const cancel = () => { const totalHedges = hedges[TO_PLANT].count + hedges[TO_REMOVE].count; - if (totalHedges > 0) { + if (totalHedges > 0 && mode !== "read_only") { const dialog = document.getElementById("cancel-modal"); const confirmCancel = document.getElementById("btn-quit-without-saving"); const dismissCancel = document.getElementById("btn-back-to-map"); @@ -609,8 +597,7 @@ createApp({ showHelpBubble, saveData, cancel, - editHedge, - displayHedge, + showHedgeModal, invalidHedges, }; } diff --git a/envergo/static/js/libs/hedges_input_plantation.js b/envergo/static/js/libs/hedges_input.js similarity index 91% rename from envergo/static/js/libs/hedges_input_plantation.js rename to envergo/static/js/libs/hedges_input.js index e8b97932b..e09797cea 100644 --- a/envergo/static/js/libs/hedges_input_plantation.js +++ b/envergo/static/js/libs/hedges_input.js @@ -2,13 +2,11 @@ window.addEventListener("load", function () { let buttons = document.querySelectorAll(".hedge-input-open-btn"); let modal = document.getElementById("hedge-input-modal"); - const urlParams = new URLSearchParams(window.location.search); - const hedgeId = urlParams.get('haies'); - let hedgeIframe; const openModal = function () { let saveUrl = HEDGES_PLANTATION_URL; + const hedgeId = HEDGE_DATA_ID; if (hedgeId) { saveUrl += hedgeId + "/"; } diff --git a/envergo/templates/haie/moulinette/petition_project.html b/envergo/templates/haie/moulinette/petition_project.html index ffca530da..6b0357ba7 100644 --- a/envergo/templates/haie/moulinette/petition_project.html +++ b/envergo/templates/haie/moulinette/petition_project.html @@ -1,5 +1,7 @@ {% extends 'haie/moulinette/result_plantation.html' %} +{% load static %} + {% block result_title %}
Besoin d’échanger sur votre projet ?

Résultats de la simulation réglementaire

{{ block.super }} {% endblock %} + +{% block project_summary %} + {{ block.super }} + +{% endblock %} + +{% block extra_js %} + + + +{% endblock %} diff --git a/envergo/templates/haie/moulinette/result.html b/envergo/templates/haie/moulinette/result.html index 9df3b1597..7aa0712bc 100644 --- a/envergo/templates/haie/moulinette/result.html +++ b/envergo/templates/haie/moulinette/result.html @@ -17,7 +17,8 @@ {% block extra_js %} + - + {% endblock %} diff --git a/envergo/templates/hedges/input.html b/envergo/templates/hedges/input.html index 3333947e5..30e988293 100644 --- a/envergo/templates/hedges/input.html +++ b/envergo/templates/hedges/input.html @@ -86,18 +86,16 @@

[[ hedge.id ]] À compléter - + + @click.stop="showHedgeModal(hedge, hedge.type)"> + [[ mode === 'removal' ? 'Modifier' : 'Voir la description' ]] + - - - [[ hedge.length.toFixed(0) ]] m @@ -129,19 +127,16 @@

À compléter - + - - - [[ hedge.length.toFixed(0) ]] m @@ -205,7 +200,8 @@

Complétez la description des haies pour pouvoir pou
-

From 01f3ee49f96426698c5418d996f3e75cdbd28a36 Mon Sep 17 00:00:00 2001 From: PY Date: Mon, 13 Jan 2025 17:02:58 +0100 Subject: [PATCH 3/5] urls --- envergo/petitions/urls_haie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envergo/petitions/urls_haie.py b/envergo/petitions/urls_haie.py index 29005c57b..1973aa727 100644 --- a/envergo/petitions/urls_haie.py +++ b/envergo/petitions/urls_haie.py @@ -9,7 +9,7 @@ urlpatterns = [ path("", PetitionProjectCreate.as_view(), name="petition_project_create"), path( - "", + "/consultation/", PetitionProjectDetail.as_view(), name="petition_project", ), From 0fe82565713bd15823d8b8244a25dd14880f0112 Mon Sep 17 00:00:00 2001 From: PY Date: Mon, 13 Jan 2025 17:29:24 +0100 Subject: [PATCH 4/5] urls --- envergo/hedges/views.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/envergo/hedges/views.py b/envergo/hedges/views.py index 03fac187d..fe7d13869 100644 --- a/envergo/hedges/views.py +++ b/envergo/hedges/views.py @@ -39,11 +39,15 @@ def get_context_data(self, **kwargs): context["hedge_to_plant_data_form"] = HedgeToPlantDataForm(prefix="plantation") context["hedge_to_remove_data_form"] = HedgeToRemoveDataForm(prefix="removal") - context["matomo_custom_url"] = self.request.build_absolute_uri( - reverse("moulinette_saisie_d") - if mode == "removal" - else reverse("moulinette_saisie_p") - ) + if mode == "removal": + context["matomo_custom_url"] = self.request.build_absolute_uri( + reverse("moulinette_saisie_d") + ) + elif mode == "plantation": + context["matomo_custom_url"] = self.request.build_absolute_uri( + reverse("moulinette_saisie_p") + ) + return context def post(self, request, *args, **kwargs): From b13cdea685707ce66b425e700d6e920fa4efaf0c Mon Sep 17 00:00:00 2001 From: PY Date: Thu, 16 Jan 2025 06:30:46 +0100 Subject: [PATCH 5/5] graphical review + edit link + url --- envergo/hedges/views.py | 4 ++++ envergo/petitions/urls_haie.py | 9 ++++++++- envergo/petitions/views.py | 11 +++++++++-- envergo/static/sass/project_haie.scss | 4 ++++ .../templates/haie/moulinette/petition_project.html | 10 ++++++---- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/envergo/hedges/views.py b/envergo/hedges/views.py index fe7d13869..249d620a2 100644 --- a/envergo/hedges/views.py +++ b/envergo/hedges/views.py @@ -47,6 +47,10 @@ def get_context_data(self, **kwargs): context["matomo_custom_url"] = self.request.build_absolute_uri( reverse("moulinette_saisie_p") ) + elif mode == "read_only": + context["matomo_custom_url"] = self.request.build_absolute_uri( + reverse("petition_project_hedges") + ) return context diff --git a/envergo/petitions/urls_haie.py b/envergo/petitions/urls_haie.py index 1973aa727..7f6765198 100644 --- a/envergo/petitions/urls_haie.py +++ b/envergo/petitions/urls_haie.py @@ -1,4 +1,5 @@ from django.urls import path +from django.views.generic import RedirectView from envergo.petitions.views import ( PetitionProjectAutoRedirection, @@ -13,9 +14,15 @@ PetitionProjectDetail.as_view(), name="petition_project", ), + # This is another "fake" url, only for matomo tracking + path( + "+ref_proj+/consultation/haies/", + RedirectView.as_view(pattern_name="home"), + name="petition_project_hedges", + ), # a path that redirects to the petition project detail page without logging the event path( - "/auto-redirection", + "/auto-redirection/", PetitionProjectAutoRedirection.as_view(), name="petition_project_auto_redirection", ), diff --git a/envergo/petitions/views.py b/envergo/petitions/views.py index 72c1f4efe..7fa679e20 100644 --- a/envergo/petitions/views.py +++ b/envergo/petitions/views.py @@ -24,7 +24,7 @@ from envergo.petitions.models import PetitionProject from envergo.utils.mattermost import notify from envergo.utils.tools import display_form_details, generate_key -from envergo.utils.urls import extract_param_from_url +from envergo.utils.urls import extract_param_from_url, update_qs logger = logging.getLogger(__name__) @@ -414,7 +414,14 @@ def get_context_data(self, **kwargs): self.petition_project.demarches_simplifiees_dossier_number ) context["created_at"] = self.petition_project.created_at - context["moulinette_url"] = self.petition_project.moulinette_url + + parsed_moulinette_url = urlparse(self.petition_project.moulinette_url) + moulinette_params = parse_qs(parsed_moulinette_url.query) + moulinette_params["edit"] = ["true"] + result_url = reverse("moulinette_result") + edit_url = update_qs(result_url, moulinette_params) + + context["edit_url"] = edit_url context["ds_url"] = ( f"https://www.demarches-simplifiees.fr/dossiers/" f"{self.petition_project.demarches_simplifiees_dossier_number}" diff --git a/envergo/static/sass/project_haie.scss b/envergo/static/sass/project_haie.scss index 92fa2f7e1..0d7036f81 100644 --- a/envergo/static/sass/project_haie.scss +++ b/envergo/static/sass/project_haie.scss @@ -359,3 +359,7 @@ div#go-to-ds-btn { display: flex; justify-content: flex-end; } + +button#project-summary-hedge-input-open-btn { + background-color: var(--grey-1000-50); +} diff --git a/envergo/templates/haie/moulinette/petition_project.html b/envergo/templates/haie/moulinette/petition_project.html index 6b0357ba7..9f2504915 100644 --- a/envergo/templates/haie/moulinette/petition_project.html +++ b/envergo/templates/haie/moulinette/petition_project.html @@ -9,7 +9,7 @@ target="_blank" rel="noopener external">Voir le dossier sur Démarches simplifiées -

Dossier n° {{ demarches_simplifiees_dossier_number }}

+

Dossier n° {{ demarches_simplifiees_dossier_number }}

Déposé le {{ created_at }}

@@ -17,11 +17,12 @@

Dossier n° {{ demarches_simplifiees_dossier_number }}

{% block result_header %}

Vous souhaitez modifier votre simulation ?

-

Cette simulation n’est plus modifiable car elle a été pris en compte dans votre dossier.

+ Cette simulation n’est plus modifiable car elle a été pris en compte dans votre dossier. +
Vous pouvez dupliquer cette version, la modifier comme vous le souhaitez puis recréer un dossier pour déposer votre demande.

- Dupliquer cette simulation + Dupliquer cette simulation

Besoin d’échanger sur votre projet ?

@@ -34,7 +35,8 @@

Résultats de la simulation réglementaire

{% block project_summary %} {{ block.super }} -