Skip to content
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

Ajout de la saisie des haies dans le simulateur côté haies #422

Merged
merged 67 commits into from
Oct 14, 2024

Conversation

thibault
Copy link
Collaborator

@thibault thibault commented Sep 24, 2024

Implémentation du module de saisie de haies.

@thibault thibault requested a review from pyDez September 24, 2024 12:59
@thibault thibault force-pushed the poc_saisie_haie branch 2 times, most recently from 049de96 to 21c7219 Compare October 4, 2024 08:06
@thibault thibault marked this pull request as ready for review October 9, 2024 16:02
@thibault
Copy link
Collaborator Author

thibault commented Oct 9, 2024

@pyDez La branche va devoir être mergée en prod, même si la fonctionnalité elle-même n'est pas terminée.

Par conséquent, je pense qu'on peut ouvrir la revue. Est-ce que tu as besoin de quelques détails pour ça, ou je te laisse jeter un premier coup d'œil ?

@thibault thibault changed the title Poc saisie haie Ajout de la saisie des haies dans le simulateur côté haies Oct 9, 2024
envergo/hedges/views.py Dismissed Show dismissed Hide dismissed
Copy link
Collaborator

@pyDez pyDez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je vais suivre le bon vieux théorème :

PR de 5 lignes => 10 retours lors de la code review
PR de 1000 lignes => LGTM !

Je ne suis pas rentré dans le détails, mais je n'ai rien vu de choquant.

Comment on lines +113 to +159
window.addEventListener("load", function() {
let btn = document.getElementById("hedge-input-open-btn");
let modal = document.getElementById("hedge-input-modal");
let hedgeIdField = document.getElementById("id_haies");
let hedgeDataStatsTpl = document.getElementById("hedge-data-statistics");
let statisticsContainer = document.getElementById("statistics-container");
let hedgeIframe;

// open the hedge input ui in a modal upon the button click
btn.addEventListener("click", function() {
let saveUrl = "{% url 'input_hedges' %}";
let hedgeId = hedgeIdField.value;
if (hedgeId) {
saveUrl += hedgeId + "/";
}
hedgeIframe = window.open(saveUrl, "hedge-input-iframe");
modal.showModal();
});

// When the input is saved, close the modal
window.addEventListener("message", function(event) {
if (event.origin !== window.location.origin) {
return;
}

if (event.data.action === "cancel") {
hedgeIframe.close();
modal.close();
}

if (event.data.input_id) {
let statsContent = hedgeDataStatsTpl.content.cloneNode(true);
let lengthToRemove = statsContent.getElementById("length-to-remove");
let lengthToPlant = statsContent.getElementById("length-to-plant");
lengthToRemove.textContent = event.data.length_to_remove;
lengthToPlant.textContent = event.data.length_to_plant;
statisticsContainer.innerHTML = "";
statisticsContainer.appendChild(statsContent);

hedgeIdField.value = event.data.input_id;
hedgeIframe.close();
modal.close();
}
});


});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On pourrait extraire ca dans un fichier séparé peut etre ?

@thibault thibault merged commit e020cf5 into main Oct 14, 2024
8 checks passed
@thibault thibault deleted the poc_saisie_haie branch October 14, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants