diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index 9e05312b..fd4892b4 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -191,8 +191,9 @@ function sync_get(path, success, errors) { */ async function async_get(path, success, errors) { console.log("async_get " + path); + let response; try { - const response = await fetch(path); + response = await fetch(path); if (response.ok) { const data = await response.json(); success(data); @@ -203,6 +204,8 @@ async function async_get(path, success, errors) { console.error(error); if (errors) errors(error); } + + return response; } /** @@ -233,8 +236,9 @@ function sync_post(path, data, success, errors) { */ async function async_post(path, data, success, errors) { console.log("async_post " + path); + let response; try { - const response = await fetch(path, { + response = await fetch(path, { method: "POST", headers: { "Content-Type": "application/json", @@ -252,6 +256,8 @@ async function async_post(path, data, success, errors) { console.error(error); if (errors) errors(error); } + + return response; } // <<== Gestion des actions de masse ==>> diff --git a/app/templates/assiduites/widgets/differee.j2 b/app/templates/assiduites/widgets/differee.j2 index 1c8b2a0f..65cfb351 100644 --- a/app/templates/assiduites/widgets/differee.j2 +++ b/app/templates/assiduites/widgets/differee.j2 @@ -954,24 +954,27 @@ editList.push(edit); }) - - $.when( - asyncCreateAssiduiteGroup(createList, (data) => { - + const values = { "create": {}, "edit": {} }; + Promise.all( + [asyncCreateAssiduiteGroup(createList, (data) => { + values.create = data; }), asyncEditAssiduiteGroup(editList, (data) => { + values.edit = data; - }) - ).done((c, e) => { + })] + ).then(() => { + const c = values.create; + const e = values.edit; let error; - Object.keys(c[0].success).forEach((k) => { + Object.keys(c.success).forEach((k) => { const assiduite = createList[Number.parseInt(k)]; - assiduite["assiduite_id"] = c[0].success[k].message.assiduite_id; + assiduite["assiduite_id"] = c.success[k].message.assiduite_id; assiduites[assiduite.etudid].push(assiduite); }) - if (c[0].errors.length > 0) { - error = c[0].errors[Object.keys(c[0].errors)[0]]; + if (c.errors.length > 0) { + error = c.errors[Object.keys(c.errors)[0]]; if (error.message.indexOf("Module") != -1) { const html = `