assiduité etudiant : debut justification rapide

This commit is contained in:
iziram 2023-04-13 17:31:13 +02:00
parent 2770b22d51
commit db5fe4f640
3 changed files with 80 additions and 4 deletions

View File

@ -1722,3 +1722,71 @@ function getCurrentAssiduiteModuleImplId() {
}
return "";
}
function getCurrentAssiduite(etudid) {
const field = document.querySelector(
`fieldset.btns_field.single[etudid='${etudid}']`
);
if (!field) return null;
const assiduite_id = parseInt(field.getAttribute("assiduite_id"));
const type = field.getAttribute("type");
if (type == "edition") {
let assi = null;
assiduites[etudid].forEach((a) => {
if (a.assiduite_id === assiduite_id) {
assi = a;
}
});
return assi;
} else {
return null;
}
}
// <<== Gestion de la justification ==>>
function getJustificatifFromPeriod(date) {
let justifs = [];
sync_get(
getUrl() +
`/api/justificatifs/${etudid}/query?date_debut=${date.deb.format()}&date_fin=${date.fin.format()}`,
(data) => {
justifs = data;
}
);
return justifs;
}
function updateJustifieButton(isJustified, isDisabled = true) {
const btn = document.getElementById("justif-rapide");
if (isJustified) {
btn.classList.add("justifie");
} else {
btn.classList.remove("justifie");
}
if (isDisabled) {
btn.setAttribute("disabled", "true");
} else {
btn.removeAttribute("disabled");
}
}
function fastJustify(assiduite) {
const period = {
deb: new moment.tz(assiduite.date_debut, TIMEZONE),
fin: new moment.tz(assiduite.date_fin, TIMEZONE),
};
const justifs = getJustificatifFromPeriod(period);
if (justifs.length > 0) {
//modifier l'assiduité
} else {
//créer un nouveau justificatif
// Afficher prompt -> demander raison et état
}
}

View File

@ -98,9 +98,7 @@
}
function updateSelectedSelect(moduleimpl_id) {
const select = document.getElementById('moduleimpl_select');
select.querySelector("option[selected]").removeAttribute("selected");
select.querySelector(`option[value="${moduleimpl_id}"]`).setAttribute('selected', 'true');
document.getElementById('moduleimpl_select').value = moduleimpl_id;
}

View File

@ -40,7 +40,11 @@
{% include "assiduites/timeline.j2" %}
{% include "assiduites/moduleimpl_dynamic_selector.j2" %}
<div>
{% include "assiduites/moduleimpl_dynamic_selector.j2" %}
<button class="btn" onclick="justify()" disabled id="justif-rapide">Justifier</button>
</div>
<div class="btn_group">
<button class="btn" onclick="setPeriodValues(8,18)">Journée</button>
@ -75,6 +79,7 @@
getSingleEtud({{ sco.etud.id }});
actualizeEtud({{ sco.etud.id }});
updateSelect()
</script>
@ -82,6 +87,11 @@
.rouge {
color: crimson;
}
.justifie {
background-color: rgb(104, 104, 252);
color: whitesmoke;
}
</style>
{% endblock %}