From d227264283321a96f6bd4d8b392ad79288eac64d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 29 Jun 2022 22:53:56 +0200 Subject: [PATCH] Liens navigation sur saise jury BUT --- app/but/jury_but_recap.py | 5 +++- app/scodoc/sco_utils.py | 2 ++ app/static/js/jury_but.js | 50 +++++++++++++++++++++++++++++++++++- app/static/js/table_recap.js | 12 +++++++++ app/views/notes.py | 6 ++--- sco_version.py | 2 +- 6 files changed, 71 insertions(+), 6 deletions(-) diff --git a/app/but/jury_but_recap.py b/app/but/jury_but_recap.py index d735018fa..1eca11cfb 100644 --- a/app/but/jury_but_recap.py +++ b/app/but/jury_but_recap.py @@ -333,7 +333,10 @@ class RowCollector: + ((" " + scu.EMO_WARNING) if deca.nb_rcues_under_8 > 0 else ""), "col_rcue col_rcues_validables" + klass, ) - self["_rcues_validables_data"] = {"etudid": deca.etud.id} + self["_rcues_validables_data"] = { + "etudid": deca.etud.id, + "nomprenom": deca.etud.nomprenom, + } if len(deca.rcues_annee) > 0: # permet un tri par nb de niveaux validables + moyenne gen indicative S_pair if deca.res_pair and deca.etud.id in deca.res_pair.etud_moy_gen: diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index 150c8cfe7..88dca7fde 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -968,6 +968,8 @@ ICON_XLS = icontag("xlsicon_img", title="Version tableur") # HTML emojis EMO_WARNING = "⚠️" # warning /!\ EMO_RED_TRIANGLE_DOWN = "🔻" # red triangle pointed down +EMO_PREV_ARROW = "❮" +EMO_NEXT_ARROW = "❯" def sort_dates(L, reverse=False): diff --git a/app/static/js/jury_but.js b/app/static/js/jury_but.js index e67362cb2..1ef24c168 100644 --- a/app/static/js/jury_but.js +++ b/app/static/js/jury_but.js @@ -11,4 +11,52 @@ function change_menu_code(elt) { // TODO: comparer avec valeur enregistrée (à mettre en data-orig ?) // et colorer en fonction elt.parentElement.parentElement.classList.add("modified"); -} \ No newline at end of file +} + +$(function () { + // Recupère la liste ordonnées des etudids + // pour avoir le "suivant" etr le "précédent" + // (liens de navigation) + const url = new URL(document.URL); + const frags = url.pathname.split("/"); // .../formsemestre_validation_but/formsemestre_id/etudid + const etudid = frags[frags.length - 1]; + const formsemestre_id = frags[frags.length - 2]; + const etudids_key = JSON.stringify(["etudids", url.origin, formsemestre_id]); + const etudids_str = localStorage.getItem(etudids_key); + const noms_key = JSON.stringify(["noms", url.origin, formsemestre_id]); + const noms_str = localStorage.getItem(noms_key); + if (etudids_str && noms_str) { + const etudids = JSON.parse(etudids_str); + const noms = JSON.parse(noms_str); + const cur_idx = etudids.indexOf(etudid); + let prev_idx = -1; + let next_idx = -1 + if (cur_idx != -1) { + if (cur_idx > 0) { + prev_idx = cur_idx - 1; + } + if (cur_idx < etudids.length - 1) { + next_idx = cur_idx + 1; + } + } + if (prev_idx != -1) { + let elem = document.querySelector("div.prev a"); + if (elem) { + elem.href = elem.href.replace("PREV", etudids[prev_idx]); + elem.innerHTML = noms[prev_idx]; + } + } else { + document.querySelector("div.prev").innerHTML = ""; + } + if (next_idx != -1) { + let elem = document.querySelector("div.next a"); + if (elem) { + elem.href = elem.href.replace("NEXT", etudids[next_idx]); + elem.innerHTML = noms[next_idx]; + } + } else { + document.querySelector("div.next").innerHTML = ""; + } + + } +}); \ No newline at end of file diff --git a/app/static/js/table_recap.js b/app/static/js/table_recap.js index 805153fda..b9c86d5f8 100644 --- a/app/static/js/table_recap.js +++ b/app/static/js/table_recap.js @@ -192,6 +192,18 @@ $(function () { if (formsemestre_id) { localStorage.setItem(order_info_key, order_info); } + let etudids = []; + document.querySelectorAll("td.col_rcues_validables").forEach(e => { + etudids.push(e.dataset.etudid); + }); + let noms = []; + document.querySelectorAll("td.col_rcues_validables").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, } diff --git a/app/views/notes.py b/app/views/notes.py index 5270ffd22..883a7c7be 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -2332,15 +2332,15 @@ def formsemestre_validation_but( """ ) # --- Navigation - prev = f"""précédent + )}" class="stdlink"">précédent """ next = f"""suivant + )}" class="stdlink"">suivant {scu.EMO_NEXT_ARROW} """ H.append( f""" diff --git a/sco_version.py b/sco_version.py index 474261ea9..58fc4f03a 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.6" +SCOVERSION = "9.3.7" SCONAME = "ScoDoc"