From 13d4da3fea15cb13f5e05958e3bcb0cc91cda4a0 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 27 Mar 2022 18:49:15 +0200 Subject: [PATCH] Recap BUT: titre footer (lien, bulle) + highlight selected row --- app/comp/res_but.py | 27 ++++++++++++++++++++++++--- app/scodoc/sco_recapcomplet.py | 15 +++++++-------- app/static/css/scodoc.css | 17 ++++++++++++++++- app/static/js/table_recap.js | 9 +++++++++ 4 files changed, 56 insertions(+), 12 deletions(-) diff --git a/app/comp/res_but.py b/app/comp/res_but.py index ba4bec6152..a81f01b592 100644 --- a/app/comp/res_but.py +++ b/app/comp/res_but.py @@ -20,10 +20,11 @@ from app.models import ScoDocSiteConfig from app.models.etudiants import Identite from app.models.moduleimpls import ModuleImpl from app.models.ues import UniteEns -from app.scodoc import sco_groups -from app.scodoc import sco_preferences from app.scodoc import sco_codes_parcours from app.scodoc.sco_codes_parcours import UE_SPORT +from app.scodoc import sco_groups +from app.scodoc import sco_preferences +from app.scodoc import sco_users import app.scodoc.sco_utils as scu @@ -210,6 +211,8 @@ class ResultatsSemestreBUT(NotesTableCompat): NO_NOTE = "-" # contenu des cellules sans notes rows = [] titles = {"rang": "Rg"} # column_id : title + # les titres en footer: les mêmes, mais avec des bulles et liens: + titles_bot = {} def add_cell( row: dict, col_id: str, title: str, content: str, classes: str = "" @@ -243,7 +246,7 @@ class ResultatsSemestreBUT(NotesTableCompat): formsemestre_id=self.formsemestre.id, etudid=etudid, ) - row[f"_nom_short_target_attrs"] = f'class="etudinfo" id="{etudid}"' + row["_nom_short_target_attrs"] = f'class="etudinfo" id="{etudid}"' row["_nom_disp_target"] = row["_nom_short_target"] row["_nom_disp_target_attrs"] = row["_nom_short_target_attrs"] self._recap_etud_groups_infos(etudid, row, titles) @@ -261,6 +264,9 @@ class ResultatsSemestreBUT(NotesTableCompat): fmt_note(moy_gen), "col_moy_gen" + note_class, ) + titles_bot["_moy_gen_target_attrs"] = ( + 'title="moyenne indicative"' if self.is_apc else "" + ) # --- Moyenne d'UE for ue in [ue for ue in ues if ue.type != UE_SPORT]: ue_status = self.get_etud_ue_status(etudid, ue.id) @@ -280,6 +286,9 @@ class ResultatsSemestreBUT(NotesTableCompat): fmt_note(val), "col_ue" + note_class, ) + titles_bot[ + f"_{col_id}_target_attrs" + ] = f"""title="{ue.titre} S{ue.semestre_idx or '?'}" """ # Les moyennes des ressources et SAÉs dans cette UE for modimpl in self.modimpls_in_ue(ue.id, etudid, with_bonus=False): if ue_status["is_capitalized"]: @@ -309,6 +318,16 @@ class ResultatsSemestreBUT(NotesTableCompat): # class col_res mod_ue_123 f"col_{modimpl.module.type_abbrv()} mod_ue_{ue.id}", ) + titles_bot[f"_{col_id}_target"] = url_for( + "notes.moduleimpl_status", + scodoc_dept=g.scodoc_dept, + moduleimpl_id=modimpl.id, + ) + titles_bot[ + f"_{col_id}_target_attrs" + ] = f""" + title="{modimpl.module.titre} + ({sco_users.user_info(modimpl.responsable_id)['nomcomplet']})" """ modimpl_ids.add(modimpl.id) rows.append(row) @@ -332,6 +351,8 @@ class ResultatsSemestreBUT(NotesTableCompat): row["prenom"] = row["nom_short"] = bottom_line.capitalize() row["_tr_class"] = bottom_line.lower() footer_rows.append(row) + titles_bot.update(titles) + footer_rows.append(titles_bot) return ( rows, footer_rows, diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index 7f939b3675..31b8629753 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -1025,10 +1025,9 @@ def _gen_cell(key: str, row: dict, elt="td"): attrs += f' data-order="{order}"' content = row.get(key, "") target = row.get(f"_{key}_target") - if content and target: # avec lien - content = ( - f'{content}' - ) + if content or target: # avec lien + href = f'href="{target}"' if target else "" + content = f'{content}' return f"<{elt} {attrs}>{content}" @@ -1062,11 +1061,11 @@ def make_formsemestre_recapcomplet_apc(formsemestre: FormSemestre, format="html" H.append("\n") # footer H.append("") - for row in footer_rows: - H.append(f"{_gen_row(column_ids, row)}\n") + idx_last = len(footer_rows) - 1 + for i, row in enumerate(footer_rows): + H.append(f'{_gen_row(column_ids, row, "th" if i == idx_last else "td")}\n') H.append( - f""" - {_gen_row(column_ids, titles, "th")} + """ diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index 8884e9a51a..54408f977a 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -3240,9 +3240,24 @@ table.dataTable td.etudinfo, table.dataTable td.group { text-align: left; } /* Nouveau tableau recap */ +div.table_recap { + margin-right: 6px; +} div.table_recap table.table_recap { width: auto; } +table.table_recap tr.selected td { + border-bottom: 1px solid rgb(248, 0, 33); + border-top: 1px solid rgb(248, 0, 33); + background-color: rgb(253, 255, 155); +} +table.table_recap tr.selected td:first-child { + border-left: 1px solid rgb(248, 0, 33); +} +table.table_recap tr.selected td:last-child { + border-right: 1px solid rgb(248, 0, 33); +} + table.table_recap .identite_court { white-space:nowrap; text-align: left; @@ -3258,7 +3273,7 @@ table.table_recap .group { border-left: 1px dashed rgb(160, 160, 160); } -table.table_recap a:hover { +table.table_recap tbody tr td a:hover { color: red; text-decoration: underline; } diff --git a/app/static/js/table_recap.js b/app/static/js/table_recap.js index 8f81999ce1..31344b7324 100644 --- a/app/static/js/table_recap.js +++ b/app/static/js/table_recap.js @@ -64,4 +64,13 @@ $(function () { ); }); + $('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'); + } + }); });