From 47f17157f106c7d5b19336d70debf28f0c524262 Mon Sep 17 00:00:00 2001 From: Iziram Date: Fri, 23 Aug 2024 16:09:46 +0200 Subject: [PATCH] update etud_info : func attach_etud_info --- app/static/js/assiduites.js | 9 +++++++ app/static/js/etud_info.js | 52 +++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index 4bcb83960..446817247 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -263,6 +263,8 @@ function creerLigneEtudiant(etud, index) { // div index avec l'index const indexDiv = document.createElement("div"); indexDiv.classList.add("index"); + indexDiv.id = `etudid-${etud.id}`; + indexDiv.textContent = index; ligneEtud.appendChild(indexDiv); @@ -280,6 +282,7 @@ function creerLigneEtudiant(etud, index) { const nameSet = document.createElement("a"); nameSet.classList.add("name_set"); + nameSet.id = `etudid-${etud.id}`; nameSet.href = `bilan_etud?etudid=${etud.id}`; const nom = document.createElement("h4"); @@ -426,6 +429,12 @@ function creerLigneEtudiant(etud, index) { ligneEtud.appendChild(btnsField); + // Attache les infos de l'étudiant (bulle etud_info) + try { + attach_etud_info(nameSet); + attach_etud_info(indexDiv); + } catch {} + return ligneEtud; } diff --git a/app/static/js/etud_info.js b/app/static/js/etud_info.js index c500fe7e3..56e59858a 100644 --- a/app/static/js/etud_info.js +++ b/app/static/js/etud_info.js @@ -14,7 +14,7 @@ function get_etudid_from_elem(e) { } $().ready(function () { - if (typeof SCO_URL == 'undefined') { + if (typeof SCO_URL == "undefined") { return; } var elems = $(".etudinfo:not(th)"); @@ -38,7 +38,10 @@ $().ready(function () { $(elems[i]).qtip({ content: { ajax: { - url: `${SCO_URL}etud_info_html?etudid=` + get_etudid_from_elem(elems[i]) + qs, + url: + `${SCO_URL}etud_info_html?etudid=` + + get_etudid_from_elem(elems[i]) + + qs, type: "GET", //success: function(data, status) { // this.set('content.text', data); @@ -63,3 +66,48 @@ $().ready(function () { }); } }); + +// Fonction pour attacher un tooltip a un élément +// e est l'élément HTML +// son id doit être de la forme "...-{etudid}" +// ou bien son id est "{etudid}" +function attach_etud_info(e) { + var q_args = get_query_args(); + const args_to_pass = new Set([ + "formsemestre_id", + "group_ids", + "group_id", + "partition_id", + "moduleimpl_id", + "evaluation_id", + ]); + let qs = ""; + for (var k in q_args) { + if (args_to_pass.has(k)) { + qs += "&" + k + "=" + q_args[k]; + } + } + const etudid = get_etudid_from_elem(e); + $(e).qtip({ + content: { + ajax: { + url: `${SCO_URL}etud_info_html?etudid=` + etudid + qs, + type: "GET", + }, + }, + text: "Loading...", + position: { + at: "right bottom", + my: "left top", + }, + style: { + classes: "qtip-etud", + }, + hide: { + fixed: true, + delay: 300, + }, + // utile pour debugguer le css: + // hide: { event: 'unfocus' } + }); +}