forked from ScoDoc/ScoDoc
partition_editor: routes API
This commit is contained in:
parent
dcd7cf78fd
commit
1796279d8a
@ -42,8 +42,8 @@
|
|||||||
let params = (new URL(document.location)).searchParams;
|
let params = (new URL(document.location)).searchParams;
|
||||||
let formsemestre_id = params.get('formsemestre_id');
|
let formsemestre_id = params.get('formsemestre_id');
|
||||||
|
|
||||||
let partitions = await fetchData("/ScoDoc/api/formsemestre/" + formsemestre_id + "/partitions");
|
let partitions = await fetchData("/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre_id + "/partitions");
|
||||||
let etudiants = await fetchData("/ScoDoc/api/formsemestre/" + formsemestre_id + "/resultats");
|
let etudiants = await fetchData("/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre_id + "/resultats");
|
||||||
|
|
||||||
etudiants.sort((a, b) => {
|
etudiants.sort((a, b) => {
|
||||||
return a.nom_short.localeCompare(b.nom_short)
|
return a.nom_short.localeCompare(b.nom_short)
|
||||||
@ -86,15 +86,15 @@
|
|||||||
<div class=etudiants></div>
|
<div class=etudiants></div>
|
||||||
</div>
|
</div>
|
||||||
${(() => {
|
${(() => {
|
||||||
let output = "";
|
let output = "";
|
||||||
Object.entries(partition.groups).forEach(([idGroupe, titreGroupe]) => {
|
Object.entries(partition.groups).forEach(([idGroupe, titreGroupe]) => {
|
||||||
/***************/
|
/***************/
|
||||||
outputMasques += `<div data-idgroupe="${idGroupe}"><span class="editing move">||</span><span>${titreGroupe.name}</span><span class="editing modif">✏️</span><span class="editing suppr">❌</span></div>`;
|
outputMasques += `<div data-idgroupe="${idGroupe}"><span class="editing move">||</span><span>${titreGroupe.name}</span><span class="editing modif">✏️</span><span class="editing suppr">❌</span></div>`;
|
||||||
/***************/
|
/***************/
|
||||||
output += templateGroupe_zoneGroupes(idGroupe, titreGroupe.name);
|
output += templateGroupe_zoneGroupes(idGroupe, titreGroupe.name);
|
||||||
})
|
})
|
||||||
return output;
|
return output;
|
||||||
})()}
|
})()}
|
||||||
</div>`;
|
</div>`;
|
||||||
outputMasques += `
|
outputMasques += `
|
||||||
<div class="editing ajoutGroupe">+</div>
|
<div class="editing ajoutGroupe">+</div>
|
||||||
@ -289,9 +289,9 @@
|
|||||||
/* Save */
|
/* Save */
|
||||||
this.classList.add("saving");
|
this.classList.add("saving");
|
||||||
if (idGroupe == "aucun") {
|
if (idGroupe == "aucun") {
|
||||||
var url = `/ScoDoc/api/partition/${idPartition}/remove_etudiant/${etudid}`;
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/partition/${idPartition}/remove_etudiant/${etudid}`;
|
||||||
} else {
|
} else {
|
||||||
var url = `/ScoDoc/api/group/${idGroupe}/set_etudiant/${etudid}`
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/group/${idGroupe}/set_etudiant/${etudid}`
|
||||||
}
|
}
|
||||||
fetch(url, { method: "POST" })
|
fetch(url, { method: "POST" })
|
||||||
.then(r => { return r.json() })
|
.then(r => { return r.json() })
|
||||||
@ -320,12 +320,12 @@
|
|||||||
var name = "Nouvelle " + date.getSeconds();
|
var name = "Nouvelle " + date.getSeconds();
|
||||||
let params = (new URL(document.location)).searchParams;
|
let params = (new URL(document.location)).searchParams;
|
||||||
let formsemestre_id = params.get('formsemestre_id');
|
let formsemestre_id = params.get('formsemestre_id');
|
||||||
var url = "/ScoDoc/api/formsemestre/" + formsemestre_id + "/partition/create";
|
var url = "/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/" + formsemestre_id + "/partition/create";
|
||||||
var payload = { partition_name: name };
|
var payload = { partition_name: name };
|
||||||
} else {
|
} else {
|
||||||
// Groupe
|
// Groupe
|
||||||
var name = "Nouveau " + date.getSeconds();
|
var name = "Nouveau " + date.getSeconds();
|
||||||
var url = `/ScoDoc/api/partition/${this.parentElement.dataset.idpartition}/group/create`;
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/partition/${this.parentElement.dataset.idpartition}/group/create`;
|
||||||
var payload = { group_name: name };
|
var payload = { group_name: name };
|
||||||
}
|
}
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
@ -382,7 +382,7 @@
|
|||||||
let etudiant = {
|
let etudiant = {
|
||||||
etudid: etudid,
|
etudid: etudid,
|
||||||
nom_disp: e.previousElementSibling.dataset.nom,
|
nom_disp: e.previousElementSibling.dataset.nom,
|
||||||
prenom:e.previousElementSibling.dataset.prenom
|
prenom: e.previousElementSibling.dataset.prenom
|
||||||
}
|
}
|
||||||
outputGroupes += templateEtudiant_zoneGroupes(etudiant);
|
outputGroupes += templateEtudiant_zoneGroupes(etudiant);
|
||||||
////////////////////////
|
////////////////////////
|
||||||
@ -463,14 +463,14 @@
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
if (obj.parentElement.dataset.idpartition) {
|
if (obj.parentElement.dataset.idpartition) {
|
||||||
var url = `/ScoDoc/api/partition/${obj.parentElement.dataset.idpartition}/edit`;
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/partition/${obj.parentElement.dataset.idpartition}/edit`;
|
||||||
var payload = { partition_name: obj.innerText }
|
var payload = { partition_name: obj.innerText }
|
||||||
|
|
||||||
document.querySelector(`.masques [data-idpartition="${obj.parentElement.dataset.idpartition}"][data-idgroupe="aucun"]`).innerText = "Non affectés - " + obj.innerText;
|
document.querySelector(`.masques [data-idpartition="${obj.parentElement.dataset.idpartition}"][data-idgroupe="aucun"]`).innerText = "Non affectés - " + obj.innerText;
|
||||||
document.querySelectorAll(`#zoneChoix .etudiants [data-idpartition="${obj.parentElement.dataset.idpartition}"]>div`).forEach(e => { e.innerText = obj.innerText });
|
document.querySelectorAll(`#zoneChoix .etudiants [data-idpartition="${obj.parentElement.dataset.idpartition}"]>div`).forEach(e => { e.innerText = obj.innerText });
|
||||||
document.querySelector(`#zoneGroupes [data-idpartition="${obj.parentElement.dataset.idpartition}"]>h3`).innerText = obj.innerText;
|
document.querySelector(`#zoneGroupes [data-idpartition="${obj.parentElement.dataset.idpartition}"]>h3`).innerText = obj.innerText;
|
||||||
} else {
|
} else {
|
||||||
var url = `/ScoDoc/api/group/${obj.parentElement.dataset.idgroupe}/edit`;
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/group/${obj.parentElement.dataset.idgroupe}/edit`;
|
||||||
var payload = { group_name: obj.innerText }
|
var payload = { group_name: obj.innerText }
|
||||||
|
|
||||||
document.querySelectorAll(`#zoneChoix .etudiants [value="${obj.parentElement.dataset.idgroupe}"]+span`).forEach(e => { e.innerText = obj.innerText });
|
document.querySelectorAll(`#zoneChoix .etudiants [value="${obj.parentElement.dataset.idgroupe}"]+span`).forEach(e => { e.innerText = obj.innerText });
|
||||||
@ -527,7 +527,7 @@
|
|||||||
/* Suppression des éléments dans la page */
|
/* Suppression des éléments dans la page */
|
||||||
if (this.dataset.idpartition) {
|
if (this.dataset.idpartition) {
|
||||||
document.querySelectorAll(`[data-idpartition="${this.dataset.idpartition}"]`).forEach(e => { e.remove() })
|
document.querySelectorAll(`[data-idpartition="${this.dataset.idpartition}"]`).forEach(e => { e.remove() })
|
||||||
var url = "/ScoDoc/api/partition/" + this.dataset.idpartition + "/delete";
|
var url = "/ScoDoc/{{formsemestre.departement.acronym}}/api/partition/" + this.dataset.idpartition + "/delete";
|
||||||
} else {
|
} else {
|
||||||
document.querySelectorAll(`[value="${this.dataset.idgroupe}"]`).forEach(e => {
|
document.querySelectorAll(`[value="${this.dataset.idgroupe}"]`).forEach(e => {
|
||||||
if (e.checked == true) {
|
if (e.checked == true) {
|
||||||
@ -536,7 +536,7 @@
|
|||||||
e.parentElement.remove()
|
e.parentElement.remove()
|
||||||
})
|
})
|
||||||
document.querySelectorAll(`[data-idgroupe="${this.dataset.idgroupe}"]`).forEach(e => { e.remove() })
|
document.querySelectorAll(`[data-idgroupe="${this.dataset.idgroupe}"]`).forEach(e => { e.remove() })
|
||||||
var url = "/ScoDoc/api/group/" + this.dataset.idgroupe + "/delete";
|
var url = "/ScoDoc/{{formsemestre.departement.acronym}}/api/group/" + this.dataset.idgroupe + "/delete";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save
|
//Save
|
||||||
@ -601,7 +601,7 @@
|
|||||||
if (this.dataset.idpartition) {
|
if (this.dataset.idpartition) {
|
||||||
let params = (new URL(document.location)).searchParams;
|
let params = (new URL(document.location)).searchParams;
|
||||||
let formsemestre_id = params.get('formsemestre_id');
|
let formsemestre_id = params.get('formsemestre_id');
|
||||||
var url = `/ScoDoc/api/formsemestre/${formsemestre_id}/partitions/order`;
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/${formsemestre_id}/partitions/order`;
|
||||||
|
|
||||||
document.querySelectorAll(`#zoneChoix .masques>div`).forEach(parent => {
|
document.querySelectorAll(`#zoneChoix .masques>div`).forEach(parent => {
|
||||||
positions.forEach(position => {
|
positions.forEach(position => {
|
||||||
@ -619,7 +619,7 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
var url = `/ScoDoc/api/partition/${this.parentElement.dataset.idpartition}/groups/order`;
|
var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/partition/${this.parentElement.dataset.idpartition}/groups/order`;
|
||||||
|
|
||||||
document.querySelectorAll(`#zoneChoix .etudiants .partition[data-idpartition="${this.parentElement.dataset.idpartition}"]`).forEach(partition => {
|
document.querySelectorAll(`#zoneChoix .etudiants .partition[data-idpartition="${this.parentElement.dataset.idpartition}"]`).forEach(partition => {
|
||||||
positions.forEach(position => {
|
positions.forEach(position => {
|
||||||
|
Loading…
Reference in New Issue
Block a user