1
0
forked from ScoDoc/ScoDoc

Recap BUT: titre footer (lien, bulle) + highlight selected row

This commit is contained in:
Emmanuel Viennet 2022-03-27 18:49:15 +02:00
parent 2a429a82f0
commit 13d4da3fea
4 changed files with 56 additions and 12 deletions

View File

@ -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,

View File

@ -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'<a href="{target}" {row.get(f"_{key}_target_attrs", "")}>{content}</a>'
)
if content or target: # avec lien
href = f'href="{target}"' if target else ""
content = f'<a {href} {row.get(f"_{key}_target_attrs", "")}>{content}</a>'
return f"<{elt} {attrs}>{content}</{elt}>"
@ -1062,11 +1061,11 @@ def make_formsemestre_recapcomplet_apc(formsemestre: FormSemestre, format="html"
H.append("</tbody>\n")
# footer
H.append("<tfoot>")
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")}
"""
</tfoot>
</table>
</div>

View File

@ -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;
}

View File

@ -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');
}
});
});