From bbc3bbc7010550a0980d186ba956635de237e7ba Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 14 Jan 2025 20:18:29 +0100 Subject: [PATCH] =?UTF-8?q?Page=20accueil=20dept:=20d=C3=A9sactive=20s?= =?UTF-8?q?=C3=A9lection=20semestres=20si=20pas=20admin.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/scolar_index.js | 88 ++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/app/static/js/scolar_index.js b/app/static/js/scolar_index.js index 0a5e2eb16..640c093be 100644 --- a/app/static/js/scolar_index.js +++ b/app/static/js/scolar_index.js @@ -18,51 +18,53 @@ $(document).ready(function () { }; const table = new DataTable("table.semlist", table_options); // Sélection de semestres et mise à jour du menu associé - table.on('click', 'tbody tr', function (e) { - e.currentTarget.classList.toggle('selected'); - var nbSelectedRows = table.rows('.selected').count(); - if (nbSelectedRows == 0) { - document.getElementById("formsemestres-select-infos").style.display = 'none'; - } - else { - document.getElementById("formsemestres-select-infos").style.display = 'inline'; - if (nbSelectedRows > 1) { - document.querySelector("#formsemestres-select-menu li.sco_menu_title a").childNodes[1].nodeValue = nbSelectedRows + " semestres sélectionnés"; - } else { - document.querySelector("#formsemestres-select-menu li.sco_menu_title a").childNodes[1].nodeValue = nbSelectedRows + " semestre sélectionné"; + if (document.getElementById("formsemestres-select-infos")) { + table.on('click', 'tbody tr', function (e) { + e.currentTarget.classList.toggle('selected'); + var nbSelectedRows = table.rows('.selected').count(); + if (nbSelectedRows == 0) { + document.getElementById("formsemestres-select-infos").style.display = 'none'; + } + else { + document.getElementById("formsemestres-select-infos").style.display = 'inline'; + if (nbSelectedRows > 1) { + document.querySelector("#formsemestres-select-menu li.sco_menu_title a").childNodes[1].nodeValue = nbSelectedRows + " semestres sélectionnés"; + } else { + document.querySelector("#formsemestres-select-menu li.sco_menu_title a").childNodes[1].nodeValue = nbSelectedRows + " semestre sélectionné"; + } } - } - }); - // Lien déselectionner - document.getElementById("formsemestres-deselect").addEventListener('click', function (e) { - e.preventDefault(); - table.rows('.selected').nodes().to$().removeClass('selected'); - document.getElementById("formsemestres-select-infos").style.display = 'none'; - }); - // Modification des liens de la section formsemestres-actions: ajout des formsemestres selectionnés: - const links = document.querySelectorAll('#formsemestres-select-menu li.sco_menu_item a'); - links.forEach(link => { - link.addEventListener('click', function(event) { - // Prevent the default action (navigation) - event.preventDefault(); - - // Build the query string with formsemestre_id parameters - const selectedRows = document.querySelectorAll('tr.selected'); - const selectedFormsemestreIds = Array.from(selectedRows).map(row => row.dataset.formsemestre_id); - const queryString = selectedFormsemestreIds - .map(id => `formsemestre_ids=${encodeURIComponent(id)}`) - .join('&'); - - // Construct the new URL - const originalHref = link.getAttribute('href'); - const newHref = originalHref.includes('?') - ? `${originalHref}&${queryString}` // If there's already a query string - : `${originalHref}?${queryString}`; // If no query string exists - - // Navigate to the new URL - window.location.href = newHref; }); - }); + // Lien déselectionner + document.getElementById("formsemestres-deselect").addEventListener('click', function (e) { + e.preventDefault(); + table.rows('.selected').nodes().to$().removeClass('selected'); + document.getElementById("formsemestres-select-infos").style.display = 'none'; + }); + // Modification des liens de la section formsemestres-actions: ajout des formsemestres selectionnés: + const links = document.querySelectorAll('#formsemestres-select-menu li.sco_menu_item a'); + links.forEach(link => { + link.addEventListener('click', function(event) { + // Prevent the default action (navigation) + event.preventDefault(); + + // Build the query string with formsemestre_id parameters + const selectedRows = document.querySelectorAll('tr.selected'); + const selectedFormsemestreIds = Array.from(selectedRows).map(row => row.dataset.formsemestre_id); + const queryString = selectedFormsemestreIds + .map(id => `formsemestre_ids=${encodeURIComponent(id)}`) + .join('&'); + + // Construct the new URL + const originalHref = link.getAttribute('href'); + const newHref = originalHref.includes('?') + ? `${originalHref}&${queryString}` // If there's already a query string + : `${originalHref}?${queryString}`; // If no query string exists + + // Navigate to the new URL + window.location.href = newHref; + }); + }); + } // Edition des codes Apo let table_editable = document.querySelector("table#semlist.apo_editable");