2022-03-26 23:33:57 +01:00
|
|
|
// Tableau recap notes
|
|
|
|
$(function () {
|
|
|
|
$(function () {
|
2023-02-06 13:05:39 +01:00
|
|
|
if ($('table.table_recap').length == 0) { return; }
|
|
|
|
|
2023-02-02 18:27:15 +01:00
|
|
|
let hidden_colums = [
|
|
|
|
"etud_codes", "identite_detail",
|
|
|
|
"partition_aux", "partition_rangs", "admission",
|
|
|
|
"col_empty"
|
|
|
|
];
|
2022-06-25 16:23:39 +02:00
|
|
|
// Etat (tri des colonnes) de la table:
|
|
|
|
|
|
|
|
const url = new URL(document.URL);
|
|
|
|
const formsemestre_id = url.searchParams.get("formsemestre_id");
|
|
|
|
const order_info_key = JSON.stringify([url.pathname, formsemestre_id]);
|
2023-01-30 22:38:34 +01:00
|
|
|
const etudids_key = JSON.stringify(["etudids", url.origin, formsemestre_id]);
|
|
|
|
const noms_key = JSON.stringify(["noms", url.origin, formsemestre_id]);
|
2022-06-25 16:23:39 +02:00
|
|
|
let order_info;
|
|
|
|
if (formsemestre_id) {
|
|
|
|
const x = localStorage.getItem(order_info_key);
|
|
|
|
if (x) {
|
|
|
|
try {
|
|
|
|
order_info = JSON.parse(x);
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-01-14 17:43:57 +01:00
|
|
|
|
2023-02-09 15:27:19 +01:00
|
|
|
// Les colonnes visibles sont mémorisées, il faut initialiser l'état des boutons
|
2023-01-14 17:43:57 +01:00
|
|
|
function update_buttons_labels(dt) {
|
2023-02-09 15:27:19 +01:00
|
|
|
// chaque bouton controle une classe stockée dans le data-group du span
|
|
|
|
document.querySelectorAll("button.dt-button").forEach(but => {
|
|
|
|
let g_span = but.querySelector("span > span");
|
|
|
|
if (g_span) {
|
|
|
|
let group = g_span.dataset["group"];
|
|
|
|
if (group) {
|
|
|
|
// si le group (= la 1ere col.) est visible, but_on
|
|
|
|
if (dt.columns("." + group).visible()[0]) {
|
|
|
|
but.classList.add("but_on");
|
|
|
|
but.classList.remove("but_off");
|
|
|
|
} else {
|
|
|
|
but.classList.add("but_off");
|
|
|
|
but.classList.remove("but_on");
|
|
|
|
}
|
|
|
|
}
|
2023-01-14 17:43:57 +01:00
|
|
|
}
|
2023-02-09 15:27:19 +01:00
|
|
|
});
|
2023-01-14 17:43:57 +01:00
|
|
|
}
|
|
|
|
|
2023-02-09 15:27:19 +01:00
|
|
|
// Changement visibilité groupes colonnes (boutons)
|
|
|
|
function toggle_col_but_visibility(e, dt, node, config) {
|
|
|
|
let group = node.children()[0].firstChild.dataset.group;
|
|
|
|
toggle_col_group_visibility(dt, group, node.hasClass("but_on"));
|
|
|
|
}
|
|
|
|
function toggle_col_ident_visibility(e, dt, node, config) {
|
|
|
|
let onoff = node.hasClass("but_on");
|
|
|
|
toggle_col_group_visibility(dt, "identite_detail", onoff);
|
|
|
|
toggle_col_group_visibility(dt, "identite_court", !onoff);
|
|
|
|
}
|
|
|
|
function toggle_col_ressources_visibility(e, dt, node, config) {
|
|
|
|
let onoff = node.hasClass("but_on");
|
|
|
|
toggle_col_group_visibility(dt, "col_res", onoff);
|
|
|
|
toggle_col_group_visibility(dt, "col_ue_bonus", onoff);
|
|
|
|
toggle_col_group_visibility(dt, "col_malus", onoff);
|
|
|
|
}
|
|
|
|
function toggle_col_group_visibility(dt, group, onoff) {
|
|
|
|
if (onoff) {
|
|
|
|
dt.columns('.' + group).visible(false);
|
|
|
|
} else {
|
|
|
|
dt.columns('.' + group).visible(true);
|
|
|
|
}
|
|
|
|
update_buttons_labels(dt);
|
|
|
|
}
|
|
|
|
// Definition des boutons au dessus de la table:
|
2022-03-28 18:13:51 +02:00
|
|
|
let buttons = [
|
|
|
|
{
|
2023-02-09 15:27:19 +01:00
|
|
|
extend: 'copyHtml5',
|
|
|
|
text: 'Copier',
|
|
|
|
exportOptions: { orthogonal: 'export' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
extend: 'excelHtml5',
|
|
|
|
// footer: true, // ne fonctionne pas ?
|
|
|
|
exportOptions: { orthogonal: 'export' },
|
|
|
|
title: document.querySelector('table.table_recap').dataset.filename
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// force affichage de toutes les colonnes
|
|
|
|
text: '<a title="Afficher toutes les colonnes">✴</a>',
|
2022-03-28 18:13:51 +02:00
|
|
|
action: function (e, dt, node, config) {
|
2023-02-09 15:27:19 +01:00
|
|
|
dt.columns().visible(true);
|
2023-01-14 17:43:57 +01:00
|
|
|
update_buttons_labels(dt);
|
2022-03-28 18:13:51 +02:00
|
|
|
}
|
|
|
|
},
|
2022-03-29 00:03:38 +02:00
|
|
|
{
|
2023-02-12 01:13:43 +01:00
|
|
|
text: '<a title="Rétablir l\'affichage par défaut" class="clearreload">🔄</a>',
|
2022-03-29 00:03:38 +02:00
|
|
|
action: function (e, dt, node, config) {
|
2023-02-09 15:27:19 +01:00
|
|
|
localStorage.clear();
|
|
|
|
console.log("cleared localStorage");
|
|
|
|
location.reload();
|
2022-03-29 00:03:38 +02:00
|
|
|
}
|
2022-05-23 10:59:43 +02:00
|
|
|
},
|
2023-02-09 15:27:19 +01:00
|
|
|
{
|
|
|
|
text: '<span data-group="identite_detail">Civilité</span>',
|
|
|
|
action: toggle_col_ident_visibility,
|
|
|
|
},
|
|
|
|
{
|
2023-02-13 22:00:56 +01:00
|
|
|
text: '<span data-group="partition_aux"><a title="Affichage des groupes secondaires (la première partition est toujours affichée)">Groupes</a></span>',
|
2023-02-09 15:27:19 +01:00
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
},
|
|
|
|
{
|
2023-02-13 22:00:56 +01:00
|
|
|
text: '<span data-group="partition_rangs"><a title="Rangs dans les groupes (si activés dans les partitions concernées)">Rg</a></span>',
|
2023-02-09 15:27:19 +01:00
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
},
|
|
|
|
]; // fin des boutons communs à toutes les tables recap
|
|
|
|
|
|
|
|
if ($('table.table_recap').hasClass("jury")) {
|
2023-02-19 19:26:57 +01:00
|
|
|
// Table JURY:
|
|
|
|
// avec ou sans codes enregistrés
|
2022-06-24 12:00:08 +02:00
|
|
|
buttons.push(
|
|
|
|
{
|
2023-02-12 01:13:43 +01:00
|
|
|
text: '<span data-group="recorded_code">Codes jury</span>',
|
2023-02-09 15:27:19 +01:00
|
|
|
action: toggle_col_but_visibility,
|
2022-06-24 12:00:08 +02:00
|
|
|
});
|
2023-02-19 19:26:57 +01:00
|
|
|
if ($('table.table_recap').hasClass("apc")) {
|
|
|
|
// Boutons spécifiques à la table JURY BUT
|
|
|
|
buttons.push(
|
|
|
|
{
|
|
|
|
text: '<span data-group="cursus_but">Compétences</span>',
|
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
});
|
|
|
|
buttons.push(
|
|
|
|
{
|
|
|
|
text: '<span data-group="col_rcue">RCUEs</span>',
|
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
});
|
|
|
|
}
|
2022-06-24 16:57:44 +02:00
|
|
|
} else {
|
2023-02-09 15:27:19 +01:00
|
|
|
// BOUTONS SPECIFIQUES A LA TABLE RECAP NON JURY
|
2022-04-07 23:31:08 +02:00
|
|
|
buttons.push(
|
|
|
|
$('table.table_recap').hasClass("apc") ?
|
|
|
|
{
|
2023-02-09 15:27:19 +01:00
|
|
|
text: '<span data-group="col_res">Ressources</span>',
|
|
|
|
action: toggle_col_ressources_visibility,
|
2022-04-07 23:31:08 +02:00
|
|
|
} : {
|
|
|
|
name: "toggle_mod",
|
|
|
|
text: "Cacher les modules",
|
|
|
|
action: function (e, dt, node, config) {
|
2023-02-09 15:27:19 +01:00
|
|
|
let onoff = node.hasClass("but_on");
|
|
|
|
toggle_col_group_visibility(dt, "col_mod:not(.col_empty)", onoff);
|
|
|
|
toggle_col_group_visibility(dt, "col_ue_bonus", onoff);
|
|
|
|
toggle_col_group_visibility(dt, "col_malus", onoff);
|
2022-04-07 23:31:08 +02:00
|
|
|
}
|
2022-03-28 18:13:51 +02:00
|
|
|
}
|
2022-04-07 23:31:08 +02:00
|
|
|
);
|
|
|
|
if ($('table.table_recap').hasClass("apc")) {
|
|
|
|
buttons.push({
|
2023-02-09 15:27:19 +01:00
|
|
|
text: '<span data-group="col_sae">SAÉs</span>',
|
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
});
|
2022-04-07 23:31:08 +02:00
|
|
|
}
|
2023-02-12 14:09:37 +01:00
|
|
|
// S'il y a des colonnes vides:
|
|
|
|
if ($('table.table_recap td.col_empty').length > 0) {
|
|
|
|
buttons.push({ // modules vides
|
|
|
|
text: '<span data-group="col_empty">Vides</span>',
|
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
});
|
|
|
|
}
|
2023-02-09 15:27:19 +01:00
|
|
|
// Boutons admission (pas en jury)
|
|
|
|
if (!$('table.table_recap').hasClass("jury")) {
|
|
|
|
buttons.push(
|
|
|
|
{
|
|
|
|
text: '<span data-group="admission">Admission</span>',
|
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
}
|
|
|
|
);
|
2023-02-02 18:27:15 +01:00
|
|
|
}
|
2023-02-09 15:27:19 +01:00
|
|
|
}
|
2023-02-12 01:13:43 +01:00
|
|
|
// Boutons évaluations (si présentes)
|
|
|
|
if ($('table.table_recap').hasClass("with_evaluations")) {
|
|
|
|
buttons.push(
|
|
|
|
{
|
|
|
|
text: '<span data-group="eval">Évaluations</span>',
|
|
|
|
action: toggle_col_but_visibility,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-02-09 15:27:19 +01:00
|
|
|
|
|
|
|
// ------------- LA TABLE ---------
|
2023-01-30 22:38:34 +01:00
|
|
|
try {
|
|
|
|
let table = $('table.table_recap').DataTable(
|
|
|
|
{
|
|
|
|
paging: false,
|
|
|
|
searching: true,
|
|
|
|
info: false,
|
|
|
|
autoWidth: false,
|
|
|
|
fixedHeader: {
|
|
|
|
header: true,
|
|
|
|
footer: false
|
2022-04-04 09:35:52 +02:00
|
|
|
},
|
2023-01-30 22:38:34 +01:00
|
|
|
orderCellsTop: true, // cellules ligne 1 pour tri
|
|
|
|
aaSorting: [], // Prevent initial sorting
|
|
|
|
colReorder: true,
|
|
|
|
stateSave: true, // enregistre état de la table (tris, ...)
|
|
|
|
"columnDefs": [
|
|
|
|
{
|
|
|
|
// cache les codes, le détail de l'identité, les groupes, les colonnes admission et les vides
|
|
|
|
targets: hidden_colums,
|
|
|
|
visible: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Elimine les 0 à gauche pour les exports excel et les "copy"
|
2023-02-02 18:27:15 +01:00
|
|
|
targets: ["col_mod", "col_moy_gen", "col_moy_ue", "col_res", "col_sae", "evaluation", "col_rcue"],
|
2023-01-30 22:38:34 +01:00
|
|
|
render: function (data, type, row) {
|
|
|
|
return type === 'export' ? data.replace(/0(\d\..*)/, '$1') : data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-02-02 19:22:29 +01:00
|
|
|
// Elimine les "+"" pour les exports
|
2023-01-30 22:38:34 +01:00
|
|
|
targets: ["col_ue_bonus", "col_malus"],
|
|
|
|
render: function (data, type, row) {
|
2023-02-02 19:22:29 +01:00
|
|
|
return type === 'export' ? data.replace(/.*\+(\d?\d?\.\d\d).*/m, '$1').replace(/0(\d\..*)/, '$1') : data;
|
2023-01-30 22:38:34 +01:00
|
|
|
}
|
|
|
|
},
|
2023-02-02 18:27:15 +01:00
|
|
|
{
|
|
|
|
// Elimine emoji warning sur UEs
|
|
|
|
targets: ["col_ues_validables"],
|
|
|
|
render: function (data, type, row) {
|
|
|
|
return type === 'export' ? data.replace(/(\d+\/\d+).*/, '$1') : data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-30 22:38:34 +01:00
|
|
|
],
|
|
|
|
dom: 'Bfrtip',
|
2023-02-09 15:27:19 +01:00
|
|
|
buttons: buttons,
|
2023-01-30 22:38:34 +01:00
|
|
|
"drawCallback": function (settings) {
|
|
|
|
// permet de conserver l'ordre de tri des colonnes
|
2023-02-12 04:20:08 +01:00
|
|
|
let table = $('table.table_recap').DataTable();
|
|
|
|
let order_info = JSON.stringify(table.order());
|
2023-01-30 22:38:34 +01:00
|
|
|
if (formsemestre_id) {
|
|
|
|
localStorage.setItem(order_info_key, order_info);
|
2022-04-04 09:35:52 +02:00
|
|
|
}
|
2023-01-30 22:38:34 +01:00
|
|
|
let etudids = [];
|
|
|
|
document.querySelectorAll("td.identite_court").forEach(e => {
|
|
|
|
etudids.push(e.dataset.etudid);
|
|
|
|
});
|
|
|
|
let noms = [];
|
|
|
|
document.querySelectorAll("td.identite_court").forEach(e => {
|
|
|
|
noms.push(e.dataset.nomprenom);
|
|
|
|
});
|
|
|
|
localStorage.setItem(etudids_key, JSON.stringify(etudids));
|
|
|
|
localStorage.setItem(noms_key, JSON.stringify(noms));
|
2022-03-26 23:33:57 +01:00
|
|
|
},
|
2023-01-30 22:38:34 +01:00
|
|
|
"order": order_info,
|
|
|
|
}
|
|
|
|
);
|
2023-02-02 18:27:15 +01:00
|
|
|
update_buttons_labels(table);
|
2023-01-30 22:38:34 +01:00
|
|
|
} catch (error) {
|
|
|
|
// l'erreur peut etre causee par un ancien storage:
|
|
|
|
localStorage.removeItem(etudids_key);
|
|
|
|
localStorage.removeItem(noms_key);
|
|
|
|
localStorage.removeItem(order_info_key);
|
|
|
|
location.reload();
|
|
|
|
}
|
2022-03-26 23:33:57 +01:00
|
|
|
});
|
2022-03-27 18:49:15 +02:00
|
|
|
$('table.table_recap tbody').on('click', 'tr', function () {
|
|
|
|
if ($(this).hasClass('selected')) {
|
|
|
|
$(this).removeClass('selected');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('table.table_recap tr.selected').removeClass('selected');
|
|
|
|
$(this).addClass('selected');
|
|
|
|
}
|
|
|
|
});
|
2022-06-25 12:32:00 +02:00
|
|
|
// Pour montrer et surligner l'étudiant sélectionné:
|
2022-04-07 23:31:08 +02:00
|
|
|
$(function () {
|
2023-01-29 21:52:39 +01:00
|
|
|
let row_selected = document.querySelector(".row_selected");
|
2022-06-25 12:32:00 +02:00
|
|
|
if (row_selected) {
|
2023-02-12 04:20:08 +01:00
|
|
|
row_selected.scrollIntoView();
|
|
|
|
window.scrollBy(0, -125);
|
2022-06-25 12:32:00 +02:00
|
|
|
row_selected.classList.add("selected");
|
|
|
|
}
|
2022-04-07 23:31:08 +02:00
|
|
|
});
|
2022-03-26 23:33:57 +01:00
|
|
|
});
|