diff --git a/app/static/css/table_editor.css b/app/static/css/table_editor.css index 04faa9434..d3fe5a0f3 100644 --- a/app/static/css/table_editor.css +++ b/app/static/css/table_editor.css @@ -7,87 +7,53 @@ body { /***************************/ /* Le tableau */ /***************************/ -.tableau { +.tableau{ display: grid; grid-auto-rows: minmax(24px, auto); + gap: 2px; } - -.entete { +.entete{ background: #09c; font-weight: bold; } - -.tableau>div { - padding: 4px; +.tableau>div{ + padding: 4px 8px; + border-radius: 4px; border: 1px solid #999; grid-column: var(--x) / span var(--nbX); grid-row: var(--y) / span var(--nbY); } -/***************************/ -/* Attente */ -/***************************/ -.wait { - position: fixed; - top: 32px; - left: 50%; - height: 4px; - width: 32px; - margin-left: -16px; - background: #424242; - animation: attente 0.4s infinite alternate; - display: none; -} - -.go { - display: block; -} - -@keyframes attente { - 100% { - transform: translateY(-16px) rotate(360deg); - } -} - -/***************************/ -/* Système de modification */ -/***************************/ -.modifOnOff { - position: relative; - display: table; - margin: 16px; - padding-right: 8px; +[data-editable="true"]{ cursor: pointer; } -.modifOnOff::before { - content: ''; - width: 40px; - height: 20px; - background: #c90; - position: absolute; - top: 0; - left: 100%; - border-radius: 20px; - transition: 0.2s; -} +/***************************/ +/* Statut des cellules */ +/***************************/ +.selected{ outline: 1px solid #c09; } +.modifying{ outline: 2px dashed #c09; } +.wait{ outline: 2px solid #c90; } +.good{ outline: 2px solid #9c0; } -.modifOnOff::after { - content: ''; - width: 16px; - height: 16px; - background: #FFF; - position: absolute; - top: 2px; - left: calc(100% + 2px); - border-radius: 100%; - transition: 0.2s; +/***************************/ +/* Message */ +/***************************/ +.message{ + position: fixed; + bottom: 100%; + left: 50%; + z-index: 10; + padding: 20px; + border-radius: 0 0 10px 10px; + background: #ec7068; + background: #90c; + color: #FFF; + font-size: 24px; + animation: message 3s; + transform: translate(-50%, 0); } - -.modifOnOff.active::before { - background: #9c0; +@keyframes message{ + 20%{transform: translate(-50%, 100%)} + 80%{transform: translate(-50%, 100%)} } - -.modifOnOff.active::after { - transform: translateX(20px); -} \ No newline at end of file diff --git a/app/static/js/table_editor.js b/app/static/js/table_editor.js index 692268afb..c2ed4210a 100644 --- a/app/static/js/table_editor.js +++ b/app/static/js/table_editor.js @@ -1,34 +1,6 @@ -/* table_editor, par Sébastien L. +/* table_editor, par Sébastien L. 2021-11-12 */ -/******************************/ -/* Gestion de la modification */ -/******************************/ - -function editableOnOff() { - if (this.classList.toggle("active")) { - document.querySelectorAll("[data-editable=true]").forEach(cellule => { - cellule.contentEditable = true; - cellule.addEventListener("input", delayBeforeSave); - cellule.addEventListener("blur", save); - }) - } else { - document.querySelectorAll("[data-editable=true]").forEach(cellule => { - cellule.removeAttribute("contentEditable"); - cellule.removeEventListener("input", delayBeforeSave); - cellule.removeEventListener("blur", save); - }) - } -} - -let timeout = 0; - -function delayBeforeSave() { - clearTimeout(timeout); - document.querySelector(".wait").classList.add("go"); - timeout = setTimeout(() => { save(this) }, 2000); -} - /*****************************/ /* Mise en place des données */ /*****************************/ @@ -38,19 +10,117 @@ function build_table(data) { data.forEach((cellule) => { output += `