Table recap: efface données client cachées si erreur.

This commit is contained in:
Emmanuel Viennet 2023-01-30 18:38:34 -03:00 committed by iziram
parent 728010bf69
commit 3998b5a366

View File

@ -14,6 +14,8 @@ $(function () {
const url = new URL(document.URL);
const formsemestre_id = url.searchParams.get("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;
if (formsemestre_id) {
const x = localStorage.getItem(order_info_key);
@ -157,6 +159,7 @@ $(function () {
}
});
}
try {
let table = $('table.table_recap').DataTable(
{
paging: false,
@ -226,14 +229,19 @@ $(function () {
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,
}
);
} 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();
}
update_buttons_labels(table);
});
$('table.table_recap tbody').on('click', 'tr', function () {