From 045ced9002a3eedbe41ceb234b859ad1bc76de2f Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 16 Mar 2018 15:28:47 +0100 Subject: [PATCH] [webpack.ue.manage] eased 'add_form' (by index no more ID) --- webpack/component/ue/manage.vue | 6 +++--- webpack/data/ue.js | 28 +++++++++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/webpack/component/ue/manage.vue b/webpack/component/ue/manage.vue index 16e4659..3cc2671 100644 --- a/webpack/component/ue/manage.vue +++ b/webpack/component/ue/manage.vue @@ -41,7 +41,7 @@ v-show='c.formations.indexOf(f.idForm) < 0' :value='f.idForm'>{{ f.labelForm }} - + @@ -75,7 +75,7 @@ v-show='td.formations.indexOf(f.idForm) < 0' :value='f.idForm'>{{ f.labelForm }} - + @@ -109,7 +109,7 @@ v-show='tp.formations.indexOf(f.idForm) < 0' :value='f.idForm'>{{ f.labelForm }} - + diff --git a/webpack/data/ue.js b/webpack/data/ue.js index c04064c..62c2e73 100644 --- a/webpack/data/ue.js +++ b/webpack/data/ue.js @@ -809,10 +809,10 @@ gstore.add('rem_form', function(type, res_i, id_form){ }); /* (2) Add a formation */ -gstore.add('add_form', function(type, id_res, i){ +gstore.add('add_form', function(type, res_i){ // 1. Check params types - if( isNaN(type) || isNaN(id_res) || isNaN(i) ) + if( isNaN(type) || isNaN(res_i) ) return; // 2. Check @type param @@ -823,29 +823,35 @@ gstore.add('add_form', function(type, id_res, i){ var res = [ 'cours', 'td', 'tp' ][type]; var resM = [ 'Cours', 'TD', 'TP' ][type]; - // 4. Exit if @i is invalid - if( gstore.get.manage[res][i] == null ) + // 4. Extract @resource from @res_i + var resource = gstore.get.manage[res][res_i]; + + // 4- Manage unreachable resource + if( resource == null ) return; - // 5. Extract formation id + var id_form = resource.add_form; + + // 7. Exit if not a number if( isNaN(id_form) ) return; - // 7. Request to add formation - api.call(`PUT ue/${res}/${id_res}`, { add_form: [id_form] }, (rs) => { + // 8. Request to add formation + api.call(`PUT ue/${res}/${res_id}`, { add_form: [id_form] }, (rs) => { // 7.1. Manage error if( rs.error !== 0 || rs.updated !== true ) return; // 7.2. Unselect the