diff --git a/webpack/component/teacher/view.vue b/webpack/component/teacher/view.vue index d5decff..6fb1bfc 100644 --- a/webpack/component/teacher/view.vue +++ b/webpack/component/teacher/view.vue @@ -6,19 +6,19 @@
-
+

- +

- + heures à faire
diff --git a/webpack/data/teacher.js b/webpack/data/teacher.js index 68786ee..3f1b965 100644 --- a/webpack/data/teacher.js +++ b/webpack/data/teacher.js @@ -216,15 +216,7 @@ gstore.add('ir_handler', function(prof_id){ if( prof_id == null || isNaN(prof_id) ) return; - /* (2) Prepare confirmation pop-up */ - var popup_rq = { - title: 'Confirmation de suppression', - content: "La suppression de l'enseignant sadkfjsdlkf est irréversible.

Voulez-vous le supprimer définitivement ?", - action: 'Supprimer', - type: 'invalid' - }; - - /* (3) Show popup */ + /* (2) Show popup */ (new Promise( (resolve, reject) => { popup.ask({ @@ -239,39 +231,39 @@ gstore.add('ir_handler', function(prof_id){ return new Promise( (resolve, reject) => { - /* (3.1) Delete professor */ + /* (2.1) Delete professor */ api.call('DELETE professor/'+prof_id, {}, function(rs){ - /* (3.1.1) Abort on error */ + /* (2.1.1) Abort on error */ if( rs.error !== 0 || rs.deleted !== true ) return reject(rs.error); - /* (3.1.2) Success */ + /* (2.1.2) Success */ resolve(); }); }); - /* (4) On success */ + /* (3) On success */ }).then(function(){ - /* (4.1) Find index in gstore */ + /* (3.1) Find index in gstore */ var gi = gstore.get.professors.map( (data, i) => { return ( data.idProfesseur && data.idProfesseur == prof_id ) ? i : ''; }).join(''); - /* (4.2) Do nothing if not found */ + /* (3.2) Do nothing if not found */ if( isNaN(gi) ) return; - /* (4.3) Else -> remove from visible */ + /* (3.3) Else -> remove from visible */ gstore.get.professors.splice(gi, 1); - /* (5) On error */ + /* (4) On error */ }).catch(function(err_code){ popup.ask({ title: 'Error ('+err_code+')', - content: 'La suppression à échoué. Veuillez réessayer ultérieurement.', + content: 'La suppression a échouée. Veuillez réessayer ultérieurement.', action: 'OK', type: 'neutral' }, () => {}); @@ -279,11 +271,75 @@ gstore.add('ir_handler', function(prof_id){ }); - - - - - }); + + + +/* (6) Manage instant edit +---------------------------------------------------------*/ +/* (1) Define edit handler */ +gstore.add('ie_handler', function(prof_id){ + + /* (1) Abort if wrong prof_id */ + if( prof_id == null || isNaN(prof_id) ) + return; + + /* (2) Show popup */ + (new Promise( (resolve, reject) => { + + popup.ask({ + title: 'Confirmation de modification', + content: "La modification de l'enseignant sadkfjsdlkf est irréversible.

Voulez-vous le modifier ?", + action: 'Modifier', + type: 'search' + }, (popup_rs) => { popup_rs && resolve() }); + + })).then(function(){ + + + return new Promise( (resolve, reject) => { + + /* (2.1) Delete professor */ + api.call('PUT professor/'+prof_id, {}, function(rs){ + + /* (2.1.1) Abort on error */ + if( rs.error !== 0 || rs.updated !== true ) + return reject(rs.error); + + /* (2.1.2) Success */ + resolve(); + + }); + + }); + + /* (3) On success */ + }).then(function(){ + + /* (3.1) Find index in gstore */ + var gi = gstore.get.professors.map( (data, i) => { return ( data.idProfesseur && data.idProfesseur == prof_id ) ? i : ''; }).join(''); + + /* (3.2) Do nothing if not found */ + if( isNaN(gi) ) return; + + /* (3.3) Else -> update VueJS element */ + // gstore.get.professors[gi]; + + + + /* (4) On error */ + }).catch(function(err_code){ + + popup.ask({ + title: 'Error ('+err_code+')', + content: 'La modification a échouée. Veuillez réessayer ultérieurement.', + action: 'OK', + type: 'neutral' + }, () => {}); + + }); + + +}); \ No newline at end of file