diff --git a/webpack/component/ue/manage.vue b/webpack/component/ue/manage.vue index 38aeebf..383398f 100644 --- a/webpack/component/ue/manage.vue +++ b/webpack/component/ue/manage.vue @@ -18,7 +18,7 @@
Cours
@@ -31,14 +31,14 @@
- + - +
@@ -47,7 +47,7 @@
@@ -62,14 +62,14 @@
- + - +
@@ -78,7 +78,7 @@
@@ -93,14 +93,14 @@
- + - +
diff --git a/webpack/data/ue.js b/webpack/data/ue.js index b8ee2d5..a4857d8 100644 --- a/webpack/data/ue.js +++ b/webpack/data/ue.js @@ -584,8 +584,14 @@ gstore.add('load_ue_groups', function(code, recur=0){ reject({ label: 'Cours', code: rs.error}); } + // store data + // for each field add a 'add_form' for instant-adding formations afterwards + for( var group of rs.groups ){ + group.add_form = '-'; + gstore.get.manage.cours.push( group ); + } + // resolve data on success - gstore.get.manage.cours = rs.groups; resolve(); }); @@ -603,8 +609,14 @@ gstore.add('load_ue_groups', function(code, recur=0){ reject({ label: 'TD', code: rs.error}); } + // store data + // for each field add a 'add_form' for instant-adding formations afterwards + for( var group of rs.groups ){ + group.add_form = '-'; + gstore.get.manage.td.push( group ); + } + // resolve data on success - gstore.get.manage.td = rs.groups; resolve(); }); @@ -624,8 +636,14 @@ gstore.add('load_ue_groups', function(code, recur=0){ reject({ label: 'TP', code: rs.error}); } + // store data + // for each field add a 'add_form' for instant-adding formations afterwards + for( var group of rs.groups ){ + group.add_form = '-'; + gstore.get.manage.tp.push( group ); + } + // resolve data on success - gstore.get.manage.tp = rs.groups; resolve(); }); @@ -778,4 +796,48 @@ gstore.add('rem_form', function(type, id_res, id_form){ }); +}); + +/* (2) Add a formation */ +gstore.add('add_form', function(type, id_res, i){ + + // 1. Check params types + if( isNaN(type) || isNaN(id_res) || isNaN(i) ) + return; + + // 2. Check @type param + if( [0,1,2].indexOf(type) == -1 ) + return; + + // 3. extract API resource from @type + 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 ) + return; + + // 5. Extract + gstore.get.manage[res][i].add_form = '-'; + + // 7.3. Add formation to update VueJS + gstore.get.manage[res][i].formations.push(id_form); + + }); + + }); \ No newline at end of file