-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
049de96
to
21c7219
Compare
da98ce2
to
87f33a0
Compare
@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 ? |
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.
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.
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(); | ||
} | ||
}); | ||
|
||
|
||
}); |
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.
On pourrait extraire ca dans un fichier séparé peut etre ?
ae33e4f
to
2626ad0
Compare
Implémentation du module de saisie de haies.