diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py
index ce0899f5..c8fef8f0 100644
--- a/app/scodoc/sco_recapcomplet.py
+++ b/app/scodoc/sco_recapcomplet.py
@@ -277,9 +277,7 @@ def _formsemestre_recapcomplet_to_file(
include_evaluations=include_evaluations,
filename=filename,
)
- return scu.send_file(
- data, filename=filename, mime=scu.get_mime_suffix(tabformat)
- )
+ return scu.send_file(data, filename=filename, mime=scu.get_mime_suffix(format))
elif tabformat == "xml":
data = gen_formsemestre_recapcomplet_xml(
formsemestre.id,
@@ -464,9 +462,11 @@ def _gen_formsemestre_recapcomplet_table(
mode_jury=False,
filename: str = "",
selected_etudid=None,
-) -> str:
- """Génère le html"""
- table = res.get_table_recap(
+) -> TableRecap:
+ """Construit la table récap."""
+ table_class = TableJury if mode_jury else TableRecap
+ table = table_class(
+ res,
convert_values=True,
include_evaluations=include_evaluations,
mode_jury=mode_jury,
@@ -474,20 +474,7 @@ def _gen_formsemestre_recapcomplet_table(
)
table.data["filename"] = filename
table.select_row(selected_etudid)
- return f"""
-
- {
- '
aucun étudiant !
'
- if table.is_empty()
- else table.html(
- extra_classes=[
- 'table_recap',
- 'apc' if formsemestre.formation.is_apc() else 'classic',
- 'jury' if mode_jury else ''
- ])
- }
-
- """
+ return table
def gen_formsemestre_recapcomplet_excel(
diff --git a/app/static/js/table_recap.js b/app/static/js/table_recap.js
index 3cf02120..1021b31d 100644
--- a/app/static/js/table_recap.js
+++ b/app/static/js/table_recap.js
@@ -24,23 +24,49 @@ $(function () {
}
// 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]);
- 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);
- if (x) {
- try {
- order_info = JSON.parse(x);
- } catch (error) {
- console.error(error);
+ let hidden_colums = [
+ "etud_codes", "identite_detail",
+ "partition_aux", "partition_rangs", "admission",
+ "col_empty"
+ ];
+ // 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]);
+ 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);
+ if (x) {
+ try {
+ order_info = JSON.parse(x);
+ } catch (error) {
+ console.error(error);
+ }
+ }
+ }
+
+ // Les colonnes visibles sont mémorisées, il faut initialiser l'état des boutons
+ function update_buttons_labels(dt) {
+ // 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");
+ }
+ }
+ }
+ });
}
}
}
@@ -63,89 +89,79 @@ $(function () {
}
}
}
- });
- }
+ // Definition des boutons au dessus de la table:
+ let 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
+ },
+ {
+ // force affichage de toutes les colonnes
+ text: '✴',
+ action: function (e, dt, node, config) {
+ dt.columns().visible(true);
+ update_buttons_labels(dt);
+ }
+ },
+ {
+ text: '🔄',
+ action: function (e, dt, node, config) {
+ localStorage.clear();
+ console.log("cleared localStorage");
+ location.reload();
+ }
+ },
+ {
+ text: 'Civilité',
+ action: toggle_col_ident_visibility,
+ },
+ {
+ text: 'Groupes',
+ action: toggle_col_but_visibility,
+ },
+ {
+ text: 'Rg',
+ action: toggle_col_but_visibility,
+ },
+ ]; // fin des boutons communs à toutes les tables recap
- // 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:
- let 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,
- },
- {
- // force affichage de toutes les colonnes
- text: '✴',
- action: function (e, dt, node, config) {
- dt.columns().visible(true);
- update_buttons_labels(dt);
- },
- },
- {
- text: '🔄',
- action: function (e, dt, node, config) {
- localStorage.clear();
- console.log("cleared localStorage");
- location.reload();
- },
- },
- {
- text: 'Civilité',
- action: toggle_col_ident_visibility,
- },
- {
- text: 'Groupes',
- action: toggle_col_but_visibility,
- },
- {
- text: 'Rg',
- action: toggle_col_but_visibility,
- },
- ]; // fin des boutons communs à toutes les tables recap
-
- if ($("table.table_recap").hasClass("jury")) {
- // table jury: avec ou sans codes enregistrés
- buttons.push({
- text: 'Codes jury',
- action: toggle_col_but_visibility,
- });
- } else {
- // BOUTONS SPECIFIQUES A LA TABLE RECAP NON JURY
- buttons.push(
- $("table.table_recap").hasClass("apc")
- ? {
- text: 'Ressources',
- action: toggle_col_ressources_visibility,
+ if ($('table.table_recap').hasClass("jury")) {
+ // table jury: avec ou sans codes enregistrés
+ buttons.push(
+ {
+ text: 'Codes jury',
+ action: toggle_col_but_visibility,
+ });
+ } else {
+ // BOUTONS SPECIFIQUES A LA TABLE RECAP NON JURY
+ buttons.push(
+ $('table.table_recap').hasClass("apc") ?
+ {
+ text: 'Ressources',
+ action: toggle_col_ressources_visibility,
+ } : {
+ name: "toggle_mod",
+ text: "Cacher les modules",
+ action: function (e, dt, node, config) {
+ 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);
+ }
+ }
+ );
+ if ($('table.table_recap').hasClass("apc")) {
+ buttons.push({
+ text: 'SAÉs',
+ action: toggle_col_but_visibility,
+ });
}
: {
name: "toggle_mod",
@@ -161,36 +177,16 @@ $(function () {
toggle_col_group_visibility(dt, "col_malus", onoff);
},
}
- );
- if ($("table.table_recap").hasClass("apc")) {
- buttons.push({
- text: 'SAÉs',
- action: toggle_col_but_visibility,
- });
- }
- // S'il y a des colonnes vides:
- if ($("table.table_recap td.col_empty").length > 0) {
- buttons.push({
- // modules vides
- text: 'Vides',
- action: toggle_col_but_visibility,
- });
- }
- // Boutons admission (pas en jury)
- if (!$("table.table_recap").hasClass("jury")) {
- buttons.push({
- text: 'Admission',
- action: toggle_col_but_visibility,
- });
- }
- }
- // Boutons évaluations (si présentes)
- if ($("table.table_recap").hasClass("with_evaluations")) {
- buttons.push({
- text: 'Évaluations',
- action: toggle_col_but_visibility,
- });
- }
+ }
+ // Boutons évaluations (si présentes)
+ if ($('table.table_recap').hasClass("with_evaluations")) {
+ buttons.push(
+ {
+ text: 'Évaluations',
+ action: toggle_col_but_visibility,
+ }
+ );
+ }
// ------------- LA TABLE ---------
try {