From d5a6ba74486d0c7a1efb3a0ab9ac9b6880b8e15a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 12 May 2023 10:00:11 +0200 Subject: [PATCH] Fix JS access to css --- app/static/js/ref_competences.js | 23 --------- app/static/js/releve-but.js | 18 ++++---- app/static/js/scodoc.js | 24 ++++++++++ app/templates/but/bulletin.j2 | 77 +++++++++++++++++-------------- app/templates/but/refcomp_show.j2 | 4 +- 5 files changed, 77 insertions(+), 69 deletions(-) diff --git a/app/static/js/ref_competences.js b/app/static/js/ref_competences.js index 892f5163..32b9f9db 100644 --- a/app/static/js/ref_competences.js +++ b/app/static/js/ref_competences.js @@ -1,27 +1,4 @@ -function getCurrentScriptPath() { - // Get all the script elements on the page - var scripts = document.getElementsByTagName('script'); - // Find the last script element (which is the currently executing script) - var currentScript = scripts[scripts.length - 1]; - - // Retrieve the src attribute of the script element - var scriptPath = currentScript.src; - - return scriptPath; -} -function removeLastTwoComponents(path) { - // Split the path into individual components - var components = path.split('/'); - - // Remove the last two components (filename and enclosing directory) - components.splice(-2); - - // Join the remaining components back into a path - var newPath = components.join('/'); - - return newPath; -} class ref_competences extends HTMLElement { constructor() { super(); diff --git a/app/static/js/releve-but.js b/app/static/js/releve-but.js index 5304e05d..c1fac211 100644 --- a/app/static/js/releve-but.js +++ b/app/static/js/releve-but.js @@ -15,8 +15,8 @@ class releveBUT extends HTMLElement { /* Style du module */ const styles = document.createElement('link'); styles.setAttribute('rel', 'stylesheet'); - if (location.href.split("/")[3] == "ScoDoc") { - styles.setAttribute('href', '/ScoDoc/static/css/releve-but.css'); // Scodoc + if (location.href.includes("ScoDoc")) { + styles.setAttribute('href', removeLastTwoComponents(getCurrentScriptPath()) + '/css/releve-but.css'); // Scodoc } else { styles.setAttribute('href', '/assets/styles/releve-but.css'); // Passerelle } @@ -212,8 +212,8 @@ class releveBUT extends HTMLElement { this.shadow.querySelector("#identite_etudiant").innerHTML = ` ${data.etudiant.nomprenom} `; this.shadow.querySelector(".dateInscription").innerHTML += this.ISOToDate(data.semestre.inscription); let output = ''; - if(!data.options.block_moyenne_generale){ - output += ` + if (!data.options.block_moyenne_generale) { + output += `
Moyenne
${data.semestre.notes.value}
Rang :
${data.semestre.rang.value} / ${data.semestre.rang.total}
@@ -333,7 +333,7 @@ class releveBUT extends HTMLElement { } else { output += `
-
+

${ue}${(dataUE.titre) ? " - " + dataUE.titre : ""}

@@ -341,7 +341,7 @@ class releveBUT extends HTMLElement {
Moyenne : ${dataUE.moyenne?.value || dataUE.moyenne || "-"}
Rang : ${dataUE.moyenne?.rang} / ${dataUE.moyenne?.total}
`; - if(!dataUE.date_capitalisation){ + if (!dataUE.date_capitalisation) { output += ` Bonus : ${dataUE.bonus || 0} - Malus : ${dataUE.malus || 0}`; } else { @@ -359,12 +359,12 @@ class releveBUT extends HTMLElement {
*/ output += "
"; - if(!dataUE.date_capitalisation){ - output += + if (!dataUE.date_capitalisation) { + output += this.synthese(data, dataUE.ressources) + this.synthese(data, dataUE.saes); } - + output += "
"; } }); diff --git a/app/static/js/scodoc.js b/app/static/js/scodoc.js index efd6e943..40ada69d 100644 --- a/app/static/js/scodoc.js +++ b/app/static/js/scodoc.js @@ -256,3 +256,27 @@ class ScoFieldEditor { } } +function getCurrentScriptPath() { + // Get all the script elements on the page + var scripts = document.getElementsByTagName('script'); + + // Find the last script element (which is the currently executing script) + var currentScript = scripts[scripts.length - 1]; + + // Retrieve the src attribute of the script element + var scriptPath = currentScript.src; + + return scriptPath; +} +function removeLastTwoComponents(path) { + // Split the path into individual components + var components = path.split('/'); + + // Remove the last two components (filename and enclosing directory) + components.splice(-2); + + // Join the remaining components back into a path + var newPath = components.join('/'); + + return newPath; +} diff --git a/app/templates/but/bulletin.j2 b/app/templates/but/bulletin.j2 index ddf337b3..221e56fb 100644 --- a/app/templates/but/bulletin.j2 +++ b/app/templates/but/bulletin.j2 @@ -7,43 +7,50 @@ {% block app_content %} -{% include 'bul_head.j2' %} + {% include 'bul_head.j2' %} - - + -{% include 'bul_foot.j2' %} + {% include 'bul_foot.j2' %} - -{% endblock %} \ No newline at end of file + + + + +{% endblock %} diff --git a/app/templates/but/refcomp_show.j2 b/app/templates/but/refcomp_show.j2 index 5b69da1f..7ccc0372 100644 --- a/app/templates/but/refcomp_show.j2 +++ b/app/templates/but/refcomp_show.j2 @@ -19,8 +19,6 @@
- - {% include "but/refcomp_parcours_niveaux.j2" %} @@ -49,6 +47,8 @@ {% block scripts %} {{super()}} + +