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/hedges/views.py b/envergo/hedges/views.py index 03fac187d..249d620a2 100644 --- a/envergo/hedges/views.py +++ b/envergo/hedges/views.py @@ -39,11 +39,19 @@ 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") + ) + elif mode == "read_only": + context["matomo_custom_url"] = self.request.build_absolute_uri( + reverse("petition_project_hedges") + ) + return context def post(self, request, *args, **kwargs): diff --git a/envergo/petitions/urls_haie.py b/envergo/petitions/urls_haie.py index 5cbf6cb99..df8ba9bbd 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, @@ -10,10 +11,16 @@ urlpatterns = [ path("", PetitionProjectCreate.as_view(), name="petition_project_create"), path( - "/", + "/consultation/", 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/", diff --git a/envergo/petitions/views.py b/envergo/petitions/views.py index 2c7254a38..d44f2547c 100644 --- a/envergo/petitions/views.py +++ b/envergo/petitions/views.py @@ -25,7 +25,7 @@ from envergo.petitions.services import compute_instructor_informations 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__) @@ -402,7 +402,7 @@ def get_context_data(self, **kwargs): class PetitionProjectDetail(PetitionProjectMixin, FormView): - template_name = "haie/moulinette/result_plantation.html" + template_name = "haie/moulinette/petition_project.html" def get(self, request, *args, **kwargs): result = super().get(request, *args, **kwargs) @@ -427,6 +427,22 @@ 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 + + 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}" + ) return context 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/static/sass/project_haie.scss b/envergo/static/sass/project_haie.scss index 2219fb0e0..e348dd4f5 100644 --- a/envergo/static/sass/project_haie.scss +++ b/envergo/static/sass/project_haie.scss @@ -358,3 +358,12 @@ div#form-group-haies { div#demarches-simplifiees-modal-btns { display: flex; } + +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 new file mode 100644 index 000000000..9f2504915 --- /dev/null +++ b/envergo/templates/haie/moulinette/petition_project.html @@ -0,0 +1,49 @@ +{% extends 'haie/moulinette/result_plantation.html' %} + +{% load static %} + +{% block result_title %} + +

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 %} + +{% 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/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 %} 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