From 35646a934bd9bc32a9bf74d419fde9ca91d2c495 Mon Sep 17 00:00:00 2001 From: iziram Date: Wed, 19 Apr 2023 18:17:47 +0200 Subject: [PATCH] Assiduites : modification automatique du moduleimpl_id --- app/static/js/assiduites.js | 2 +- .../assiduites/moduleimpl_dynamic_selector.j2 | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index 0252013de..79d7308fc 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -1758,7 +1758,7 @@ function getCurrentAssiduite(etudid) { const assiduite_id = parseInt(field.getAttribute("assiduite_id")); const type = field.getAttribute("type"); - if (type == "edition") { + if (type == "édition") { let assi = null; assiduites[etudid].forEach((a) => { if (a.assiduite_id === assiduite_id) { diff --git a/app/templates/assiduites/moduleimpl_dynamic_selector.j2 b/app/templates/assiduites/moduleimpl_dynamic_selector.j2 index 3fcf07d55..dbbecc8a1 100644 --- a/app/templates/assiduites/moduleimpl_dynamic_selector.j2 +++ b/app/templates/assiduites/moduleimpl_dynamic_selector.j2 @@ -98,7 +98,26 @@ } function updateSelectedSelect(moduleimpl_id) { - document.getElementById('moduleimpl_select').value = moduleimpl_id; + const mod_id = moduleimpl_id != null ? moduleimpl_id : "" + document.getElementById('moduleimpl_select').value = mod_id; + } + + + + window.onload = () => { + document.getElementById('moduleimpl_select').addEventListener('change', () => { + const mod_id = document.getElementById('moduleimpl_select').value; + + const assi = getCurrentAssiduite(etudid); + if (assi) { + editAssiduite(assi.assiduite_id, assi.etat); + } + }) + + const conflicts = getAssiduitesConflict(etudid); + if (conflicts.length > 0) { + updateSelectedSelect(conflicts[0].moduleimpl_id); + } }