diff --git a/app/static/css/table_editor.css b/app/static/css/table_editor.css index e3192d88..25d192c5 100644 --- a/app/static/css/table_editor.css +++ b/app/static/css/table_editor.css @@ -52,6 +52,9 @@ div.title_STANDARD, .champs_STANDARD { div.title_MALUS { background-color: #ff4700; } +.sums { + background: #ddd; +} /***************************/ /* Statut des cellules */ /***************************/ diff --git a/app/static/js/table_editor.js b/app/static/js/table_editor.js index 2af700a4..a4e8d27a 100644 --- a/app/static/js/table_editor.js +++ b/app/static/js/table_editor.js @@ -4,8 +4,13 @@ /*****************************/ /* Mise en place des données */ /*****************************/ +let lastX; +let lastY; + function build_table(data) { let output = ""; + let sumsUE = {}; + let sumsRessources = {}; data.forEach((cellule) => { output += ` @@ -29,11 +34,61 @@ function build_table(data) { "> ${cellule.data} `; + + if (cellule.editable && cellule.data) { + sumsRessources[cellule.y] = (sumsRessources[cellule.y] ?? 0) + parseInt(cellule.data); + sumsUE[cellule.x] = (sumsUE[cellule.x] ?? 0) + parseInt(cellule.data); + } }) + + output += showSums(sumsRessources, sumsUE); document.querySelector(".tableau").innerHTML = output; installListeners(); } +function showSums(sumsRessources, sumsUE) { + lastX = Object.keys(sumsUE).length + 2; + lastY = Object.keys(sumsRessources).length + 2; + + let output = ""; + + Object.entries(sumsUE).forEach(([num, value]) => { + output += ` +