Page accueil dept: désactive sélection semestres si pas admin.

This commit is contained in:
Emmanuel Viennet 2025-01-14 20:18:29 +01:00
parent 867575ac78
commit bbc3bbc701

View File

@ -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");