ScoDoc-Lille/app/static/js/groups_view.js

133 lines
3.4 KiB
JavaScript
Raw Normal View History

2020-09-26 16:19:37 +02:00
// Affichage progressif du trombinoscope html
$().ready(function () {
var spans = $(".unloaded_img");
for (var i = 0; i < spans.length; i++) {
var sp = spans[i];
var etudid = sp.id;
$(sp).load(SCO_URL + "etud_photo_html?etudid=" + etudid);
}
2020-09-26 16:19:37 +02:00
});
// L'URL pour recharger l'état courant de la page (groupes et tab selectionnes)
// (ne fonctionne que pour les requetes GET: manipule la query string)
function groups_view_url() {
2024-07-31 13:43:39 +02:00
let url = new URL(location.href);
let urlParams = url.searchParams;
// ajout du formsemestre
urlParams.set(
"formsemestre_id",
$("#group_selector")[0].formsemestre_id.value
);
urlParams.delete("group_ids");
// ajout des groupes selectionnes
var selected_groups = document.getElementById("group_ids_sel").value;
url.search = urlParams.toString() + selected_groups;
return url.href;
2023-11-16 23:34:47 +01:00
}
// Recharge la page sans arguments group_ids
function remove_group_filter() {
2024-07-31 13:43:39 +02:00
var url = new URL(location.href);
url.searchParams.delete("group_ids");
2020-09-26 16:19:37 +02:00
2024-07-31 13:43:39 +02:00
window.location = url.href;
2020-09-26 16:19:37 +02:00
}
// Recharge la page en changeant les groupes selectionnés et en conservant le tab actif:
function submit_group_selector() {
2024-07-31 13:43:39 +02:00
window.location = groups_view_url();
2020-09-26 16:19:37 +02:00
}
2024-07-31 13:43:39 +02:00
function change_list_options(selected_options) {
var url = new URL(groups_view_url());
var urlParams = url.searchParams;
var options = [
"with_paiement",
"with_archives",
"with_annotations",
"with_codes",
"with_bourse",
];
for (var i = 0; i < options.length; i++) {
var option = options[i];
if ($.inArray(option, selected_options) >= 0) {
2024-07-31 13:43:39 +02:00
urlParams.set(option, "1");
2020-09-26 16:19:37 +02:00
}
}
2024-07-31 13:43:39 +02:00
window.location = url.href;
2020-09-26 16:19:37 +02:00
}
// Menu choix groupe:
function toggle_visible_etuds() {
//
$(".etud_elem").hide();
var qargs = "";
$("#group_ids_sel option:selected").each(function (index, opt) {
var group_id = opt.value;
$(".group-" + group_id).show();
qargs += "&group_ids=" + group_id;
});
// Update url saisie tableur:
var input_eval = $("#formnotes_evaluation_id");
if (input_eval.length > 0) {
var evaluation_id = input_eval[0].value;
$("#menu_saisie_tableur a").attr(
"href",
"saisie_notes_tableur?evaluation_id=" + evaluation_id + qargs
);
// lien feuille excel:
$("#lnk_feuille_saisie").attr(
"href",
"feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs
);
}
// Update champs form group_ids_str
let group_ids_str = Array.from(
document.querySelectorAll("#group_ids_sel option:checked")
)
.map(function (elem) {
return elem.value;
})
.join();
document
.querySelectorAll("input.group_ids_str")
.forEach((elem) => (elem.value = group_ids_str));
2020-09-26 16:19:37 +02:00
}
// Trombinoscope
$().ready(function () {
var elems = $(".trombi-photo");
for (var i = 0; i < elems.length; i++) {
$(elems[i]).qtip({
content: {
ajax: {
url:
SCO_URL +
"etud_info_html?with_photo=0&etudid=" +
get_etudid_from_elem(elems[i]),
},
text: "Loading...",
},
position: {
at: "right",
my: "left top",
},
style: {
classes: "qtip-etud",
},
// utile pour debugguer le css:
// hide: { event: 'unfocus' }
});
}
2020-09-26 16:19:37 +02:00
});
2024-07-31 13:43:39 +02:00
// gestion du tab actif
$().ready(function () {
let tab = new URL(location.href).searchParams.get("tab");
if (tab) {
document.getElementById(tab)?.click();
}
});