From 459e75db8976fc629761133177dc827dcaadd927 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 13 Nov 2021 09:43:13 +0100 Subject: [PATCH] =?UTF-8?q?details=20cosm=C3=A9tiques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/css/table_editor.css | 2 +- app/static/js/table_editor.js | 3 +- app/templates/pn/form_modules_ue_coefs.html | 36 +++++++++++---------- app/views/pn_modules.py | 4 +-- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/static/css/table_editor.css b/app/static/css/table_editor.css index d3fe5a0f3..32e33f2ed 100644 --- a/app/static/css/table_editor.css +++ b/app/static/css/table_editor.css @@ -35,7 +35,7 @@ body { .modifying{ outline: 2px dashed #c09; } .wait{ outline: 2px solid #c90; } .good{ outline: 2px solid #9c0; } - +.modified { font-weight: bold; color:indigo} /***************************/ /* Message */ /***************************/ diff --git a/app/static/js/table_editor.js b/app/static/js/table_editor.js index c2ed4210a..cb50c1fea 100644 --- a/app/static/js/table_editor.js +++ b/app/static/js/table_editor.js @@ -19,6 +19,7 @@ function build_table(data) { data-nbX="${cellule.nbX || 1}" data-nbY="${cellule.nbY || 1}" data-data="${cellule.data}" + data-orig="${cellule.data}" style=" --x:${cellule.x}; --y:${cellule.y}; @@ -79,7 +80,7 @@ function modifCell(obj) { function key(event) { switch (event.key) { - case "Enter": modifCell(document.querySelector(".selected")); event.preventDefault(); break; + case "Enter": modifCell(document.querySelector(".selected")); event.preventDefault(); ArrowMove(1, 0); break; case "ArrowRight": ArrowMove(1, 0); break; case "ArrowLeft": ArrowMove(-1, 0); break; case "ArrowUp": ArrowMove(0, -1); break; diff --git a/app/templates/pn/form_modules_ue_coefs.html b/app/templates/pn/form_modules_ue_coefs.html index e8f671bd8..7c27f70c2 100644 --- a/app/templates/pn/form_modules_ue_coefs.html +++ b/app/templates/pn/form_modules_ue_coefs.html @@ -28,7 +28,7 @@ if (value.length == 0) { value = "0"; } - if (!/^\d+$/.test(value)) { + if (!/^[\d.,]+$/.test(value)) { message("Il est attendu un nombre"); return false; } @@ -38,28 +38,30 @@ obj.dataset.data = value; obj.classList.add("wait"); // XXX DEBUG - console.log(` - x : ${getComputedStyle(obj).getPropertyValue("--x")} - y : ${getComputedStyle(obj).getPropertyValue("--y")} - data : ${value} - ue_id: ${obj.dataset.ue_id} - module_id : ${obj.dataset.module_id} - `); + // console.log(` + // x : ${getComputedStyle(obj).getPropertyValue("--x")} + // y : ${getComputedStyle(obj).getPropertyValue("--y")} + // data : ${value} + // ue_id: ${obj.dataset.ue_id} + // module_id : ${obj.dataset.module_id} + // `); $.post("{{data_save}}", { - module_id: `${obj.dataset.module_id}`, - ue_id: `${obj.dataset.ue_id}`, - coef: `${value}` + module_id: obj.dataset.module_id, + ue_id: obj.dataset.ue_id, + coef: value }, function (result) { - console.log("enregistré"); // XXX obj.classList.remove("wait"); - obj.classList.add("good"); - // Lorsque les données sont bien enregistrés, on enlève + if (obj.dataset.orig != value) + obj.classList.add("modified"); + else + obj.classList.remove("modified"); + // Lorsque les données sont bien enregistrées, on enlève // l'indication que c'est bon au bout d'un temps - setTimeout(() => { - obj.classList.remove("good"); - }, 1000); + //setTimeout(() => { + // obj.classList.remove("modified"); + //}, 1000); } ); } diff --git a/app/views/pn_modules.py b/app/views/pn_modules.py index 722bcd7ed..b93852096 100644 --- a/app/views/pn_modules.py +++ b/app/views/pn_modules.py @@ -93,8 +93,6 @@ def table_modules_ue_coefs(formation_id): { "x": col, "y": 1, # 1ere ligne - "nbX": 1, - "nbY": 1, "style": "title_ue", "data": ue.acronyme, "title": ue.titre, @@ -110,7 +108,7 @@ def table_modules_ue_coefs(formation_id): "x": col, "y": row, "style": "champs", - "data": df[ue.id][mod.id], + "data": df[ue.id][mod.id] or "", "editable": True, "module_id": mod.id, "ue_id": ue.id,