diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index d02e7cc7..b0474134 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -67,18 +67,24 @@ CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS def groups_view( group_ids=(), fmt="html", - # Options pour listes: with_codes=0, etat=None, - with_paiement=0, # si vrai, ajoute colonnes infos paiement droits et finalisation inscription (lent car interrogation portail) - with_archives=0, # ajoute colonne avec noms fichiers archivés + with_paiement=0, + with_archives=0, with_annotations=0, with_bourse=0, - formsemestre_id=None, # utilise si aucun groupe selectionné + formsemestre_id=None, ): """Affichage des étudiants des groupes indiqués group_ids: liste de group_id fmt: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf + + Options pour listes: + with_paiement: si vrai, ajoute colonnes infos paiement droits + et finalisation inscription (lent car interrogation portail) + with_archives: ajoute colonne avec noms fichiers archivés + + formsemestre_id est utilisé si aucun groupe selectionné pour construire la liste des groupes. """ # Informations sur les groupes à afficher: groups_infos = DisplayedGroupsInfos( diff --git a/app/static/js/apo_semset_maq_status.js b/app/static/js/apo_semset_maq_status.js index 445bdf87..161a2211 100644 --- a/app/static/js/apo_semset_maq_status.js +++ b/app/static/js/apo_semset_maq_status.js @@ -1,10 +1,9 @@ - $(function () { - $("div#export_help").accordion({ - heightStyle: "content", - collapsible: true, - active: false, - }); + $("div#export_help").accordion({ + heightStyle: "content", + collapsible: true, + active: false, + }); }); // Affichage des listes par type @@ -14,77 +13,89 @@ $(function () { // -> surligne le cas sélectionné function display(r, c, row, col) { - if ((row != r) && (row != '*')) return 'none'; - if ((col != c) && (col != '*')) return 'none'; - return ''; + if (row != r && row != "*") return "none"; + if (col != c && col != "*") return "none"; + return ""; } function show_tag(all_rows, all_cols, tag) { - // Filtrer tous les étudiants - all_rows.split(',').forEach(function (r) { - all_cols.split(',').forEach(function (c) { - etudiants = r + c.substring(1); - $(etudiants).css("display", "none"); - }) - }) - // sauf le tag - $('.' + tag).css('display', ''); + // Filtrer tous les étudiants + all_rows.split(",").forEach(function (r) { + all_cols.split(",").forEach(function (c) { + etudiants = r + c.substring(1); + $(etudiants).css("display", "none"); + }); + }); + // sauf le tag + $("." + tag).css("display", ""); } function show_filtres(effectifs, filtre_row, filtre_col) { - $("#compte").html(effectifs); - if ((filtre_row == '') && (filtre_col == '')) { - $("#sans_filtre").css("display", ""); - $("#filtre_row").css("display", "none"); - $("#filtre_col").css("display", "none"); + $("#compte").html(effectifs); + if (filtre_row == "" && filtre_col == "") { + $("#sans_filtre").css("display", ""); + $("#filtre_row").css("display", "none"); + $("#filtre_col").css("display", "none"); + } else { + $("#sans_filtre").css("display", "none"); + if (filtre_row == "") { + $("#filtre_row").css("display", "none"); + $("#filtre_col").css("display", ""); + $("#filtre_col").html("Filtre sur code étape: " + filtre_col); + } else if (filtre_col == "") { + $("#filtre_row").css("display", ""); + $("#filtre_col").css("display", "none"); + $("#filtre_row").html("Filtre sur semestre: " + filtre_row); } else { - $("#sans_filtre").css("display", "none"); - if (filtre_row == '') { - $("#filtre_row").css("display", "none"); - $("#filtre_col").css("display", ""); - $("#filtre_col").html("Filtre sur code étape: " + filtre_col); - } else if (filtre_col == '') { - $("#filtre_row").css("display", ""); - $("#filtre_col").css("display", "none"); - $("#filtre_row").html("Filtre sur semestre: " + filtre_row); - } else { - $("#filtre_row").css("display", ""); - $("#filtre_col").css("display", ""); - $("#filtre_row").html("Filtre sur semestre: " + filtre_row); - $("#filtre_col").html("Filtre sur code étape: " + filtre_col); - } + $("#filtre_row").css("display", ""); + $("#filtre_col").css("display", ""); + $("#filtre_row").html("Filtre sur semestre: " + filtre_row); + $("#filtre_col").html("Filtre sur code étape: " + filtre_col); } + } } -function doFiltrage(all_rows, all_cols, row, col, effectifs, filtre_row, filtre_col) { - show_filtres(effectifs, filtre_row, filtre_col) - all_rows.split(',').forEach(function (r) { - all_cols.split(',').forEach(function (c) { - etudiants = r + c.substring(1); - $(etudiants).css("display", display(r, c, row, col)); - }); +function doFiltrage( + all_rows, + all_cols, + row, + col, + effectifs, + filtre_row, + filtre_col +) { + show_filtres(effectifs, filtre_row, filtre_col); + all_rows.split(",").forEach(function (r) { + all_cols.split(",").forEach(function (c) { + etudiants = r + c.substring(1); + $(etudiants).css("display", display(r, c, row, col)); }); + }); - $('.repartition td').css("background-color", ""); - $('.repartition th').css("background-color", ""); + $(".repartition td").css("background-color", ""); + $(".repartition th").css("background-color", ""); - if (row == '*' && col == '*') { // Aucun filtre - } else if (row == '*') { // filtrage sur 1 colonne - $(col).css("background-color", "lightblue"); - } else if (col == '*') { // Filtrage sur 1 ligne - $(row + '>td').css("background-color", "lightblue"); - $(row + '>th').css("background-color", "lightblue"); - } else { // filtrage sur 1 case - $(row + '>td' + col).css("background-color", "lightblue"); - } + if (row == "*" && col == "*") { + // Aucun filtre + } else if (row == "*") { + // filtrage sur 1 colonne + $(col).css("background-color", "lightblue"); + } else if (col == "*") { + // Filtrage sur 1 ligne + $(row + ">td").css("background-color", "lightblue"); + $(row + ">th").css("background-color", "lightblue"); + } else { + // filtrage sur 1 case + $(row + ">td" + col).css("background-color", "lightblue"); + } - // Modifie le titre de la section pour indiquer la sélection: - // elt est le lien cliqué - // var td_class = elt.parentNode.className.trim(); - // if (td_class) { - // var titre_col = $("table.repartition th.")[0].textContent.trim(); - // if (titre_col) { - // $("h4#effectifs").html("Liste des étudiants de " + titre_col); - // } - // } + // Modifie le titre de la section pour indiquer la sélection: + // elt est le lien cliqué + // var td_class = elt.parentNode.className.trim(); + // if (td_class) { + // var titre_col = $("table.repartition th.")[0].textContent.trim(); + // if (titre_col) { + // $("h4#effectifs").html("Liste des étudiants de " + titre_col); + // } + // } } diff --git a/app/static/js/bulletin.js b/app/static/js/bulletin.js index 843f70f8..ffb05347 100644 --- a/app/static/js/bulletin.js +++ b/app/static/js/bulletin.js @@ -1,7 +1,6 @@ // Affichage anciens (non BUT) bulletin de notes // (uses jQuery) - // Change visibility of UE details (les de classe "notes_bulletin_row_mod" suivant) // La table a la structure suivante: // +/-...... @@ -11,40 +10,44 @@ // On change la visi de tous les jusqu'au notes_bulletin_row_ue suivant. // function toggle_vis_ue(e, new_state) { - // e is the span containg the clicked +/- icon - var tr = e.parentNode.parentNode; - if (new_state == undefined) { - // current state: use alt attribute of current image - if (e.childNodes[0].alt == '+') { - new_state = false; - } else { - new_state = true; - } - } - // find next tr in siblings - var tr = tr.nextSibling; - //while ((tr != null) && sibl.tagName == 'TR') { - var current = true; - while ((tr != null) && current) { - if ((tr.nodeType == 1) && (tr.tagName == 'TR')) { - for (var i = 0; i < tr.classList.length; i++) { - if ((tr.classList[i] == 'notes_bulletin_row_ue') || (tr.classList[i] == 'notes_bulletin_row_sum_ects')) - current = false; - } - if (current) { - if (new_state) { - tr.style.display = 'none'; - } else { - tr.style.display = 'table-row'; - } - } - } - tr = tr.nextSibling; - } - if (new_state) { - e.innerHTML = '+'; - } else { - e.innerHTML = '-'; - } + // e is the span containg the clicked +/- icon + var tr = e.parentNode.parentNode; + if (new_state == undefined) { + // current state: use alt attribute of current image + if (e.childNodes[0].alt == "+") { + new_state = false; + } else { + new_state = true; + } + } + // find next tr in siblings + var tr = tr.nextSibling; + //while ((tr != null) && sibl.tagName == 'TR') { + var current = true; + while (tr != null && current) { + if (tr.nodeType == 1 && tr.tagName == "TR") { + for (var i = 0; i < tr.classList.length; i++) { + if ( + tr.classList[i] == "notes_bulletin_row_ue" || + tr.classList[i] == "notes_bulletin_row_sum_ects" + ) + current = false; + } + if (current) { + if (new_state) { + tr.style.display = "none"; + } else { + tr.style.display = "table-row"; + } + } + } + tr = tr.nextSibling; + } + if (new_state) { + e.innerHTML = + '+'; + } else { + e.innerHTML = + '-'; + } } - diff --git a/app/static/js/calabs.js b/app/static/js/calabs.js index 50f4ff18..ebf64de9 100644 --- a/app/static/js/calabs.js +++ b/app/static/js/calabs.js @@ -12,13 +12,12 @@ var CURRENTWEEKCOLOR = "yellow"; // get all tr elements from this class // (no getElementBuClassName) -function getTRweek( week ) { - var tablecal = document.getElementById('maincalendar'); - var all = tablecal.getElementsByTagName('tr'); - var res = [] ; - for(var i=0; i < all.length; i++) { - if (all[i].className == week) - res[res.length] = all[i]; +function getTRweek(week) { + var tablecal = document.getElementById("maincalendar"); + var all = tablecal.getElementsByTagName("tr"); + var res = []; + for (var i = 0; i < all.length; i++) { + if (all[i].className == week) res[res.length] = all[i]; } return res; } @@ -26,14 +25,13 @@ function getTRweek( week ) { var HIGHLIGHTEDCELLS = []; function deselectweeks() { - - for(var i=0; i < HIGHLIGHTEDCELLS.length; i++) { + for (var i = 0; i < HIGHLIGHTEDCELLS.length; i++) { var row = rows[i]; if (row) { - if (row.className.match('currentweek')) { - row.style.backgroundColor = CURRENTWEEKCOLOR; + if (row.className.match("currentweek")) { + row.style.backgroundColor = CURRENTWEEKCOLOR; } else { - row.style.backgroundColor = WEEKDAYCOLOR; + row.style.backgroundColor = WEEKDAYCOLOR; } rows[i] = null; } @@ -44,11 +42,11 @@ function deselectweeks() { function highlightweek(el) { deselectweeks(); var week = el.className; - if ((week == 'wkend') || (week.substring(0,2) != 'wk')) { + if (week == "wkend" || week.substring(0, 2) != "wk") { return; /* does not hightlight weekends */ } rows = getTRweek(week); - for (var i=0; i < rows.length; i++) { + for (var i = 0; i < rows.length; i++) { var row = rows[i]; row.style.backgroundColor = DAYHIGHLIGHT; HIGHLIGHTEDCELLS[HIGHLIGHTEDCELLS.length] = row; @@ -58,7 +56,7 @@ function highlightweek(el) { // click on a day function wclick(el) { monday = el.className; - form = document.getElementById('formw'); - form.datelundi.value = monday.substr(2).replace(/_/g,'/').split(' ')[0]; + form = document.getElementById("formw"); + form.datelundi.value = monday.substr(2).replace(/_/g, "/").split(" ")[0]; form.submit(); } diff --git a/app/static/js/config_logos.js b/app/static/js/config_logos.js index 56b7cd27..8c129da1 100644 --- a/app/static/js/config_logos.js +++ b/app/static/js/config_logos.js @@ -1,6 +1,5 @@ function submit_form() { - $("#config_logos_form").submit(); + $("#config_logos_form").submit(); } -$(function () { -}) \ No newline at end of file +$(function () {}); diff --git a/app/static/js/detail_summary_persistence.js b/app/static/js/detail_summary_persistence.js index 1a884889..0b5645e6 100644 --- a/app/static/js/detail_summary_persistence.js +++ b/app/static/js/detail_summary_persistence.js @@ -13,70 +13,70 @@ les balises (fermées par défaut sauf si attribut open déjà activé dans le c */ -const ID_ATTRIBUTE = "ds_id" +const ID_ATTRIBUTE = "ds_id"; function genere_id(detail, idnum) { - let id = "ds_" + idnum; - if (detail.getAttribute("id")) { - id = "#" + detail.getAttribute("id"); - } - detail.setAttribute(ID_ATTRIBUTE, id); - return id; + let id = "ds_" + idnum; + if (detail.getAttribute("id")) { + id = "#" + detail.getAttribute("id"); + } + detail.setAttribute(ID_ATTRIBUTE, id); + return id; } // remise à l'état initial. doit être exécuté dès le chargement de la page pour que l'état 'open' // des balises soit celui indiqué par le serveur (et donc indépendant du localstorage) function reset_detail(detail, id) { - let opened = detail.getAttribute("open"); - if (opened) { - detail.setAttribute("open", true); - localStorage.setItem(id, true); - } else { - detail.removeAttribute("open"); - localStorage.setItem(id, false); - } + let opened = detail.getAttribute("open"); + if (opened) { + detail.setAttribute("open", true); + localStorage.setItem(id, true); + } else { + detail.removeAttribute("open"); + localStorage.setItem(id, false); + } } function restore_detail(detail, id) { - let status = localStorage.getItem(id); - if (status == "true") { - detail.setAttribute("open", true); - } else { - detail.removeAttribute("open"); - } + let status = localStorage.getItem(id); + if (status == "true") { + detail.setAttribute("open", true); + } else { + detail.removeAttribute("open"); + } } function add_listener(detail) { - detail.addEventListener('toggle', (e) => { - let id = e.target.getAttribute(ID_ATTRIBUTE); - let ante = e.target.getAttribute("open"); - if (ante == null) { - localStorage.setItem(id, false); - } else { - localStorage.setItem(id, true); - } - e.stopPropagation(); - }) + detail.addEventListener("toggle", (e) => { + let id = e.target.getAttribute(ID_ATTRIBUTE); + let ante = e.target.getAttribute("open"); + if (ante == null) { + localStorage.setItem(id, false); + } else { + localStorage.setItem(id, true); + } + e.stopPropagation(); + }); } function reset_ds() { - let idnum = 0; - keepDetails = true; - details = document.querySelectorAll("details") - details.forEach(function (detail) { - let id = genere_id(detail, idnum); - console.log("Processing " + id) - if (keepDetails) { - restore_detail(detail, id); - } else { - reset_detail(detail, id); - } - add_listener(detail); - idnum++; - }); + let idnum = 0; + keepDetails = true; + details = document.querySelectorAll("details"); + details.forEach(function (detail) { + let id = genere_id(detail, idnum); + console.log("Processing " + id); + if (keepDetails) { + restore_detail(detail, id); + } else { + reset_detail(detail, id); + } + add_listener(detail); + idnum++; + }); } -window.addEventListener('load', function() { - console.log("details/summary persistence ON"); - reset_ds(); -}) +window.addEventListener("load", function () { + console.log("details/summary persistence ON"); + reset_ds(); +}); diff --git a/app/static/js/edit_partition_form.js b/app/static/js/edit_partition_form.js index 9d4b7fd9..c9209017 100644 --- a/app/static/js/edit_partition_form.js +++ b/app/static/js/edit_partition_form.js @@ -1,38 +1,32 @@ - - function _partition_set_attr(partition_id, attr_name, attr_value) { - $.post(SCO_URL + '/partition_set_attr', - { - 'partition_id': partition_id, - 'attr': attr_name, - 'value': attr_value - }, - function (result) { - sco_message(result); - }); - return; + $.post( + SCO_URL + "/partition_set_attr", + { + partition_id: partition_id, + attr: attr_name, + value: attr_value, + }, + function (result) { + sco_message(result); + } + ); + return; } // Met à jour bul_show_rank lorsque checkbox modifiees: function update_rk(e) { - var partition_id = $(e).attr('data-partition_id'); - var v; - if (e.checked) - v = '1'; - else - v = '0'; - _partition_set_attr(partition_id, 'bul_show_rank', v); + var partition_id = $(e).attr("data-partition_id"); + var v; + if (e.checked) v = "1"; + else v = "0"; + _partition_set_attr(partition_id, "bul_show_rank", v); } - function update_show_in_list(e) { - var partition_id = $(e).attr('data-partition_id'); - var v; - if (e.checked) - v = '1'; - else - v = '0'; + var partition_id = $(e).attr("data-partition_id"); + var v; + if (e.checked) v = "1"; + else v = "0"; - _partition_set_attr(partition_id, 'show_in_lists', v); + _partition_set_attr(partition_id, "show_in_lists", v); } - diff --git a/app/static/js/edit_ue.js b/app/static/js/edit_ue.js index 488d5ea9..ef4dc60c 100644 --- a/app/static/js/edit_ue.js +++ b/app/static/js/edit_ue.js @@ -1,63 +1,72 @@ // Affiche et met a jour la liste des UE partageant le meme code $().ready(function () { - if (document.querySelector("#tf_ue_id")) { - /* fonctions spécifiques pour edition UE */ - update_ue_list(); - $("#tf_ue_code").bind("keyup", update_ue_list); + if (document.querySelector("#tf_ue_id")) { + /* fonctions spécifiques pour edition UE */ + update_ue_list(); + $("#tf_ue_code").bind("keyup", update_ue_list); - $("select#tf_type").change(function () { - update_bonus_description(); - }); - update_bonus_description(); - } + $("select#tf_type").change(function () { + update_bonus_description(); + }); + update_bonus_description(); + } }); function update_bonus_description() { - var ue_type = $("#tf_type")[0].value; - if (ue_type == "1") { /* UE SPORT */ - $("#bonus_description").show(); - var query = "/ScoDoc/get_bonus_description/default"; - $.get(query, '', function (data) { - $("#bonus_description").html(data); - }); - } else { - $("#bonus_description").html(""); - $("#bonus_description").hide(); - } + var ue_type = $("#tf_type")[0].value; + if (ue_type == "1") { + /* UE SPORT */ + $("#bonus_description").show(); + var query = "/ScoDoc/get_bonus_description/default"; + $.get(query, "", function (data) { + $("#bonus_description").html(data); + }); + } else { + $("#bonus_description").html(""); + $("#bonus_description").hide(); + } } function update_ue_list() { - let ue_id = $("#tf_ue_id")[0].value; - let ue_code = $("#tf_ue_code")[0].value; - let query = SCO_URL + "/Notes/ue_sharing_code?ue_code=" + ue_code + "&hide_ue_id=" + ue_id + "&ue_id=" + ue_id; - $.get(query, '', function (data) { - $("#ue_list_code").html(data); - }); + let ue_id = $("#tf_ue_id")[0].value; + let ue_code = $("#tf_ue_code")[0].value; + let query = + SCO_URL + + "/Notes/ue_sharing_code?ue_code=" + + ue_code + + "&hide_ue_id=" + + ue_id + + "&ue_id=" + + ue_id; + $.get(query, "", function (data) { + $("#ue_list_code").html(data); + }); } function set_ue_parcour(checkbox) { - let url = checkbox.dataset.setter; - const checkboxes = document.querySelectorAll('#choix_parcours input[type="checkbox"]:checked'); - const parcours_ids = []; - checkboxes.forEach(function (checkbox) { - parcours_ids.push(checkbox.value); + let url = checkbox.dataset.setter; + const checkboxes = document.querySelectorAll( + '#choix_parcours input[type="checkbox"]:checked' + ); + const parcours_ids = []; + checkboxes.forEach(function (checkbox) { + parcours_ids.push(checkbox.value); + }); + + fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(parcours_ids), + }) + .then((response) => response.json()) + .then((data) => { + if (data.status == 404) { + sco_error_message(data.message); + } else { + sco_message(data.message); + } }); - - fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(parcours_ids) - }) - .then(response => response.json()) - .then(data => { - if (data.status == 404) { - sco_error_message(data.message); - } else { - sco_message(data.message); - } - }); } - diff --git a/app/static/js/etud_autocomplete.js b/app/static/js/etud_autocomplete.js index 217707aa..8f6e0bfa 100644 --- a/app/static/js/etud_autocomplete.js +++ b/app/static/js/etud_autocomplete.js @@ -1,65 +1,68 @@ - // Mécanisme d'auto-complétion (choix) d'un étudiant // Il faut un champs #etudiant (text input) et à coté un champ hidden etudid qui sera rempli. // utilise autoComplete.js, source https://tarekraafat.github.io/autoComplete.js // EV 2023-06-01 function etud_autocomplete_config(with_dept = false) { - return { - selector: "#etudiant", - placeHolder: "Nom...", - threshold: 3, - data: { - src: async (query) => { - try { - // Fetch Data from external Source - const source = await fetch(`/ScoDoc/api/etudiants/name/${query}`); - // Data should be an array of `Objects` or `Strings` - const data = await source.json(); - return data; - } catch (error) { - return error; - } - }, - // Data source 'Object' key to be searched - keys: ["nom"] + return { + selector: "#etudiant", + placeHolder: "Nom...", + threshold: 3, + data: { + src: async (query) => { + try { + // Fetch Data from external Source + const source = await fetch(`/ScoDoc/api/etudiants/name/${query}`); + // Data should be an array of `Objects` or `Strings` + const data = await source.json(); + return data; + } catch (error) { + return error; + } + }, + // Data source 'Object' key to be searched + keys: ["nom"], + }, + events: { + input: { + selection: (event) => { + const prenom = sco_capitalize(event.detail.selection.value.prenom); + const selection = with_dept + ? `${event.detail.selection.value.nom} ${prenom} (${event.detail.selection.value.dept_acronym})` + : `${event.detail.selection.value.nom} ${prenom}`; + // store etudid + const etudidField = document.getElementById("etudid"); + etudidField.value = event.detail.selection.value.id; + autoCompleteJS.input.value = selection; }, - events: { - input: { - selection: (event) => { - const prenom = sco_capitalize(event.detail.selection.value.prenom); - const selection = with_dept ? `${event.detail.selection.value.nom} ${prenom} (${event.detail.selection.value.dept_acronym})` : `${event.detail.selection.value.nom} ${prenom}`; - // store etudid - const etudidField = document.getElementById('etudid'); - etudidField.value = event.detail.selection.value.id; - autoCompleteJS.input.value = selection; - } - } - }, - resultsList: { - element: (list, data) => { - if (!data.results.length) { - // Create "No Results" message element - const message = document.createElement("div"); - // Add class to the created element - message.setAttribute("class", "no_result"); - // Add message text content - message.innerHTML = `Pas de résultat pour "${data.query}"`; - // Append message element to the results list - list.prepend(message); - // Efface l'etudid - const etudidField = document.getElementById('etudid'); - etudidField.value = ""; - } - }, - noResults: true, - }, - resultItem: { - highlight: true, - element: (item, data) => { - const prenom = sco_capitalize(data.value.prenom); - item.innerHTML += with_dept ? ` ${prenom} (${data.value.dept_acronym})` : ` ${prenom}`; - }, - }, - } + }, + }, + resultsList: { + element: (list, data) => { + if (!data.results.length) { + // Create "No Results" message element + const message = document.createElement("div"); + // Add class to the created element + message.setAttribute("class", "no_result"); + // Add message text content + message.innerHTML = `Pas de résultat pour "${data.query}"`; + // Append message element to the results list + list.prepend(message); + // Efface l'etudid + const etudidField = document.getElementById("etudid"); + etudidField.value = ""; + } + }, + noResults: true, + }, + resultItem: { + highlight: true, + element: (item, data) => { + const prenom = sco_capitalize(data.value.prenom); + item.innerHTML += with_dept + ? ` ${prenom} (${data.value.dept_acronym})` + : ` ${prenom}`; + }, + }, + }; } diff --git a/app/static/js/evaluations_recap.js b/app/static/js/evaluations_recap.js index b3b60c3f..3cedb712 100644 --- a/app/static/js/evaluations_recap.js +++ b/app/static/js/evaluations_recap.js @@ -1,38 +1,37 @@ // Tableau recap evaluations du semestre $(function () { - $('table.evaluations_recap').DataTable( - { - paging: false, - searching: true, - info: false, - autoWidth: false, - fixedHeader: { - header: true, - footer: false - }, - orderCellsTop: true, // cellules ligne 1 pour tri - aaSorting: [], // Prevent initial sorting - colReorder: true, - "columnDefs": [ - { - // colonne date, triable (XXX ne fonctionne pas) - targets: ["date"], - "type": "string", - }, - ], - dom: 'Bfrtip', - buttons: [ - { - extend: 'copyHtml5', - text: 'Copier', - exportOptions: { orthogonal: 'export' } - }, - { - extend: 'excelHtml5', - exportOptions: { orthogonal: 'export' }, - title: document.querySelector('table.evaluations_recap').dataset.filename - }, - ], - - }) + $("table.evaluations_recap").DataTable({ + paging: false, + searching: true, + info: false, + autoWidth: false, + fixedHeader: { + header: true, + footer: false, + }, + orderCellsTop: true, // cellules ligne 1 pour tri + aaSorting: [], // Prevent initial sorting + colReorder: true, + columnDefs: [ + { + // colonne date, triable (XXX ne fonctionne pas) + targets: ["date"], + type: "string", + }, + ], + dom: "Bfrtip", + buttons: [ + { + extend: "copyHtml5", + text: "Copier", + exportOptions: { orthogonal: "export" }, + }, + { + extend: "excelHtml5", + exportOptions: { orthogonal: "export" }, + title: document.querySelector("table.evaluations_recap").dataset + .filename, + }, + ], + }); }); diff --git a/app/static/js/export_results.js b/app/static/js/export_results.js index ba117fa4..e5be718b 100644 --- a/app/static/js/export_results.js +++ b/app/static/js/export_results.js @@ -1,14 +1,11 @@ // Export table tous les resultats // Menu choix parcours: -$(function() { - $('#parcours_sel').multiselect( - { - includeSelectAllOption: true, - nonSelectedText:'Choisir le(s) parcours...', - selectAllValue: '', - numberDisplayed: 3, - } - ); +$(function () { + $("#parcours_sel").multiselect({ + includeSelectAllOption: true, + nonSelectedText: "Choisir le(s) parcours...", + selectAllValue: "", + numberDisplayed: 3, + }); }); - diff --git a/app/static/js/formation_recap.js b/app/static/js/formation_recap.js index 0bcb009f..6437cbf9 100644 --- a/app/static/js/formation_recap.js +++ b/app/static/js/formation_recap.js @@ -3,26 +3,38 @@ var apo_ue_editor = null; var apo_mod_editor = null; $(document).ready(function () { - var table_options = { - "paging": false, - "searching": false, - "info": false, - /* "autoWidth" : false, */ - "fixedHeader": { - "header": true, - "footer": true - }, - "orderCellsTop": true, // cellules ligne 1 pour tri - "aaSorting": [], // Prevent initial sorting - }; - $('table#formation_table_recap').DataTable(table_options); - let table_editable = document.querySelector("table#formation_table_recap.apo_editable"); - if (table_editable) { - let apo_ue_save_url = document.querySelector("table#formation_table_recap.apo_editable").dataset.apo_ue_save_url; - apo_ue_editor = new ScoFieldEditor("table#formation_table_recap tr.ue td.apo", apo_ue_save_url, false); - let apo_mod_save_url = document.querySelector("table#formation_table_recap.apo_editable").dataset.apo_mod_save_url; - apo_mod_editor = new ScoFieldEditor("table#formation_table_recap tr.mod td.apo", apo_mod_save_url, false); - } + var table_options = { + paging: false, + searching: false, + info: false, + /* "autoWidth" : false, */ + fixedHeader: { + header: true, + footer: true, + }, + orderCellsTop: true, // cellules ligne 1 pour tri + aaSorting: [], // Prevent initial sorting + }; + $("table#formation_table_recap").DataTable(table_options); + let table_editable = document.querySelector( + "table#formation_table_recap.apo_editable" + ); + if (table_editable) { + let apo_ue_save_url = document.querySelector( + "table#formation_table_recap.apo_editable" + ).dataset.apo_ue_save_url; + apo_ue_editor = new ScoFieldEditor( + "table#formation_table_recap tr.ue td.apo", + apo_ue_save_url, + false + ); + let apo_mod_save_url = document.querySelector( + "table#formation_table_recap.apo_editable" + ).dataset.apo_mod_save_url; + apo_mod_editor = new ScoFieldEditor( + "table#formation_table_recap tr.mod td.apo", + apo_mod_save_url, + false + ); + } }); - - diff --git a/app/static/js/formsemestre_edit.js b/app/static/js/formsemestre_edit.js index 3394d659..b763cc94 100644 --- a/app/static/js/formsemestre_edit.js +++ b/app/static/js/formsemestre_edit.js @@ -1,14 +1,13 @@ // Formulaire formsemestre_createwithmodules function change_semestre_id() { - var semestre_id = $("#tf_semestre_id")[0].value; - for (var i = -1; i < 12; i++) { - $(".sem" + i).hide(); - } - $(".sem" + semestre_id).show(); + var semestre_id = $("#tf_semestre_id")[0].value; + for (var i = -1; i < 12; i++) { + $(".sem" + i).hide(); + } + $(".sem" + semestre_id).show(); } - -$(window).on('load', function () { - change_semestre_id(); -}); \ No newline at end of file +$(window).on("load", function () { + change_semestre_id(); +}); diff --git a/app/static/js/formsemestre_ext_edit_ue_validations.js b/app/static/js/formsemestre_ext_edit_ue_validations.js index ed9576b5..571d2722 100644 --- a/app/static/js/formsemestre_ext_edit_ue_validations.js +++ b/app/static/js/formsemestre_ext_edit_ue_validations.js @@ -1,81 +1,83 @@ - - - function compute_moyenne() { - var notes = $(".tf_field_note input").map( - function () { return parseFloat($(this).val()); } - ).get(); - // les coefs sont donnes (ECTS en BUT) - let coefs = $("form.tf_ext_edit_ue_validations").data("ue_coefs"); - // ou saisis (formations classiques) - if (coefs == 'undefined') { - coefs = $(".tf_field_coef input").map( - function () { return parseFloat($(this).val()); } - ).get(); + var notes = $(".tf_field_note input") + .map(function () { + return parseFloat($(this).val()); + }) + .get(); + // les coefs sont donnes (ECTS en BUT) + let coefs = $("form.tf_ext_edit_ue_validations").data("ue_coefs"); + // ou saisis (formations classiques) + if (coefs == "undefined") { + coefs = $(".tf_field_coef input") + .map(function () { + return parseFloat($(this).val()); + }) + .get(); + } + var N = notes.length; + var dp = 0; + var sum_coefs = 0; + for (var i = 0; i < N; i++) { + if (!(isNaN(notes[i]) || isNaN(coefs[i]))) { + dp += notes[i] * coefs[i]; + sum_coefs += coefs[i]; } - var N = notes.length; - var dp = 0.; - var sum_coefs = 0.; - for (var i = 0; i < N; i++) { - if (!(isNaN(notes[i]) || isNaN(coefs[i]))) { - dp += notes[i] * coefs[i]; - sum_coefs += coefs[i]; - } - } - let moy = dp / sum_coefs; - if (isNaN(moy)) { - moy = "-"; - } - if (typeof moy == "number") { - moy = moy.toFixed(2); - } - return moy; + } + let moy = dp / sum_coefs; + if (isNaN(moy)) { + moy = "-"; + } + if (typeof moy == "number") { + moy = moy.toFixed(2); + } + return moy; } // Callback select menu (UE code) function enable_disable_fields_cb() { - enable_disable_fields(this); + enable_disable_fields(this); } function enable_disable_fields(select_elt) { - // input fields controled by this menu - var input_fields = $(select_elt).parent().parent().find('input:not(.ext_coef_disabled)'); - var disabled = false; - if ($(select_elt).val() === "None") { - disabled = true; + // input fields controled by this menu + var input_fields = $(select_elt) + .parent() + .parent() + .find("input:not(.ext_coef_disabled)"); + var disabled = false; + if ($(select_elt).val() === "None") { + disabled = true; + } + input_fields.each(function () { + if (disabled) { + let cur_value = $(this).val(); + $(this).data("saved-value", cur_value); + $(this).val(""); + } else { + let saved_value = $(this).data("saved-value"); + if (typeof saved_value == "undefined") { + saved_value = ""; + } + if (saved_value) { + $(this).val(saved_value); + } } - input_fields.each(function () { - if (disabled) { - let cur_value = $(this).val(); - $(this).data('saved-value', cur_value); - $(this).val(""); - } else { - let saved_value = $(this).data('saved-value'); - if (typeof saved_value == 'undefined') { - saved_value = ''; - } - if (saved_value) { - $(this).val(saved_value); - } - } - }); - input_fields.prop('disabled', disabled); + }); + input_fields.prop("disabled", disabled); } function setup_text_fields() { - $(".ueext_valid_select").each( - function () { - enable_disable_fields(this); - } - ); + $(".ueext_valid_select").each(function () { + enable_disable_fields(this); + }); } $().ready(function () { - $(".tf_ext_edit_ue_validations").change(function () { - $(".ext_sem_moy_val")[0].innerHTML = compute_moyenne(); - }); - $("form.tf_ext_edit_ue_validations input").blur(function () { - $(".ext_sem_moy_val")[0].innerHTML = compute_moyenne(); - }); - $(".ueext_valid_select").change(enable_disable_fields_cb); + $(".tf_ext_edit_ue_validations").change(function () { + $(".ext_sem_moy_val")[0].innerHTML = compute_moyenne(); + }); + $("form.tf_ext_edit_ue_validations input").blur(function () { + $(".ext_sem_moy_val")[0].innerHTML = compute_moyenne(); + }); + $(".ueext_valid_select").change(enable_disable_fields_cb); - setup_text_fields(); + setup_text_fields(); }); diff --git a/app/static/js/groups_view.js b/app/static/js/groups_view.js index 28bbeeba..74433b64 100644 --- a/app/static/js/groups_view.js +++ b/app/static/js/groups_view.js @@ -1,225 +1,213 @@ // Affichage progressif du trombinoscope html $().ready(function () { - var spans = $(".unloaded_img"); - for (var i = 0; i < spans.length; i++) { - var sp = spans[i]; - var etudid = sp.id; - $(sp).load(SCO_URL + "/etud_photo_html?etudid=" + etudid); - } + var spans = $(".unloaded_img"); + for (var i = 0; i < spans.length; i++) { + var sp = spans[i]; + var etudid = sp.id; + $(sp).load(SCO_URL + "/etud_photo_html?etudid=" + etudid); + } }); // L'URL pour recharger l'état courant de la page (groupes et tab selectionnes) // (ne fonctionne que pour les requetes GET: manipule la query string) function groups_view_url() { - var url = $.url(); - delete url.param()["group_ids"]; // retire anciens groupes de l'URL - delete url.param()["curtab"]; // retire ancien tab actif - if (CURRENT_TAB_HASH) { - url.param()["curtab"] = CURRENT_TAB_HASH; - } - delete url.param()["formsemestre_id"]; - url.param()["formsemestre_id"] = - $("#group_selector")[0].formsemestre_id.value; + var url = $.url(); + delete url.param()["group_ids"]; // retire anciens groupes de l'URL + delete url.param()["curtab"]; // retire ancien tab actif + if (CURRENT_TAB_HASH) { + url.param()["curtab"] = CURRENT_TAB_HASH; + } + delete url.param()["formsemestre_id"]; + url.param()["formsemestre_id"] = + $("#group_selector")[0].formsemestre_id.value; - var selected_groups = $("#group_selector select").val(); - url.param()["group_ids"] = selected_groups; // remplace par groupes selectionnes + var selected_groups = $("#group_selector select").val(); + url.param()["group_ids"] = selected_groups; // remplace par groupes selectionnes - return url; + return url; } // Sélectionne le groupe "tous" et recharge la page: function select_groupe_tous() { - var url = groups_view_url(); - var default_group_id = $("#group_selector")[0].default_group_id.value; - delete url.param()["group_ids"]; - url.param()["group_ids"] = [default_group_id]; + var url = groups_view_url(); + var default_group_id = $("#group_selector")[0].default_group_id.value; + delete url.param()["group_ids"]; + url.param()["group_ids"] = [default_group_id]; - var query_string = $.param(url.param(), (traditional = true)); - window.location = url.attr("base") + url.attr("path") + "?" + query_string; + var query_string = $.param(url.param(), (traditional = true)); + window.location = url.attr("base") + url.attr("path") + "?" + query_string; } // Recharge la page sans arguments group_ids function remove_group_filter() { - var url = groups_view_url(); - delete url.param()["group_ids"]; - var query_string = $.param(url.param(), (traditional = true)); - window.location = url.attr("base") + url.attr("path") + "?" + query_string; + var url = groups_view_url(); + delete url.param()["group_ids"]; + var query_string = $.param(url.param(), (traditional = true)); + window.location = url.attr("base") + url.attr("path") + "?" + query_string; } // L'URL pour l'état courant de la page: function get_current_url() { - var url = groups_view_url(); - var query_string = $.param(url.param(), (traditional = true)); - return url.attr("base") + url.attr("path") + "?" + query_string; + var url = groups_view_url(); + var query_string = $.param(url.param(), (traditional = true)); + return url.attr("base") + url.attr("path") + "?" + query_string; } // Recharge la page en changeant les groupes selectionnés et en conservant le tab actif: function submit_group_selector() { - window.location = get_current_url(); + window.location = get_current_url(); } function show_current_tab() { - if (document.getElementsByClassName("nav-tabs").length < 0) { - $('.nav-tabs [href="#' + CURRENT_TAB_HASH + '"]').tab("show"); - } + if (document.getElementsByClassName("nav-tabs").length > 0) { + $('.nav-tabs [href="#' + CURRENT_TAB_HASH + '"]').tab("show"); + } } var CURRENT_TAB_HASH = $.url().param()["curtab"]; $().ready(function () { - $(".nav-tabs a").on("shown.bs.tab", function (e) { - CURRENT_TAB_HASH = e.target.hash.slice(1); // sans le # - }); + $(".nav-tabs a").on("shown.bs.tab", function (e) { + CURRENT_TAB_HASH = e.target.hash.slice(1); // sans le # + }); - show_current_tab(); + show_current_tab(); }); function change_list_options() { - var url = groups_view_url(); - var selected_options = $("#group_list_options").val(); - var options = [ - "with_paiement", - "with_archives", - "with_annotations", - "with_codes", - "with_bourse", - ]; - for (var i = 0; i < options.length; i++) { - var option = options[i]; - delete url.param()[option]; - if ($.inArray(option, selected_options) >= 0) { - url.param()[option] = 1; - } + var url = groups_view_url(); + var selected_options = $("#group_list_options").val(); + var options = [ + "with_paiement", + "with_archives", + "with_annotations", + "with_codes", + "with_bourse", + ]; + for (var i = 0; i < options.length; i++) { + var option = options[i]; + delete url.param()[option]; + if ($.inArray(option, selected_options) >= 0) { + url.param()[option] = 1; } - var query_string = $.param(url.param(), (traditional = true)); - window.location = url.attr("base") + url.attr("path") + "?" + query_string; + } + var query_string = $.param(url.param(), (traditional = true)); + window.location = url.attr("base") + url.attr("path") + "?" + query_string; } // Menu choix groupe: function toggle_visible_etuds() { - // - $(".etud_elem").hide(); - var qargs = ""; - $("#group_ids_sel option:selected").each(function (index, opt) { - var group_id = opt.value; - $(".group-" + group_id).show(); - qargs += "&group_ids=" + group_id; - }); - // Update url saisie tableur: - var input_eval = $("#formnotes_evaluation_id"); - if (input_eval.length > 0) { - var evaluation_id = input_eval[0].value; - $("#menu_saisie_tableur a").attr( - "href", - "saisie_notes_tableur?evaluation_id=" + evaluation_id + qargs - ); - // lien feuille excel: - $("#lnk_feuille_saisie").attr( - "href", - "feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs - ); - } - // Update champs form group_ids_str - let group_ids_str = Array.from( - document.querySelectorAll("#group_ids_sel option:checked") - ) - .map(function (elem) { - return elem.value; - }) - .join(); - document - .querySelectorAll("input.group_ids_str") - .forEach((elem) => (elem.value = group_ids_str)); + // + $(".etud_elem").hide(); + var qargs = ""; + $("#group_ids_sel option:selected").each(function (index, opt) { + var group_id = opt.value; + $(".group-" + group_id).show(); + qargs += "&group_ids=" + group_id; + }); + // Update url saisie tableur: + var input_eval = $("#formnotes_evaluation_id"); + if (input_eval.length > 0) { + var evaluation_id = input_eval[0].value; + $("#menu_saisie_tableur a").attr( + "href", + "saisie_notes_tableur?evaluation_id=" + evaluation_id + qargs + ); + // lien feuille excel: + $("#lnk_feuille_saisie").attr( + "href", + "feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs + ); + } + // Update champs form group_ids_str + let group_ids_str = Array.from( + document.querySelectorAll("#group_ids_sel option:checked") + ) + .map(function (elem) { + return elem.value; + }) + .join(); + document + .querySelectorAll("input.group_ids_str") + .forEach((elem) => (elem.value = group_ids_str)); } $().ready(function () { - $("#group_ids_sel").multiselect({ - includeSelectAllOption: false, - nonSelectedText: "choisir...", - // buttonContainer: '
', - onChange: function (element, checked) { - // Gestion du groupe "tous" - if ( - checked == true && - $("#group_ids_sel").hasClass("default_deselect_others") - ) { - var default_group_id = $(".default_group")[0].value; + $("#group_ids_sel").multiselect({ + includeSelectAllOption: false, + nonSelectedText: "choisir...", + // buttonContainer: '
', + onChange: function (element, checked) { + // Gestion du groupe "tous" + if ( + checked == true && + $("#group_ids_sel").hasClass("default_deselect_others") + ) { + var default_group_id = $(".default_group")[0].value; - if (element.hasClass("default_group")) { - // click sur groupe "tous" - // deselectionne les autres - $("#group_ids_sel option:selected").each(function ( - index, - opt - ) { - if (opt.value != default_group_id) { - $("#group_ids_sel").multiselect( - "deselect", - opt.value - ); - } - }); - } else { - // click sur un autre item - // si le groupe "tous" est selectionne et que l'on coche un autre, le deselectionner - var default_is_selected = false; - $("#group_ids_sel option:selected").each(function ( - index, - opt - ) { - if (opt.value == default_group_id) { - default_is_selected = true; - return false; - } - }); - if (default_is_selected) { - $("#group_ids_sel").multiselect( - "deselect", - default_group_id - ); - } - } + if (element.hasClass("default_group")) { + // click sur groupe "tous" + // deselectionne les autres + $("#group_ids_sel option:selected").each(function (index, opt) { + if (opt.value != default_group_id) { + $("#group_ids_sel").multiselect("deselect", opt.value); } - - toggle_visible_etuds(); - // referme le menu apres chaque choix: - $("#group_selector .btn-group").removeClass("open"); - - if ($("#group_ids_sel").hasClass("submit_on_change")) { - submit_group_selector(); + }); + } else { + // click sur un autre item + // si le groupe "tous" est selectionne et que l'on coche un autre, le deselectionner + var default_is_selected = false; + $("#group_ids_sel option:selected").each(function (index, opt) { + if (opt.value == default_group_id) { + default_is_selected = true; + return false; } - }, - }); + }); + if (default_is_selected) { + $("#group_ids_sel").multiselect("deselect", default_group_id); + } + } + } - // initial setup - toggle_visible_etuds(); + toggle_visible_etuds(); + // referme le menu apres chaque choix: + $("#group_selector .btn-group").removeClass("open"); + + if ($("#group_ids_sel").hasClass("submit_on_change")) { + submit_group_selector(); + } + }, + }); + + // initial setup + toggle_visible_etuds(); }); // Trombinoscope $().ready(function () { - var elems = $(".trombi-photo"); - for (var i = 0; i < elems.length; i++) { - $(elems[i]).qtip({ - content: { - ajax: { - url: - SCO_URL + - "/etud_info_html?with_photo=0&etudid=" + - get_etudid_from_elem(elems[i]), - }, - text: "Loading...", - }, - position: { - at: "right", - my: "left top", - }, - style: { - classes: "qtip-etud", - }, - // utile pour debugguer le css: - // hide: { event: 'unfocus' } - }); - } + var elems = $(".trombi-photo"); + for (var i = 0; i < elems.length; i++) { + $(elems[i]).qtip({ + content: { + ajax: { + url: + SCO_URL + + "/etud_info_html?with_photo=0&etudid=" + + get_etudid_from_elem(elems[i]), + }, + text: "Loading...", + }, + position: { + at: "right", + my: "left top", + }, + style: { + classes: "qtip-etud", + }, + // utile pour debugguer le css: + // hide: { event: 'unfocus' } + }); + } }); diff --git a/app/static/js/jury_but.js b/app/static/js/jury_but.js index c53b223a..945e9333 100644 --- a/app/static/js/jury_but.js +++ b/app/static/js/jury_but.js @@ -1,88 +1,90 @@ - - // active les menus des codes "manuels" (année, RCUEs) function enable_manual_codes(elt) { - $(".jury_but select.manual").prop("disabled", !elt.checked); + $(".jury_but select.manual").prop("disabled", !elt.checked); } // changement d'un menu code: function change_menu_code(elt) { - // Ajuste styles pour visualiser codes enregistrés/modifiés - if (elt.value != elt.dataset.orig_code) { - elt.parentElement.parentElement.classList.add("modified"); - } else { - elt.parentElement.parentElement.classList.remove("modified"); - } - if (elt.value == elt.dataset.orig_recorded) { - elt.parentElement.parentElement.classList.add("recorded"); - } else { - elt.parentElement.parentElement.classList.remove("recorded"); - } - // Si RCUE passant en ADJ, change les menus des UEs associées ADJR - if (elt.classList.contains("code_rcue") - && elt.dataset.niveau_id - && elt.value == "ADJ" - && elt.value != elt.dataset.orig_recorded) { - let ue_selects = elt.parentElement.parentElement.parentElement.querySelectorAll( - "select.ue_rcue_" + elt.dataset.niveau_id); - ue_selects.forEach(select => { - if (select.value != "ADM") { - select.value = "ADJR"; - change_menu_code(select); // pour changer les styles - } - }); - } + // Ajuste styles pour visualiser codes enregistrés/modifiés + if (elt.value != elt.dataset.orig_code) { + elt.parentElement.parentElement.classList.add("modified"); + } else { + elt.parentElement.parentElement.classList.remove("modified"); + } + if (elt.value == elt.dataset.orig_recorded) { + elt.parentElement.parentElement.classList.add("recorded"); + } else { + elt.parentElement.parentElement.classList.remove("recorded"); + } + // Si RCUE passant en ADJ, change les menus des UEs associées ADJR + if ( + elt.classList.contains("code_rcue") && + elt.dataset.niveau_id && + elt.value == "ADJ" && + elt.value != elt.dataset.orig_recorded + ) { + let ue_selects = + elt.parentElement.parentElement.parentElement.querySelectorAll( + "select.ue_rcue_" + elt.dataset.niveau_id + ); + ue_selects.forEach((select) => { + if (select.value != "ADM") { + select.value = "ADJR"; + change_menu_code(select); // pour changer les styles + } + }); + } } $(function () { - // Recupère la liste ordonnées des etudids - // pour avoir le "suivant" et 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 = ""; - } - } else { - // Supprime les liens de navigation - document.querySelector("div.prev").innerHTML = ""; - document.querySelector("div.next").innerHTML = ""; + // Recupère la liste ordonnées des etudids + // pour avoir le "suivant" et 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 = ""; + } + } else { + // Supprime les liens de navigation + document.querySelector("div.prev").innerHTML = ""; + document.querySelector("div.next").innerHTML = ""; + } }); // ----- Etat du formulaire jury pour éviter sortie sans enregistrer @@ -91,29 +93,31 @@ let IS_SUBMITTING = false; // Une chaine décrivant l'état du form function get_form_state() { - let codes = []; - // il n'y a que des + document.querySelectorAll("select").forEach((sel) => codes.push(sel.value)); + return codes.join(); } -$('document').ready(function () { - FORM_STATE = get_form_state(); - document.querySelector("form#jury_but").addEventListener('submit', jury_form_submit); +$("document").ready(function () { + FORM_STATE = get_form_state(); + document + .querySelector("form#jury_but") + .addEventListener("submit", jury_form_submit); }); function is_modified() { - return FORM_STATE != get_form_state(); + return FORM_STATE != get_form_state(); } function jury_form_submit(event) { - IS_SUBMITTING = true; + IS_SUBMITTING = true; } window.addEventListener("beforeunload", function (e) { - if ((!IS_SUBMITTING) && is_modified()) { - var confirmationMessage = 'Changements non enregistrés !'; - (e || window.event).returnValue = confirmationMessage; - return confirmationMessage; - } + if (!IS_SUBMITTING && is_modified()) { + var confirmationMessage = "Changements non enregistrés !"; + (e || window.event).returnValue = confirmationMessage; + return confirmationMessage; + } }); diff --git a/app/static/js/map_lycees.js b/app/static/js/map_lycees.js index dae9f433..514ac4c4 100644 --- a/app/static/js/map_lycees.js +++ b/app/static/js/map_lycees.js @@ -2,33 +2,42 @@ var ScoMarkerIcons = {}; -$().ready(function(){ - $('#lyc_map_canvas').gmap( - { 'center': '48.955741,2.34141', - 'zoom' : 8, - 'mapTypeId': google.maps.MapTypeId.ROADMAP - }).bind('init', function(event, map) { - for (var i =0; i < lycees_coords.length; i++) { - var lycee = lycees_coords[i]; - var nb = lycee['number']; - var icon; - if (nb in ScoMarkerIcons) { - icon = ScoMarkerIcons[nb]; - } else { - icon = new google.maps.MarkerImage( 'https://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=' + nb + '|FF0000|000000' ); - ScoMarkerIcons[nb] = icon; // cache - } - $('#lyc_map_canvas').gmap( - 'addMarker', - {'position': lycee['position'], 'bounds': true, 'nomlycee' : lycee['name'], 'icon' : icon } - ).click( - function() { - $('#lyc_map_canvas').gmap('openInfoWindow', {'content': this.nomlycee}, this); - } - ); - } - }); +$().ready(function () { + $("#lyc_map_canvas") + .gmap({ + center: "48.955741,2.34141", + zoom: 8, + mapTypeId: google.maps.MapTypeId.ROADMAP, + }) + .bind("init", function (event, map) { + for (var i = 0; i < lycees_coords.length; i++) { + var lycee = lycees_coords[i]; + var nb = lycee["number"]; + var icon; + if (nb in ScoMarkerIcons) { + icon = ScoMarkerIcons[nb]; + } else { + icon = new google.maps.MarkerImage( + "https://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=" + + nb + + "|FF0000|000000" + ); + ScoMarkerIcons[nb] = icon; // cache + } + $("#lyc_map_canvas") + .gmap("addMarker", { + position: lycee["position"], + bounds: true, + nomlycee: lycee["name"], + icon: icon, + }) + .click(function () { + $("#lyc_map_canvas").gmap( + "openInfoWindow", + { content: this.nomlycee }, + this + ); + }); + } + }); }); - - - diff --git a/app/static/js/module_edit.js b/app/static/js/module_edit.js index 9882fdff..2917c017 100644 --- a/app/static/js/module_edit.js +++ b/app/static/js/module_edit.js @@ -1,8 +1,3 @@ /* Page édition module */ - -$(document).ready(function () { - -}); - - +$(document).ready(function () {}); diff --git a/app/static/js/module_tag_editor.js b/app/static/js/module_tag_editor.js index 13ca64d7..9aff530a 100644 --- a/app/static/js/module_tag_editor.js +++ b/app/static/js/module_tag_editor.js @@ -1,35 +1,31 @@ // Edition tags sur modules +$(function () { + $(".module_tag_editor").tagEditor({ + initialTags: "", + placeholder: "Tags du module ...", + forceLowercase: false, + onChange: function (field, editor, tags) { + $.post("module_tag_set", { + module_id: field.data("module_id"), + taglist: tags.join(), + }); + }, + autocomplete: { + delay: 200, // ms before suggest + position: { collision: "flip" }, // automatic menu position up/down + source: "module_tag_search", + }, + }); -$(function() { - $('.module_tag_editor').tagEditor({ - initialTags: '', - placeholder: 'Tags du module ...', - forceLowercase: false, - onChange: function(field, editor, tags) { - $.post('module_tag_set', - { - module_id: field.data("module_id"), - taglist: tags.join() - }); - }, - autocomplete: { - delay: 200, // ms before suggest - position: { collision: 'flip' }, // automatic menu position up/down - source: "module_tag_search" - }, - }); - - // version readonly - readOnlyTags($('.module_tag_editor_ro')); - - - $('.sco_tag_checkbox').click(function() { - if( $(this).is(':checked')) { - $(".sco_tag_edit").show(); - } else { - $(".sco_tag_edit").hide(); - } - }); + // version readonly + readOnlyTags($(".module_tag_editor_ro")); + $(".sco_tag_checkbox").click(function () { + if ($(this).is(":checked")) { + $(".sco_tag_edit").show(); + } else { + $(".sco_tag_edit").hide(); + } + }); }); diff --git a/app/static/js/moduleimpl_inscriptions_stats.js b/app/static/js/moduleimpl_inscriptions_stats.js index af8d4bb3..9390acbe 100644 --- a/app/static/js/moduleimpl_inscriptions_stats.js +++ b/app/static/js/moduleimpl_inscriptions_stats.js @@ -2,36 +2,31 @@ */ function change_ue_inscr(elt) { - let url = ""; - if (elt.checked) { - url = elt.dataset.url_inscr; - } else { - url = elt.dataset.url_desinscr; - } - $.post(url, - {}, - function (result) { - sco_message("changement inscription UE enregistré"); - } - ); + let url = ""; + if (elt.checked) { + url = elt.dataset.url_inscr; + } else { + url = elt.dataset.url_desinscr; + } + $.post(url, {}, function (result) { + sco_message("changement inscription UE enregistré"); + }); } $(function () { - $("table#but_ue_inscriptions").DataTable( - { - paging: false, - searching: true, - info: false, - autoWidth: false, - fixedHeader: { - header: true, - footer: false - }, - orderCellsTop: true, // cellules ligne 1 pour tri - aaSorting: [], // Prevent initial sorting - "oLanguage": { - "sSearch": "Chercher :" - } - } - ); + $("table#but_ue_inscriptions").DataTable({ + paging: false, + searching: true, + info: false, + autoWidth: false, + fixedHeader: { + header: true, + footer: false, + }, + orderCellsTop: true, // cellules ligne 1 pour tri + aaSorting: [], // Prevent initial sorting + oLanguage: { + sSearch: "Chercher :", + }, + }); }); diff --git a/app/static/js/radar_bulletin.js b/app/static/js/radar_bulletin.js index 43fe13dc..533b3bf5 100644 --- a/app/static/js/radar_bulletin.js +++ b/app/static/js/radar_bulletin.js @@ -25,7 +25,7 @@ var NB_TICS = R_TICS.length; function get_notes_and_draw(formsemestre_id, etudid) { console.log("get_notes(" + formsemestre_id + ", " + etudid + " )"); /* Recupère le bulletin de note et extrait tableau de notes */ - /* + /* var notes = [ { 'module' : 'E1', 'note' : 13, diff --git a/app/static/js/recap_parcours.js b/app/static/js/recap_parcours.js index 8f9329d3..8615ad17 100644 --- a/app/static/js/recap_parcours.js +++ b/app/static/js/recap_parcours.js @@ -1,59 +1,67 @@ // Affichage parcours etudiant // (uses jQuery) -function toggle_vis(e, new_state) { // change visibility of tr (UE in tr and next tr) - // e is the span containg the clicked +/- icon - var formsemestre_class = e.classList[1]; - var tr = e.parentNode.parentNode; - if (new_state == undefined) { - // current state: use alt attribute of current image - if (e.childNodes[0].alt == '+') { - new_state=false; - } else { - new_state=true; - } - } - if (new_state) { - new_tr_display = 'none'; +function toggle_vis(e, new_state) { + // change visibility of tr (UE in tr and next tr) + // e is the span containg the clicked +/- icon + var formsemestre_class = e.classList[1]; + var tr = e.parentNode.parentNode; + if (new_state == undefined) { + // current state: use alt attribute of current image + if (e.childNodes[0].alt == "+") { + new_state = false; } else { - new_tr_display = 'table-row'; + new_state = true; } - $("tr."+formsemestre_class+":not(.rcp_l1)").css('display', new_tr_display) - - // find next tr in siblings (xxx legacy code, could be optimized) - var sibl = tr.nextSibling; - while ((sibl != null) && sibl.nodeType != 1 && sibl.tagName != 'TR') { - sibl = sibl.nextSibling; + } + if (new_state) { + new_tr_display = "none"; + } else { + new_tr_display = "table-row"; + } + $("tr." + formsemestre_class + ":not(.rcp_l1)").css( + "display", + new_tr_display + ); + + // find next tr in siblings (xxx legacy code, could be optimized) + var sibl = tr.nextSibling; + while (sibl != null && sibl.nodeType != 1 && sibl.tagName != "TR") { + sibl = sibl.nextSibling; + } + if (sibl) { + var td_disp = "none"; + if (new_state) { + e.innerHTML = + '+'; + } else { + e.innerHTML = + '-'; + td_disp = "inline"; } - if (sibl) { - var td_disp = 'none'; - if (new_state) { - e.innerHTML = '+'; - } else { - e.innerHTML = '-'; - td_disp = 'inline'; - } - // acronymes d'UE - sibl = e.parentNode.nextSibling; - while (sibl != null) { - if (sibl.nodeType == 1 && sibl.className == 'ue_acro') - sibl.childNodes[0].style.display = td_disp; - sibl = sibl.nextSibling; - } + // acronymes d'UE + sibl = e.parentNode.nextSibling; + while (sibl != null) { + if (sibl.nodeType == 1 && sibl.className == "ue_acro") + sibl.childNodes[0].style.display = td_disp; + sibl = sibl.nextSibling; } + } } var sems_state = false; function toggle_all_sems(e) { - var elems = $("span.toggle_sem"); - for (var i=0; i < elems.length; i++) { - toggle_vis(elems[i], sems_state); - } - sems_state = !sems_state; - if (sems_state) { - e.innerHTML = '-'; - } else { - e.innerHTML = '+'; - } -} \ No newline at end of file + var elems = $("span.toggle_sem"); + for (var i = 0; i < elems.length; i++) { + toggle_vis(elems[i], sems_state); + } + sems_state = !sems_state; + if (sems_state) { + e.innerHTML = + '-'; + } else { + e.innerHTML = + '+'; + } +} diff --git a/app/static/js/ref_competences.js b/app/static/js/ref_competences.js index 32b9f9db..38d2730b 100644 --- a/app/static/js/ref_competences.js +++ b/app/static/js/ref_competences.js @@ -1,106 +1,131 @@ - class ref_competences extends HTMLElement { - constructor() { - super(); - this.shadow = this.attachShadow({ mode: 'open' }); + constructor() { + super(); + this.shadow = this.attachShadow({ mode: "open" }); - /* Template de base */ - this.shadow.innerHTML = ` + /* Template de base */ + this.shadow.innerHTML = `
Cliquer sur un parcours pour afficher ses niveaux de compétences
`; - /* Style du module */ - const styles = document.createElement('link'); - styles.setAttribute('rel', 'stylesheet'); - styles.setAttribute('href', removeLastTwoComponents(getCurrentScriptPath()) + '/css/ref-competences.css'); + /* Style du module */ + const styles = document.createElement("link"); + styles.setAttribute("rel", "stylesheet"); + styles.setAttribute( + "href", + removeLastTwoComponents(getCurrentScriptPath()) + + "/css/ref-competences.css" + ); - this.shadow.appendChild(styles); - } + this.shadow.appendChild(styles); + } - set setData(data) { - this.data = data; - this.parcours(); - } + set setData(data) { + this.data = data; + this.parcours(); + } - parcours() { - let parcoursDIV = this.shadow.querySelector(".parcours"); - Object.entries(this.data.parcours).forEach(([cle, parcours]) => { - let div = document.createElement("div"); - div.innerHTML = `${parcours.code}`; - div.addEventListener("click", (event) => { this.competences(event, cle) }) - parcoursDIV.appendChild(div); - }) - this.initCompetences(); - } + parcours() { + let parcoursDIV = this.shadow.querySelector(".parcours"); + Object.entries(this.data.parcours).forEach(([cle, parcours]) => { + let div = document.createElement("div"); + div.innerHTML = `${parcours.code}`; + div.addEventListener("click", (event) => { + this.competences(event, cle); + }); + parcoursDIV.appendChild(div); + }); + this.initCompetences(); + } - initCompetences() { - this.competencesNumber = {}; - let i = 0; - Object.keys(this.data.competences).forEach(competence => { - this.competencesNumber[competence] = 1 + i++ % 6; - }) - } + initCompetences() { + this.competencesNumber = {}; + let i = 0; + Object.keys(this.data.competences).forEach((competence) => { + this.competencesNumber[competence] = 1 + (i++ % 6); + }); + } - competences(event, cle) { - this.shadow.querySelector(".parcours>.focus")?.classList.remove("focus"); - event.currentTarget.classList.add("focus"); - let divCompetences = this.shadow.querySelector(".competences"); + competences(event, cle) { + this.shadow.querySelector(".parcours>.focus")?.classList.remove("focus"); + event.currentTarget.classList.add("focus"); + let divCompetences = this.shadow.querySelector(".competences"); - this.shadow.querySelector(".competences").innerHTML = ""; + this.shadow.querySelector(".competences").innerHTML = ""; - /* Création des compétences */ - let competencesBucket = []; - Object.entries(this.data.parcours[cle].annees).forEach(([annee, dataAnnee]) => { - Object.entries(dataAnnee.competences).forEach(([competence, niveauCle]) => { - let numComp = this.competencesNumber[competence]; - let divCompetence = document.createElement("div"); - divCompetence.innerText = `${competence} ${niveauCle.niveau}`; - divCompetence.style.gridRowStart = annee; - divCompetence.style.gridColumnStart = competence.replaceAll(" ", "_"); - divCompetence.className = "comp" + numComp; - divCompetence.dataset.competence = `${competence} ${niveauCle.niveau}`; - divCompetence.addEventListener("click", (event) => { this.AC(event, competence, niveauCle.niveau, annee, numComp) }) - divCompetences.appendChild(divCompetence); + /* Création des compétences */ + let competencesBucket = []; + Object.entries(this.data.parcours[cle].annees).forEach( + ([annee, dataAnnee]) => { + Object.entries(dataAnnee.competences).forEach( + ([competence, niveauCle]) => { + let numComp = this.competencesNumber[competence]; + let divCompetence = document.createElement("div"); + divCompetence.innerText = `${competence} ${niveauCle.niveau}`; + divCompetence.style.gridRowStart = annee; + divCompetence.style.gridColumnStart = competence.replaceAll( + " ", + "_" + ); + divCompetence.className = "comp" + numComp; + divCompetence.dataset.competence = `${competence} ${niveauCle.niveau}`; + divCompetence.addEventListener("click", (event) => { + this.AC(event, competence, niveauCle.niveau, annee, numComp); + }); + divCompetences.appendChild(divCompetence); - competencesBucket.push(competence); - }) - }) + competencesBucket.push(competence); + } + ); + } + ); - /* Affectation de la taille des éléments */ - //divCompetences.style.setProperty("--competence-size", `calc(${100 / competencesBucket.length}% )`); - let gridTemplate = ""; - Object.keys(this.data.competences).forEach(competence => { - if (competencesBucket.indexOf(competence) == -1) { - gridTemplate += `[${competence.replaceAll(" ", "_")}] 0`; - } else { - gridTemplate += `[${competence.replaceAll(" ", "_")}] 1fr`; - } - }) - this.shadow.querySelector(".competences").style.gridTemplateColumns = gridTemplate; + /* Affectation de la taille des éléments */ + //divCompetences.style.setProperty("--competence-size", `calc(${100 / competencesBucket.length}% )`); + let gridTemplate = ""; + Object.keys(this.data.competences).forEach((competence) => { + if (competencesBucket.indexOf(competence) == -1) { + gridTemplate += `[${competence.replaceAll(" ", "_")}] 0`; + } else { + gridTemplate += `[${competence.replaceAll(" ", "_")}] 1fr`; + } + }); + this.shadow.querySelector(".competences").style.gridTemplateColumns = + gridTemplate; - /* Réaffectation des focus */ - this.shadow.querySelectorAll(".AC").forEach(ac => { - this.shadow.querySelector(`[data-competence="${ac.dataset.competence}"]`).classList.add("focus"); - }); - } + /* Réaffectation des focus */ + this.shadow.querySelectorAll(".AC").forEach((ac) => { + this.shadow + .querySelector(`[data-competence="${ac.dataset.competence}"]`) + .classList.add("focus"); + }); + } - AC(event, competence, niveau, annee, numComp) { - event.currentTarget.classList.toggle("focus"); - if (this.shadow.querySelector(`.ACs [data-competence="${competence} ${niveau}"]`)) { - this.shadow.querySelector(`.ACs [data-competence="${competence} ${niveau}"]`).remove(); - } else { - let output = ` + AC(event, competence, niveau, annee, numComp) { + event.currentTarget.classList.toggle("focus"); + if ( + this.shadow.querySelector( + `.ACs [data-competence="${competence} ${niveau}"]` + ) + ) { + this.shadow + .querySelector(`.ACs [data-competence="${competence} ${niveau}"]`) + .remove(); + } else { + let output = ` "; - } - } + Object.entries( + this.data.competences[competence].niveaux["BUT" + annee].app_critiques + ).forEach(([num, contenu]) => { + output += `
  • ${num}
    ${contenu.libelle}
  • `; + }); + this.shadow.querySelector(".ACs").innerHTML += output + ""; + } + } } -customElements.define('ref-competences', ref_competences); \ No newline at end of file +customElements.define("ref-competences", ref_competences); diff --git a/app/static/js/releve-but.js b/app/static/js/releve-but.js index e011d395..d76ec535 100644 --- a/app/static/js/releve-but.js +++ b/app/static/js/releve-but.js @@ -74,10 +74,10 @@ class releveBUT extends HTMLElement { template() { return ` -
    +
    - + @@ -99,7 +99,7 @@ class releveBUT extends HTMLElement { Les moyennes ci-dessus servent à situer l'étudiant dans la promotion et ne correspondent pas à des validations de compétences ou d'UE.
    - + @@ -181,7 +181,7 @@ class releveBUT extends HTMLElement { output += `
    - Numéro étudiant : ${data.etudiant.code_nip || "~"} - + Numéro étudiant : ${data.etudiant.code_nip || "~"} - Code INE : ${data.etudiant.code_ine || "~"}
    ${data.formation.titre}
    @@ -376,12 +376,14 @@ class releveBUT extends HTMLElement { }
    `; if (!dataUE.date_capitalisation) { - output += ` Bonus : ${dataUE.bonus || 0} - `; - if(dataUE.malus >= 0) { - output += `Malus : ${dataUE.malus || 0}`; - } else { - output += `Bonus complémentaire : ${-dataUE.malus || 0}`; - } + output += ` Bonus : ${dataUE.bonus || 0} - `; + if (dataUE.malus >= 0) { + output += `Malus : ${dataUE.malus || 0}`; + } else { + output += `Bonus complémentaire : ${ + -dataUE.malus || 0 + }`; + } } else { output += ` le ${this.ISOToDate( dataUE.date_capitalisation.split("T")[0] @@ -468,9 +470,9 @@ class releveBUT extends HTMLElement { content.moyenne.value }
    - Classe : ${content.moyenne.moy} - + Classe : ${content.moyenne.moy} - Max : ${content.moyenne.max} - - Min : ${content.moyenne.min} + Min : ${content.moyenne.min}
    diff --git a/app/static/js/sco_ue_external.js b/app/static/js/sco_ue_external.js index fb57807f..e6381555 100644 --- a/app/static/js/sco_ue_external.js +++ b/app/static/js/sco_ue_external.js @@ -1,33 +1,28 @@ // Gestion formulaire UE externes function toggle_new_ue_form(state) { - // active/desactive le formulaire "nouvelle UE" - var text_color; - if (state) { - text_color = 'rgb(180,160,160)'; - } else { - text_color = 'rgb(0,0,0)'; - } + // active/desactive le formulaire "nouvelle UE" + var text_color; + if (state) { + text_color = "rgb(180,160,160)"; + } else { + text_color = "rgb(0,0,0)"; + } - $("#tf_extue_titre td:eq(1) input").prop("disabled", state); - $("#tf_extue_titre").css('color', text_color) + $("#tf_extue_titre td:eq(1) input").prop("disabled", state); + $("#tf_extue_titre").css("color", text_color); - $("#tf_extue_acronyme td:eq(1) input").prop("disabled", state); - $("#tf_extue_acronyme").css('color', text_color) + $("#tf_extue_acronyme td:eq(1) input").prop("disabled", state); + $("#tf_extue_acronyme").css("color", text_color); - $("#tf_extue_type td:eq(1) select").prop("disabled", state); - $("#tf_extue_type").css('color', text_color) + $("#tf_extue_type td:eq(1) select").prop("disabled", state); + $("#tf_extue_type").css("color", text_color); - $("#tf_extue_ects td:eq(1) input").prop("disabled", state); - $("#tf_extue_ects").css('color', text_color) + $("#tf_extue_ects td:eq(1) input").prop("disabled", state); + $("#tf_extue_ects").css("color", text_color); } - function update_external_ue_form() { - var state = (tf.existing_ue.value != ""); - toggle_new_ue_form(state); + var state = tf.existing_ue.value != ""; + toggle_new_ue_form(state); } - - - - diff --git a/app/static/js/scolar_index.js b/app/static/js/scolar_index.js index 90c20b45..9b75eb0d 100644 --- a/app/static/js/scolar_index.js +++ b/app/static/js/scolar_index.js @@ -4,30 +4,35 @@ var elt_annee_apo_editor = null; var elt_sem_apo_editor = null; $(document).ready(function () { - var table_options = { - "paging": false, - "searching": false, - "info": false, - /* "autoWidth" : false, */ - "fixedHeader": { - "header": true, - "footer": true - }, - "orderCellsTop": true, // cellules ligne 1 pour tri - "aaSorting": [], // Prevent initial sorting - }; - $('table.semlist').DataTable(table_options); - let table_editable = document.querySelector("table#semlist.apo_editable"); - if (table_editable) { - let save_url = document.querySelector("table#semlist.apo_editable").dataset.apo_save_url; - apo_editor = new ScoFieldEditor(".etapes_apo_str", save_url, false); + var table_options = { + paging: false, + searching: false, + info: false, + /* "autoWidth" : false, */ + fixedHeader: { + header: true, + footer: true, + }, + orderCellsTop: true, // cellules ligne 1 pour tri + aaSorting: [], // Prevent initial sorting + }; + $("table.semlist").DataTable(table_options); + let table_editable = document.querySelector("table#semlist.apo_editable"); + if (table_editable) { + let save_url = document.querySelector("table#semlist.apo_editable").dataset + .apo_save_url; + apo_editor = new ScoFieldEditor(".etapes_apo_str", save_url, false); - save_url = document.querySelector("table#semlist.apo_editable").dataset.elt_annee_apo_save_url; - elt_annee_apo_editor = new ScoFieldEditor(".elt_annee_apo", save_url, false); + save_url = document.querySelector("table#semlist.apo_editable").dataset + .elt_annee_apo_save_url; + elt_annee_apo_editor = new ScoFieldEditor( + ".elt_annee_apo", + save_url, + false + ); - save_url = document.querySelector("table#semlist.apo_editable").dataset.elt_sem_apo_save_url; - elt_sem_apo_editor = new ScoFieldEditor(".elt_sem_apo", save_url, false); - } + save_url = document.querySelector("table#semlist.apo_editable").dataset + .elt_sem_apo_save_url; + elt_sem_apo_editor = new ScoFieldEditor(".elt_sem_apo", save_url, false); + } }); - - diff --git a/app/static/js/table_editor.js b/app/static/js/table_editor.js index 603e0792..18b4bd68 100644 --- a/app/static/js/table_editor.js +++ b/app/static/js/table_editor.js @@ -8,14 +8,14 @@ let lastX; let lastY; function build_table(data) { - let output = ""; - let sumsUE = {}; - let sumsRessources = {}; - let value; + let output = ""; + let sumsUE = {}; + let sumsRessources = {}; + let value; - data.forEach((cellule) => { - output += ` -
    { + output += ` +
    ${cellule.data}
    `; // ne pas mettre d'espace car c'est utilisé par :not(:empty) après - if (cellule.style.includes("champs")) { - if (cellule.editable == true && cellule.data) { - value = parseFloat(cellule.data) * 100; - } else { - value = 0; - } - sumsRessources[cellule.y] = (sumsRessources[cellule.y] ?? 0) + value; - sumsUE[cellule.x] = (sumsUE[cellule.x] ?? 0) + value; - } - }) + if (cellule.style.includes("champs")) { + if (cellule.editable == true && cellule.data) { + value = parseFloat(cellule.data) * 100; + } else { + value = 0; + } + sumsRessources[cellule.y] = (sumsRessources[cellule.y] ?? 0) + value; + sumsUE[cellule.x] = (sumsUE[cellule.x] ?? 0) + value; + } + }); - output += showSums(sumsRessources, sumsUE); - document.querySelector(".tableau").innerHTML = output; - installListeners(); + output += showSums(sumsRessources, sumsUE); + document.querySelector(".tableau").innerHTML = output; + installListeners(); } function showSums(sumsRessources, sumsUE) { - lastX = Object.keys(sumsUE).length + 2; - lastY = Object.keys(sumsRessources).length + 2; + lastX = Object.keys(sumsUE).length + 2; + lastY = Object.keys(sumsRessources).length + 2; - let output = ""; + let output = ""; - Object.entries(sumsUE).forEach(([num, value]) => { - output += ` -
    { + output += ` +
    ${value / 100}
    `; - }) + }); - Object.entries(sumsRessources).forEach(([num, value]) => { - output += ` -
    { + output += ` +
    ${value / 100}
    `; - }) + }); - return output; + return output; } /*****************************/ @@ -98,125 +98,158 @@ function showSums(sumsRessources, sumsUE) { /*****************************/ function installListeners() { - if (read_only) { - return; - } - document.body.addEventListener("keydown", key); - document.querySelectorAll("[data-editable=true]").forEach(cellule => { - cellule.addEventListener("click", function () { selectCell(this) }); - cellule.addEventListener("dblclick", function () { modifCell(this) }); - cellule.addEventListener("blur", function () { - let currentModif = document.querySelector(".modifying"); - if (currentModif) { - if (!save(currentModif)) { - return; - } - } - }); - cellule.addEventListener("input", processSums); + if (read_only) { + return; + } + document.body.addEventListener("keydown", key); + document.querySelectorAll("[data-editable=true]").forEach((cellule) => { + cellule.addEventListener("click", function () { + selectCell(this); }); + cellule.addEventListener("dblclick", function () { + modifCell(this); + }); + cellule.addEventListener("blur", function () { + let currentModif = document.querySelector(".modifying"); + if (currentModif) { + if (!save(currentModif)) { + return; + } + } + }); + cellule.addEventListener("input", processSums); + }); } - /*********************************/ /* Interaction avec les cellules */ /*********************************/ function selectCell(obj) { - if (obj.classList.contains("modifying")) { - return; // Cellule en cours de modification, ne pas sélectionner. - } - let currentModif = document.querySelector(".modifying"); - if (currentModif) { - if (!save(currentModif)) { - return; - } + if (obj.classList.contains("modifying")) { + return; // Cellule en cours de modification, ne pas sélectionner. + } + let currentModif = document.querySelector(".modifying"); + if (currentModif) { + if (!save(currentModif)) { + return; } + } - document.querySelectorAll(".selected, .modifying").forEach(cellule => { - cellule.classList.remove("selected", "modifying"); - cellule.removeAttribute("contentEditable"); - cellule.removeEventListener("keydown", keyCell); - }) - obj.classList.add("selected"); + document.querySelectorAll(".selected, .modifying").forEach((cellule) => { + cellule.classList.remove("selected", "modifying"); + cellule.removeAttribute("contentEditable"); + cellule.removeEventListener("keydown", keyCell); + }); + obj.classList.add("selected"); } function modifCell(obj) { - if (obj) { - obj.classList.add("modifying"); - obj.contentEditable = true; - obj.addEventListener("keydown", keyCell); - obj.focus(); - } + if (obj) { + obj.classList.add("modifying"); + obj.contentEditable = true; + obj.addEventListener("keydown", keyCell); + obj.focus(); + } } function key(event) { - switch (event.key) { - case "Enter": modifCell(document.querySelector(".selected")); event.preventDefault(); break; - case "ArrowRight": ArrowMove(1, 0); break; - case "ArrowLeft": ArrowMove(-1, 0); break; - case "ArrowUp": ArrowMove(0, -1); break; - case "ArrowDown": ArrowMove(0, 1); break; - } + switch (event.key) { + case "Enter": + modifCell(document.querySelector(".selected")); + event.preventDefault(); + break; + case "ArrowRight": + ArrowMove(1, 0); + break; + case "ArrowLeft": + ArrowMove(-1, 0); + break; + case "ArrowUp": + ArrowMove(0, -1); + break; + case "ArrowDown": + ArrowMove(0, 1); + break; + } } function ArrowMove(x, y) { - if (document.querySelector(".modifying") || !document.querySelector(".selected")) { - return; // S'il n'y a aucune cellule selectionnée ou si une cellule est encours de modification, on ne change pas - } + if ( + document.querySelector(".modifying") || + !document.querySelector(".selected") + ) { + return; // S'il n'y a aucune cellule selectionnée ou si une cellule est encours de modification, on ne change pas + } - let selected = document.querySelector(".selected"); - let next = document.querySelector(`[data-x="${parseInt(selected.dataset.x) + x}"][data-y="${parseInt(selected.dataset.y) + y}"][data-editable="true"]`); + let selected = document.querySelector(".selected"); + let next = document.querySelector( + `[data-x="${parseInt(selected.dataset.x) + x}"][data-y="${ + parseInt(selected.dataset.y) + y + }"][data-editable="true"]` + ); - if (next) { - selectCell(next); - } + if (next) { + selectCell(next); + } } function keyCell(event) { - if (event.key == "Enter") { - event.preventDefault(); - event.stopPropagation(); - if (!save(this)) { - return - } - this.classList.remove("modifying"); - let selected = document.querySelector(".selected"); - ArrowMove(0, 1); - if (selected != document.querySelector(".selected")) { - modifCell(document.querySelector(".selected")); - } + if (event.key == "Enter") { + event.preventDefault(); + event.stopPropagation(); + if (!save(this)) { + return; } + this.classList.remove("modifying"); + let selected = document.querySelector(".selected"); + ArrowMove(0, 1); + if (selected != document.querySelector(".selected")) { + modifCell(document.querySelector(".selected")); + } + } } function processSums() { - let sum = 0; - document.querySelectorAll(`[data-editable="true"][data-x="${this.dataset.x}"]:not(:empty)`).forEach(e => { - let val = parseFloat(e.innerText); - if (!isNaN(val)) { - sum += val * 100; - } - }) - document.querySelector(`.sums[data-x="${this.dataset.x}"][data-y="${lastY}"]`).innerText = sum / 100; + let sum = 0; + document + .querySelectorAll( + `[data-editable="true"][data-x="${this.dataset.x}"]:not(:empty)` + ) + .forEach((e) => { + let val = parseFloat(e.innerText); + if (!isNaN(val)) { + sum += val * 100; + } + }); + document.querySelector( + `.sums[data-x="${this.dataset.x}"][data-y="${lastY}"]` + ).innerText = sum / 100; - sum = 0; - document.querySelectorAll(`[data-editable="true"][data-y="${this.dataset.y}"]:not(:empty)`).forEach(e => { - let val = parseFloat(e.innerText); - if (!isNaN(val)) { - sum += val * 100; - } - }) - document.querySelector(`.sums[data-x="${lastX}"][data-y="${this.dataset.y}"]`).innerText = sum / 100; + sum = 0; + document + .querySelectorAll( + `[data-editable="true"][data-y="${this.dataset.y}"]:not(:empty)` + ) + .forEach((e) => { + let val = parseFloat(e.innerText); + if (!isNaN(val)) { + sum += val * 100; + } + }); + document.querySelector( + `.sums[data-x="${lastX}"][data-y="${this.dataset.y}"]` + ).innerText = sum / 100; } /******************************/ /* Affichage d'un message */ /******************************/ function message(msg) { - var div = document.createElement("div"); - div.className = "message"; - div.innerHTML = msg; - document.querySelector("body").appendChild(div); - setTimeout(() => { - div.remove(); - }, 3000); + var div = document.createElement("div"); + div.className = "message"; + div.innerHTML = msg; + document.querySelector("body").appendChild(div); + setTimeout(() => { + div.remove(); + }, 3000); } diff --git a/app/static/js/trombino.js b/app/static/js/trombino.js index c6a560bc..f6bf989d 100644 --- a/app/static/js/trombino.js +++ b/app/static/js/trombino.js @@ -1,11 +1,10 @@ // Affichage progressif du trombinoscope html $().ready(function () { - var spans = $(".unloaded_img"); - for (var i = 0; i < spans.size(); i++) { - var sp = spans[i]; - var etudid = sp.id; - $(sp).load(SCO_URL + "/etud_photo_html?etudid=" + etudid); - } + var spans = $(".unloaded_img"); + for (var i = 0; i < spans.size(); i++) { + var sp = spans[i]; + var etudid = sp.id; + $(sp).load(SCO_URL + "/etud_photo_html?etudid=" + etudid); + } }); - diff --git a/app/static/js/ue_list.js b/app/static/js/ue_list.js index f6e9ea75..35e79ac6 100644 --- a/app/static/js/ue_list.js +++ b/app/static/js/ue_list.js @@ -1,5 +1,5 @@ // Edition elements programme "en place" -$(function() { - $('.span_apo_edit').jinplace(); -}); \ No newline at end of file +$(function () { + $(".span_apo_edit").jinplace(); +}); diff --git a/app/static/js/user_form.js b/app/static/js/user_form.js index 4ad06672..c9261790 100644 --- a/app/static/js/user_form.js +++ b/app/static/js/user_form.js @@ -1,30 +1,30 @@ - function refresh() { - if ($("input[name='welcome:list']").is(":checked")) { - $("input[name='reset_password:list']").closest("tr").css("display", "table-row") - if ($("input[name='reset_password:list']").is(":checked")) { - $("#tf_password").closest('tr').css("display", "none"); - $("#tf_password2").closest('tr').css("display", "none"); - } else { - // Le mot de passe doit être saisi - $("#tf_password").closest('tr').css("display", "table-row"); - $("#tf_password2").closest('tr').css("display", "table-row"); - } + if ($("input[name='welcome:list']").is(":checked")) { + $("input[name='reset_password:list']") + .closest("tr") + .css("display", "table-row"); + if ($("input[name='reset_password:list']").is(":checked")) { + $("#tf_password").closest("tr").css("display", "none"); + $("#tf_password2").closest("tr").css("display", "none"); } else { - // Le mot de passe doit être saisi - $("input[name='reset_password:list']").closest("tr").css("display", "none") - $("#tf_password").closest('tr').css("display", "table-row"); - $("#tf_password2").closest('tr').css("display", "table-row"); + // Le mot de passe doit être saisi + $("#tf_password").closest("tr").css("display", "table-row"); + $("#tf_password2").closest("tr").css("display", "table-row"); } + } else { + // Le mot de passe doit être saisi + $("input[name='reset_password:list']").closest("tr").css("display", "none"); + $("#tf_password").closest("tr").css("display", "table-row"); + $("#tf_password2").closest("tr").css("display", "table-row"); + } } $(function () { - $("input[name='welcome:list']").click(function () { - refresh(); - }) - $("input[name='reset_password:list']").click(function () { - refresh(); - }) + $("input[name='welcome:list']").click(function () { refresh(); -}) - + }); + $("input[name='reset_password:list']").click(function () { + refresh(); + }); + refresh(); +}); diff --git a/sco_version.py b/sco_version.py index 5be4f774..67d9697b 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.55" +SCOVERSION = "9.6.56" SCONAME = "ScoDoc"