Filtres + affectation non affectés

This commit is contained in:
Sébastien Lehmann 2023-01-08 20:39:26 +01:00
parent 28813237f2
commit 7038685843
2 changed files with 29 additions and 26 deletions

View File

@ -338,7 +338,7 @@ body.editionActivated .filtres .nonEditable .move{
}
.filtres .unselect {
background: rgba(0, 153, 204, 0.5);
background: rgba(0, 153, 204, 0.5) !important;
}
/*****************************/
@ -353,7 +353,7 @@ body.editionActivated .filtres .nonEditable .move{
}
#zoneChoix>.autoAffectation>select{
border: none;
padding: 4px 16px;
padding: 4px;
border-radius: 4px;
}
#zoneChoix>.autoAffectation>.affectationGo{

View File

@ -227,9 +227,11 @@
document.querySelectorAll('#zonePartitions .filtres>div').forEach(partition => {
output += `<optgroup label="${partition.children[0].children[1].innerText}">`;
output += `
<optgroup label="${partition.children[0].children[1].innerText}">
<option value="non-${partition.dataset.idpartition}">Non affectés ${partition.children[0].children[1].innerText}</option>`;
partition.querySelectorAll('[data-idgroupe]:not([data-idgroupe="aucun"])').forEach(groupe => {
output += `<option value=${groupe.dataset.idgroupe}>${groupe.innerText}</option>`;
output += `<option value=${groupe.dataset.idgroupe}>${groupe.children[1].innerText}</option>`;
})
output += "</optgroup>";
@ -301,28 +303,11 @@
})
}
/*if (!this.dataset.idgroupe) {
// Partitions
let groupesSelected = [];
this.parentElement.querySelectorAll(":not(.unselect)").forEach(e => {
groupesSelected.push(e.dataset.idpartition);
})
document.querySelectorAll(`
.etudiants .partition[data-idpartition],
#zoneGroupes [data-idpartition]
`).forEach(e => {
if (groupesSelected.includes(e.dataset.idpartition)) {
e.classList.remove("hide")
} else {
e.classList.add("hide")
}
})
} else {*/
// Groupes
let groupesSelected = {};
this.parentElement.parentElement.querySelectorAll("[data-idgroupe]:not(.unselect)").forEach(e => {
let idpartition = e.parentElement.dataset.idpartition;
document.querySelectorAll(".filtres [data-idgroupe]:not(.unselect)").forEach(e => {
let idpartition = e.closest("[data-idpartition]").dataset.idpartition;
if (!groupesSelected[idpartition]) {
groupesSelected[idpartition] = [];
}
@ -345,7 +330,6 @@
e.classList.add("hide")
}
})
//}
}
/****************************/
/* Affectation à un groupe */
@ -358,8 +342,27 @@
return;
}
document.querySelectorAll(`#zoneChoix .etudiants [value="${from}"]:checked`).forEach(groupeSelected=>{
let elements = [];
if(from[0] != "n"){
elements = document.querySelectorAll(`#zoneChoix .etudiants [value="${from}"]:checked`)
} else {
document.querySelectorAll(`#zoneChoix .etudiants [data-idpartition="${from.split("-")[1]}"]`).forEach(element=>{
if(!element.querySelector('input:not([value="aucun"]):checked')){
elements.push(element);
}
})
}
console.log(elements);
elements.forEach(groupeSelected=>{
if(to[0] != "n"){
groupeSelected.closest(".grpPartitions").querySelector(`[value="${to}"]`).click();
}else{
groupeSelected.closest(".grpPartitions").querySelector(".aucun").click();
}
})
}
function assignment() {