[webpack.teacher.view] instant-remove|instant-edit now have knowledge of the specified professor (from gstore.professors)

This commit is contained in:
xdrm-brackets 2018-03-08 12:45:09 +01:00
parent 3f7aaee9b5
commit 7a3ac8ff64
1 changed files with 33 additions and 30 deletions

View File

@ -333,49 +333,51 @@ gstore.add('ir_handler', function(prof_id){
if( prof_id == null || isNaN(prof_id) )
return;
/* (2) Show popup */
/* (2.1) Find index in gstore */
var gi = gstore.get.professors.map( (data, i) => { return ( data.idProfesseur && data.idProfesseur == prof_id ) ? i : ''; }).join('');
/* (2.2) Exit if not found */
if( isNaN(gi) ) return;
local = gstore.get.professors[gi];
/* (3) Show popup */
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de suppression',
content: "La suppression de l'enseignant <b>sadkfjsdlkf</b> est irréversible.<br><br>Voulez-vous le supprimer définitivement ?",
content: "La suppression de l'enseignant <b>"+local.firstName+" "+local.lastName+"</b> est irréversible.<br><br>Voulez-vous le supprimer définitivement ?",
action: 'Supprimer',
type: 'invalid'
}, (popup_rs) => { popup_rs && resolve() });
/* (4) On pop-up confirmation */
})).then(function(){
return new Promise( (resolve, reject) => {
/* (2.1) Delete professor */
/* (4.1) Delete professor */
api.call('DELETE professor/'+prof_id, {}, function(rs){
/* (2.1.1) Abort on error */
/* (4.1.1) Abort on error */
if( rs.error !== 0 || rs.deleted !== true )
return reject(rs.error);
/* (2.1.2) Success */
/* (4.1.2) Success */
resolve();
});
});
/* (3) On success */
/* (5) 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 -> remove from visible */
/* remove from visible */
gstore.get.professors.splice(gi, 1);
/* (4) On error */
/* (6) On error */
}).catch(function(err_code){
popup.ask({
@ -403,50 +405,51 @@ gstore.add('ie_handler', function(prof_id){
if( prof_id == null || isNaN(prof_id) )
return;
/* (2) Show popup */
/* (2.1) Find index in gstore */
var gi = gstore.get.professors.map( (data, i) => { return ( data.idProfesseur && data.idProfesseur == prof_id ) ? i : ''; }).join('');
/* (2.2) Exit if not found */
if( isNaN(gi) ) return;
local = gstore.get.professors[gi];
/* (3) Show popup */
(new Promise( (resolve, reject) => {
popup.ask({
title: 'Confirmation de modification',
content: "La modification de l'enseignant <b>sadkfjsdlkf</b> est irréversible.<br><br>Voulez-vous le modifier ?",
content: "La modification de l'enseignant <b>"+local.firstName+" "+local.lastName+"</b> est irréversible.<br><br>Voulez-vous le modifier ?",
action: 'Modifier',
type: 'search'
}, (popup_rs) => { popup_rs && resolve() });
/* (4) On pop-up confirmation */
})).then(function(){
return new Promise( (resolve, reject) => {
/* (2.1) Delete professor */
/* (4.1) Delete professor */
api.call('PUT professor/'+prof_id, {}, function(rs){
/* (2.1.1) Abort on error */
/* (4.1.1) Abort on error */
if( rs.error !== 0 || rs.updated !== true )
return reject(rs.error);
/* (2.1.2) Success */
/* (4.1.2) Success */
resolve();
});
});
/* (3) On success */
/* (5) 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 */
/* update VueJS element */
// gstore.get.professors[gi];
/* (4) On error */
/* (6) On error */
}).catch(function(err_code){
popup.ask({