From 713c70799140365b7e69e2d4da772204cf63a014 Mon Sep 17 00:00:00 2001 From: lehmann Date: Sun, 14 Aug 2022 17:11:34 +0200 Subject: [PATCH] =?UTF-8?q?Partition=20editor=20-=20am=C3=A9liorations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/css/partition_editor.css | 15 +++- app/templates/scolar/partition_editor.html | 93 +++++++++++++--------- 2 files changed, 71 insertions(+), 37 deletions(-) diff --git a/app/static/css/partition_editor.css b/app/static/css/partition_editor.css index c7abf677..61e872e0 100644 --- a/app/static/css/partition_editor.css +++ b/app/static/css/partition_editor.css @@ -50,6 +50,8 @@ main { display: flex; flex-wrap: wrap; gap: 32px; + row-gap: 4px; + margin-right: 16px; } main h2 { @@ -184,8 +186,16 @@ body.editionActivated .filtres>div>div>div>div { } /*****************************/ -/* Zone Choix */ +/* Zone Partitions */ /*****************************/ +#zonePartitions { + width: 100%; +} + +.filtres { + display: table; +} + .filtres>div { background: #ddd; padding: 8px; @@ -226,6 +236,9 @@ body:not(.editionActivated) .filtres>div>div>div>div:active { background: rgba(0, 153, 204, 0.5); } +/*****************************/ +/* Zone Etudiants */ +/*****************************/ #zoneChoix .etudiants>div { background: #FFF; border: 1px solid #aaa; diff --git a/app/templates/scolar/partition_editor.html b/app/templates/scolar/partition_editor.html index 2f67f979..4e641e78 100644 --- a/app/templates/scolar/partition_editor.html +++ b/app/templates/scolar/partition_editor.html @@ -1,33 +1,37 @@ {# -*- mode: jinja-html -*- #}

{% if not read_only %}Édition des p{% else %}P{%endif%}artitions

-
- -
-
-
-

Choix

-
-
-

Afficher les partitions

-
-
-
-

- Afficher les étudiants affectés aux groupes
- Ne s'actualise pas automatiquement lors d'une modification -

-
+
+

Partitions et groupes

+
+ +
+
+

Afficher les partitions

+
+
+
+

+ Afficher les étudiants affectés aux groupes
+ Ne s'actualise pas automatiquement lors d'une modification +

+
+
+
+ +
+

Etudiants

+

Groupes

@@ -78,7 +82,12 @@ arrayPartitions.forEach((partition) => { // Filtres - outputPartitions += `
||${partition.partition_name}✏️
`; + if (partition.groups_editable) { + outputPartitions += `
||${partition.partition_name}✏️
`; + } else { + outputPartitions += `
${partition.partition_name}
`; + } + outputMasques += `
Non affectés - ${partition.partition_name}
`; // Groupes @@ -96,9 +105,13 @@ let output = ""; arrayGroups.forEach((groupe) => { /***************/ - outputMasques += `
||${groupe.group_name}✏️
`; // patch JMP (renommage du champ name dans l API) + if (partition.groups_editable) { + outputMasques += `
||${groupe.group_name}✏️
`; + } else { + outputMasques += `
${groupe.group_name}
`; + } /***************/ - output += templateGroupe_zoneGroupes(groupe.id, groupe.group_name); // patch JMP (renommage du champ name dans l API) + output += templateGroupe_zoneGroupes(groupe.id, groupe.group_name); }) return output; })()} @@ -144,7 +157,7 @@ if (!affected) { document.querySelector(`#zoneGroupes [data-idpartition="${partition.id}"]>[data-idgroupe="aucun"]>.etudiants`).innerHTML += templateEtudiant_zoneGroupes(etudiant); } - return `` + output; + return `` + output; })()}
`; }) @@ -171,9 +184,6 @@ /******************************/ function input() { document.querySelector("body").classList.toggle("editionActivated"); - /*if (event.currentTarget.checked == false) { - go(); - }*/ } function processEvents() { /*--------------------*/ @@ -193,7 +203,7 @@ /*--------------------*/ /* Changement groupe */ /*--------------------*/ - document.querySelectorAll("#zoneChoix label").forEach(btn => { btn.addEventListener("mousedown", (event) => { event.preventDefault() }) }); + document.querySelectorAll("label").forEach(btn => { btn.addEventListener("mousedown", (event) => { event.preventDefault() }) }); document.querySelectorAll(".etudiants input").forEach(input => { input.addEventListener("input", assignment) }) } @@ -223,6 +233,7 @@ } if (!this.dataset.idgroupe) { + // Partitions let groupesSelected = []; this.parentElement.querySelectorAll(":not(.unselect)").forEach(e => { groupesSelected.push(e.dataset.idpartition); @@ -238,6 +249,7 @@ } }) } else { + // Groupes let groupesSelected = {}; this.parentElement.parentElement.querySelectorAll("[data-idgroupe]:not(.unselect)").forEach(e => { @@ -350,6 +362,8 @@ div.querySelector(".move").addEventListener("mousedown", moveStart); this.parentElement.insertBefore(div, this); + div.querySelector(".modif").click(); + // Save fetch(url, { @@ -380,12 +394,12 @@ div.querySelector("div").addEventListener("click", filtre); div.querySelector(".ajoutGroupe").addEventListener("click", addPartition); - document.querySelector("#zoneChoix .masques>div").appendChild(div); + document.querySelector("#zonePartitions .masques>div").appendChild(div); // Ajout de la zone pour chaque étudiant let outputGroupes = ""; - document.querySelectorAll(`#zoneChoix .grpPartitions`).forEach(e => { + document.querySelectorAll(`#zonePartitions .grpPartitions`).forEach(e => { let etudid = e.previousElementSibling.dataset.etudid; // Préparation pour la section suivante @@ -447,10 +461,17 @@ /* Edition du texte */ /********************/ function editText() { - this.previousElementSibling.classList.add("editingText"); - this.previousElementSibling.setAttribute("contenteditable", "true"); - this.previousElementSibling.focus(); - this.previousElementSibling.addEventListener("keydown", writing); + let e = this.previousElementSibling; + e.classList.add("editingText"); + e.setAttribute("contenteditable", "true"); + e.addEventListener("keydown", writing); + + // On sélectionne la zone + const range = document.createRange(); + const selection = window.getSelection(); + selection.removeAllRanges(); + range.selectNodeContents(e); + selection.addRange(range); } function writing(event) { @@ -613,12 +634,12 @@ let formsemestre_id = params.get('formsemestre_id'); var url = `/ScoDoc/{{formsemestre.departement.acronym}}/api/formsemestre/${formsemestre_id}/partitions/order`; - document.querySelectorAll(`#zoneChoix .masques>div`).forEach(parent => { + document.querySelectorAll(`#zonePartitions .masques>div`).forEach(parent => { positions.forEach(position => { parent.append(parent.querySelector(`[data-idpartition="${position}"]`)) }) }) - document.querySelectorAll(`#zoneChoix .grpPartitions`).forEach(parent => { + document.querySelectorAll(`#zonePartitions .grpPartitions`).forEach(parent => { positions.forEach(position => { parent.append(parent.querySelector(`[data-idpartition="${position}"]`)) })