-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add present count in meeting change form
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends "admin/change_form.html" %} | ||
|
||
{% block after_related_objects %} | ||
{{ block.super }} | ||
<p id="present-count"></p> | ||
<script> | ||
window.addEventListener("DOMContentLoaded", function() { | ||
var present_count = document.getElementById("present-count"); | ||
var children_checkboxes = document.querySelectorAll("#attendances-group .field-is_present input"); | ||
function updatePresentCount() { | ||
var count = 0; | ||
for (var checkbox of children_checkboxes) { | ||
if (checkbox.checked) | ||
count++; | ||
} | ||
present_count.textContent = count + " enfant" + (count > 1 ? "s" : "") + " présent" + (count > 1 ? "s" : "") + " sur " + children_checkboxes.length + ". Taux de présence : " + (count / children_checkboxes.length * 100).toFixed(2) + "%"; | ||
} | ||
for (var checkbox of children_checkboxes) { | ||
checkbox.addEventListener("change", updatePresentCount); | ||
} | ||
updatePresentCount(); | ||
}); | ||
</script> | ||
{% endblock after_related_objects %} |