forked from ScoDoc/ScoDoc
121 lines
5.2 KiB
JavaScript
121 lines
5.2 KiB
JavaScript
// Tableau recap notes
|
|
$(function () {
|
|
$(function () {
|
|
// Les boutons dépendent du mode BUT ou classique:
|
|
let buttons = [
|
|
{
|
|
name: "toggle_ident",
|
|
text: "Civ/Nom/Prénom",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".identite_detail").visible()[0];
|
|
dt.columns(".identite_detail").visible(!visible);
|
|
dt.columns(".identite_court").visible(visible);
|
|
dt.buttons('toggle_ident:name').text(visible ? "Civ/Nom/Prénom" : "Nom");
|
|
}
|
|
},
|
|
{
|
|
name: "toggle_partitions",
|
|
text: "Toutes les partitions",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".partition_aux").visible()[0];
|
|
dt.columns(".partition_aux").visible(!visible);
|
|
dt.buttons('toggle_partitions:name').text(visible ? "Toutes les partitions" : "Cacher les partitions");
|
|
}
|
|
},
|
|
$('table.table_recap').hasClass("apc") ?
|
|
{
|
|
name: "toggle_res",
|
|
text: "Cacher les ressources",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".col_res").visible()[0];
|
|
dt.columns(".col_res").visible(!visible);
|
|
dt.columns(".col_ue_bonus").visible(!visible);
|
|
dt.buttons('toggle_res:name').text(visible ? "Montrer les ressources" : "Cacher les ressources");
|
|
}
|
|
} : {
|
|
name: "toggle_mod",
|
|
text: "Cacher les modules",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".col_mod:not(.col_empty)").visible()[0];
|
|
dt.columns(".col_mod:not(.col_empty)").visible(!visible);
|
|
dt.columns(".col_ue_bonus").visible(!visible);
|
|
dt.buttons('toggle_mod:name').text(visible ? "Montrer les modules" : "Cacher les modules");
|
|
visible = dt.columns(".col_empty").visible()[0];
|
|
dt.buttons('toggle_col_empty:name').text(visible ? "Cacher mod. vides" : "Montrer mod. vides");
|
|
}
|
|
}
|
|
];
|
|
if ($('table.table_recap').hasClass("apc")) {
|
|
buttons.push({
|
|
name: "toggle_sae",
|
|
text: "Cacher les SAÉs",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".col_sae").visible()[0];
|
|
dt.columns(".col_sae").visible(!visible);
|
|
dt.buttons('toggle_sae:name').text(visible ? "Montrer les SAÉs" : "Cacher les SAÉs");
|
|
}
|
|
})
|
|
|
|
}
|
|
buttons.push({
|
|
name: "toggle_admission",
|
|
text: "Montrer infos admission",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".admission").visible()[0];
|
|
dt.columns(".admission").visible(!visible);
|
|
dt.buttons('toggle_admission:name').text(visible ? "Montrer infos admission" : "Cacher infos admission");
|
|
}
|
|
})
|
|
buttons.push({
|
|
name: "toggle_col_empty",
|
|
text: "Montrer mod. vides",
|
|
action: function (e, dt, node, config) {
|
|
let visible = dt.columns(".col_empty").visible()[0];
|
|
dt.columns(".col_empty").visible(!visible);
|
|
dt.buttons('toggle_col_empty:name').text(visible ? "Montrer mod. vides" : "Cacher mod. vides");
|
|
}
|
|
})
|
|
$('table.table_recap').DataTable(
|
|
{
|
|
paging: false,
|
|
searching: true,
|
|
info: false,
|
|
autoWidth: false,
|
|
fixedHeader: {
|
|
header: true,
|
|
footer: false
|
|
},
|
|
orderCellsTop: true, // cellules ligne 1 pour tri
|
|
aaSorting: [], // Prevent initial sorting
|
|
colReorder: true,
|
|
"columnDefs": [
|
|
{
|
|
// cache le détail de l'identité, les groupes, les colonnes admission et les vides
|
|
"targets": ["identite_detail", "partition_aux", "admission", "col_empty"],
|
|
"visible": false,
|
|
},
|
|
],
|
|
dom: 'Bfrtip',
|
|
buttons: ['copy', 'excel', 'pdf',
|
|
{
|
|
extend: 'collection',
|
|
text: 'Colonnes affichées',
|
|
autoClose: true,
|
|
buttons: buttons,
|
|
},
|
|
]
|
|
}
|
|
);
|
|
|
|
});
|
|
$('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');
|
|
}
|
|
});
|
|
});
|