2022-06-21 18:33:43 +02:00
|
|
|
// active les menus des codes "manuels" (année, RCUEs)
|
|
|
|
function enable_manual_codes(elt) {
|
2023-11-17 13:53:17 +01:00
|
|
|
$(".jury_but select.manual").prop("disabled", !elt.checked);
|
2022-06-21 18:33:43 +02:00
|
|
|
}
|
2022-06-22 11:44:03 +02:00
|
|
|
|
2023-01-11 13:37:02 +01:00
|
|
|
// changement d'un menu code:
|
2022-06-22 11:44:03 +02:00
|
|
|
function change_menu_code(elt) {
|
2023-11-17 13:53:17 +01:00
|
|
|
// Ajuste styles pour visualiser codes enregistrés/modifiés
|
|
|
|
if (elt.value != elt.dataset.orig_code) {
|
|
|
|
elt.parentElement.parentElement.classList.add("modified");
|
|
|
|
} else {
|
|
|
|
elt.parentElement.parentElement.classList.remove("modified");
|
|
|
|
}
|
|
|
|
if (elt.value == elt.dataset.orig_recorded) {
|
|
|
|
elt.parentElement.parentElement.classList.add("recorded");
|
|
|
|
} else {
|
|
|
|
elt.parentElement.parentElement.classList.remove("recorded");
|
|
|
|
}
|
|
|
|
// Si RCUE passant en ADJ, change les menus des UEs associées ADJR
|
|
|
|
if (
|
|
|
|
elt.classList.contains("code_rcue") &&
|
|
|
|
elt.dataset.niveau_id &&
|
|
|
|
elt.value == "ADJ" &&
|
|
|
|
elt.value != elt.dataset.orig_recorded
|
|
|
|
) {
|
|
|
|
let ue_selects =
|
|
|
|
elt.parentElement.parentElement.parentElement.querySelectorAll(
|
|
|
|
"select.ue_rcue_" + elt.dataset.niveau_id
|
|
|
|
);
|
|
|
|
ue_selects.forEach((select) => {
|
|
|
|
if (select.value != "ADM") {
|
|
|
|
select.value = "ADJR";
|
|
|
|
change_menu_code(select); // pour changer les styles
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-06-29 22:53:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$(function () {
|
2023-11-17 13:53:17 +01:00
|
|
|
// Recupère la liste ordonnées des etudids
|
|
|
|
// pour avoir le "suivant" et le "précédent"
|
|
|
|
// (liens de navigation)
|
|
|
|
const url = new URL(document.URL);
|
|
|
|
const frags = url.pathname.split("/"); // .../formsemestre_validation_but/formsemestre_id/etudid
|
|
|
|
const etudid = frags[frags.length - 1];
|
|
|
|
const formsemestre_id = frags[frags.length - 2];
|
|
|
|
const etudids_key = JSON.stringify(["etudids", url.origin, formsemestre_id]);
|
|
|
|
const etudids_str = localStorage.getItem(etudids_key);
|
|
|
|
const noms_key = JSON.stringify(["noms", url.origin, formsemestre_id]);
|
|
|
|
const noms_str = localStorage.getItem(noms_key);
|
|
|
|
if (etudids_str && noms_str) {
|
|
|
|
const etudids = JSON.parse(etudids_str);
|
|
|
|
const noms = JSON.parse(noms_str);
|
|
|
|
const cur_idx = etudids.indexOf(etudid);
|
|
|
|
let prev_idx = -1;
|
|
|
|
let next_idx = -1;
|
|
|
|
if (cur_idx != -1) {
|
|
|
|
if (cur_idx > 0) {
|
|
|
|
prev_idx = cur_idx - 1;
|
|
|
|
}
|
|
|
|
if (cur_idx < etudids.length - 1) {
|
|
|
|
next_idx = cur_idx + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (prev_idx != -1) {
|
|
|
|
let elem = document.querySelector("div.prev a");
|
|
|
|
if (elem) {
|
|
|
|
elem.href = elem.href.replace("PREV", etudids[prev_idx]);
|
|
|
|
elem.innerHTML = noms[prev_idx];
|
|
|
|
}
|
2023-01-26 16:35:15 +01:00
|
|
|
} else {
|
2023-11-17 13:53:17 +01:00
|
|
|
document.querySelector("div.prev").innerHTML = "";
|
2022-06-29 22:53:56 +02:00
|
|
|
}
|
2023-11-17 13:53:17 +01:00
|
|
|
if (next_idx != -1) {
|
|
|
|
let elem = document.querySelector("div.next a");
|
|
|
|
if (elem) {
|
|
|
|
elem.href = elem.href.replace("NEXT", etudids[next_idx]);
|
|
|
|
elem.innerHTML = noms[next_idx];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
document.querySelector("div.next").innerHTML = "";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Supprime les liens de navigation
|
|
|
|
document.querySelector("div.prev").innerHTML = "";
|
|
|
|
document.querySelector("div.next").innerHTML = "";
|
|
|
|
}
|
2022-12-25 20:40:05 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// ----- Etat du formulaire jury pour éviter sortie sans enregistrer
|
|
|
|
let FORM_STATE = "";
|
2023-01-08 19:36:05 +01:00
|
|
|
let IS_SUBMITTING = false;
|
|
|
|
|
2022-12-25 20:40:05 +01:00
|
|
|
// Une chaine décrivant l'état du form
|
|
|
|
function get_form_state() {
|
2023-11-17 13:53:17 +01:00
|
|
|
let codes = [];
|
|
|
|
// il n'y a que des <select>
|
|
|
|
document.querySelectorAll("select").forEach((sel) => codes.push(sel.value));
|
|
|
|
return codes.join();
|
2022-12-25 20:40:05 +01:00
|
|
|
}
|
|
|
|
|
2023-11-17 13:53:17 +01:00
|
|
|
$("document").ready(function () {
|
|
|
|
FORM_STATE = get_form_state();
|
|
|
|
document
|
|
|
|
.querySelector("form#jury_but")
|
|
|
|
.addEventListener("submit", jury_form_submit);
|
2022-12-25 20:40:05 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
function is_modified() {
|
2023-11-17 13:53:17 +01:00
|
|
|
return FORM_STATE != get_form_state();
|
2022-12-25 20:40:05 +01:00
|
|
|
}
|
2023-01-08 19:36:05 +01:00
|
|
|
|
|
|
|
function jury_form_submit(event) {
|
2023-11-17 13:53:17 +01:00
|
|
|
IS_SUBMITTING = true;
|
2023-01-08 19:36:05 +01:00
|
|
|
}
|
|
|
|
|
2022-12-25 20:40:05 +01:00
|
|
|
window.addEventListener("beforeunload", function (e) {
|
2023-11-17 13:53:17 +01:00
|
|
|
if (!IS_SUBMITTING && is_modified()) {
|
|
|
|
var confirmationMessage = "Changements non enregistrés !";
|
|
|
|
(e || window.event).returnValue = confirmationMessage;
|
|
|
|
return confirmationMessage;
|
|
|
|
}
|
2022-12-25 20:40:05 +01:00
|
|
|
});
|