Table recap: efface données client cachées si erreur.
This commit is contained in:
parent
cb21043f31
commit
a42a3708fb
@ -14,6 +14,8 @@ $(function () {
|
|||||||
const url = new URL(document.URL);
|
const url = new URL(document.URL);
|
||||||
const formsemestre_id = url.searchParams.get("formsemestre_id");
|
const formsemestre_id = url.searchParams.get("formsemestre_id");
|
||||||
const order_info_key = JSON.stringify([url.pathname, formsemestre_id]);
|
const order_info_key = JSON.stringify([url.pathname, formsemestre_id]);
|
||||||
|
const etudids_key = JSON.stringify(["etudids", url.origin, formsemestre_id]);
|
||||||
|
const noms_key = JSON.stringify(["noms", url.origin, formsemestre_id]);
|
||||||
let order_info;
|
let order_info;
|
||||||
if (formsemestre_id) {
|
if (formsemestre_id) {
|
||||||
const x = localStorage.getItem(order_info_key);
|
const x = localStorage.getItem(order_info_key);
|
||||||
@ -157,83 +159,89 @@ $(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let table = $('table.table_recap').DataTable(
|
try {
|
||||||
{
|
let table = $('table.table_recap').DataTable(
|
||||||
paging: false,
|
{
|
||||||
searching: true,
|
paging: false,
|
||||||
info: false,
|
searching: true,
|
||||||
autoWidth: false,
|
info: false,
|
||||||
fixedHeader: {
|
autoWidth: false,
|
||||||
header: true,
|
fixedHeader: {
|
||||||
footer: false
|
header: true,
|
||||||
},
|
footer: false
|
||||||
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,
|
|
||||||
},
|
},
|
||||||
{
|
orderCellsTop: true, // cellules ligne 1 pour tri
|
||||||
// Elimine les 0 à gauche pour les exports excel et les "copy"
|
aaSorting: [], // Prevent initial sorting
|
||||||
targets: ["col_mod", "col_moy_gen", "col_ue", "col_res", "col_sae", "evaluation", "col_rcue"],
|
colReorder: true,
|
||||||
render: function (data, type, row) {
|
stateSave: true, // enregistre état de la table (tris, ...)
|
||||||
return type === 'export' ? data.replace(/0(\d\..*)/, '$1') : data;
|
"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"
|
||||||
|
targets: ["col_mod", "col_moy_gen", "col_ue", "col_res", "col_sae", "evaluation", "col_rcue"],
|
||||||
|
render: function (data, type, row) {
|
||||||
|
return type === 'export' ? data.replace(/0(\d\..*)/, '$1') : data;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Elimine les décorations (fleches bonus/malus) pour les exports
|
||||||
|
targets: ["col_ue_bonus", "col_malus"],
|
||||||
|
render: function (data, type, row) {
|
||||||
|
return type === 'export' ? data.replace(/.*(\d\d\.\d\d)/, '$1').replace(/0(\d\..*)/, '$1') : data;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dom: 'Bfrtip',
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
extend: 'collection',
|
||||||
|
text: 'Colonnes affichées',
|
||||||
|
autoClose: true,
|
||||||
|
buttons: buttons,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"drawCallback": function (settings) {
|
||||||
|
// permet de conserver l'ordre de tri des colonnes
|
||||||
|
let order_info = JSON.stringify($('table.table_recap').DataTable().order());
|
||||||
|
if (formsemestre_id) {
|
||||||
|
localStorage.setItem(order_info_key, order_info);
|
||||||
}
|
}
|
||||||
|
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));
|
||||||
},
|
},
|
||||||
{
|
"order": order_info,
|
||||||
// Elimine les décorations (fleches bonus/malus) pour les exports
|
}
|
||||||
targets: ["col_ue_bonus", "col_malus"],
|
);
|
||||||
render: function (data, type, row) {
|
} catch (error) {
|
||||||
return type === 'export' ? data.replace(/.*(\d\d\.\d\d)/, '$1').replace(/0(\d\..*)/, '$1') : data;
|
// l'erreur peut etre causee par un ancien storage:
|
||||||
}
|
localStorage.removeItem(etudids_key);
|
||||||
},
|
localStorage.removeItem(noms_key);
|
||||||
],
|
localStorage.removeItem(order_info_key);
|
||||||
dom: 'Bfrtip',
|
location.reload();
|
||||||
buttons: [
|
}
|
||||||
{
|
|
||||||
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
|
|
||||||
},
|
|
||||||
{
|
|
||||||
extend: 'collection',
|
|
||||||
text: 'Colonnes affichées',
|
|
||||||
autoClose: true,
|
|
||||||
buttons: buttons,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"drawCallback": function (settings) {
|
|
||||||
// permet de conserver l'ordre de tri des colonnes
|
|
||||||
let order_info = JSON.stringify($('table.table_recap').DataTable().order());
|
|
||||||
if (formsemestre_id) {
|
|
||||||
localStorage.setItem(order_info_key, order_info);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
const etudids_key = JSON.stringify(["etudids", url.origin, formsemestre_id]);
|
|
||||||
localStorage.setItem(etudids_key, JSON.stringify(etudids));
|
|
||||||
const noms_key = JSON.stringify(["noms", url.origin, formsemestre_id]);
|
|
||||||
localStorage.setItem(noms_key, JSON.stringify(noms));
|
|
||||||
},
|
|
||||||
"order": order_info,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
update_buttons_labels(table);
|
update_buttons_labels(table);
|
||||||
});
|
});
|
||||||
$('table.table_recap tbody').on('click', 'tr', function () {
|
$('table.table_recap tbody').on('click', 'tr', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user