From fc26d4a7efc79d17063ba9f7c08240cfd9ec22a9 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 12 Mar 2018 11:01:23 +0100 Subject: [PATCH] [webpack.ue.view] fixed update --- webpack/data/ue.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/webpack/data/ue.js b/webpack/data/ue.js index 64ab2dc..ce505e4 100644 --- a/webpack/data/ue.js +++ b/webpack/data/ue.js @@ -398,12 +398,12 @@ gstore.add('ie_handler', function(ue_i){ /* (5.7) Création de la requête */ var rq = {}; - ( label != ue.label ) && ( rq.label = label ); - // ( code != ue.code ) && ( rq.code = code ); - ( vco != ue.volumeCours ) && ( rq.volumeCours = parseInt(vco) ); - ( vtd != ue.volumeTD ) && ( rq.volumeTD = parseInt(vtd) ); - ( vtp != ue.volumeTP ) && ( rq.volumeTP = parseInt(vtp) ); - ( form != ue.defaultFormation ) && ( rq.defaultFormation = parseInt(form) ); + ( label != ue.label ) && ( rq.label = label ); + // ( code != ue.code ) && ( rq.code = code ); + ( vco != ue.volumeCours ) && ( rq.volumeCours = parseInt(vco) ); + ( vtd != ue.volumeTD ) && ( rq.volumeTD = parseInt(vtd) ); + ( vtp != ue.volumeTP ) && ( rq.volumeTP = parseInt(vtp) ); + ( form != ue.idForm ) && ( rq.defaultFormation = parseInt(form) ); (new Promise( (resolve, reject) => { @@ -423,6 +423,7 @@ gstore.add('ie_handler', function(ue_i){ api.call(`PUT ue/${ue.code}`, rq, function(rs){ /* (5.8.1.1) Abort on error */ + console.log(rq, rs.error != 0, rs.updated != true); if( rs.error != 0 || rs.updated != true ) return reject(rs.error); @@ -438,7 +439,7 @@ gstore.add('ie_handler', function(ue_i){ /* (5.9.1) update VueJS element */ gstore.get.ues[ue_i].label = label; - gstore.get.ues[ue_i].code = code; + // gstore.get.ues[ue_i].code = code; gstore.get.ues[ue_i].idForm = parseInt(form); gstore.get.ues[ue_i].volumeCours = parseInt(vco); gstore.get.ues[ue_i].volumeTD = parseInt(vtd); @@ -448,10 +449,16 @@ gstore.add('ie_handler', function(ue_i){ var fi = gstore.get.formations.map( (data, i) => { return ( data.idForm && data.idForm == form ) ? i : ''; }).join(''); /* (5.9.3) Exit if not found */ - if( isNaN(fi) ) return gstore.add('edit_i', -1); + if( isNaN(fi) ) + return gstore.add('edit_i', -1); - /* (5.9.4) If found -> set formation label */ - gstore.get.ues[ue_i].labelForm = gstore.get.formations[fi].labelForm; + /* (5.9.4) If not found -> set default text */ + if( !gstore.get.formations.hasOwnProperty(fi) ) + gstore.get.ues[ue_i].labelForm = ''; + + /* (5.9.5) If found -> set formation label */ + else + gstore.get.ues[ue_i].labelForm = gstore.get.formations[fi].labelForm; /* (5.9.5) Remove edit mode */ gstore.add('edit_i', -1);