forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -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 ==>>
|
||||
|
@ -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 = `
|
||||
<h3>Aucun module n'a été spécifié (préférence du semestre concerné)</h3>
|
||||
@ -982,7 +985,7 @@
|
||||
toCreate.length = 0
|
||||
}
|
||||
}
|
||||
Object.keys(e[0].success).forEach((k) => {
|
||||
Object.keys(e.success).forEach((k) => {
|
||||
const { etudid, assiduite_id, moduleimpl_id, etat } = editList[Number.parseInt(k)]
|
||||
assiduites[etudid].map((a) => {
|
||||
if (a.assiduite_id == assiduite_id) {
|
||||
|
Loading…
Reference in New Issue
Block a user