Merge pull request 'Filtres + affectation non affectés' (#549) from lehmann/ScoDoc-Front:master into master

Reviewed-on: https://scodoc.org/git/ScoDoc/ScoDoc/pulls/549
This commit is contained in:
Emmanuel Viennet 2023-01-08 23:28:09 +01:00
commit a5f82dec18
2 changed files with 29 additions and 26 deletions

View File

@ -338,7 +338,7 @@ body.editionActivated .filtres .nonEditable .move{
} }
.filtres .unselect { .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{ #zoneChoix>.autoAffectation>select{
border: none; border: none;
padding: 4px 16px; padding: 4px;
border-radius: 4px; border-radius: 4px;
} }
#zoneChoix>.autoAffectation>.affectationGo{ #zoneChoix>.autoAffectation>.affectationGo{

View File

@ -227,9 +227,11 @@
document.querySelectorAll('#zonePartitions .filtres>div').forEach(partition => { 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 => { 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>"; 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 // Groupes
let groupesSelected = {}; let groupesSelected = {};
this.parentElement.parentElement.querySelectorAll("[data-idgroupe]:not(.unselect)").forEach(e => { document.querySelectorAll(".filtres [data-idgroupe]:not(.unselect)").forEach(e => {
let idpartition = e.parentElement.dataset.idpartition; let idpartition = e.closest("[data-idpartition]").dataset.idpartition;
if (!groupesSelected[idpartition]) { if (!groupesSelected[idpartition]) {
groupesSelected[idpartition] = []; groupesSelected[idpartition] = [];
} }
@ -345,7 +330,6 @@
e.classList.add("hide") e.classList.add("hide")
} }
}) })
//}
} }
/****************************/ /****************************/
/* Affectation à un groupe */ /* Affectation à un groupe */
@ -358,8 +342,27 @@
return; 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(); groupeSelected.closest(".grpPartitions").querySelector(`[value="${to}"]`).click();
}else{
groupeSelected.closest(".grpPartitions").querySelector(".aucun").click();
}
}) })
} }
function assignment() { function assignment() {