[webpack.teacher.view] instant-remove|instant-edit now have knowledge of the specified professor (from gstore.professors)
This commit is contained in:
parent
3f7aaee9b5
commit
7a3ac8ff64
|
@ -333,49 +333,51 @@ gstore.add('ir_handler', function(prof_id){
|
||||||
if( prof_id == null || isNaN(prof_id) )
|
if( prof_id == null || isNaN(prof_id) )
|
||||||
return;
|
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) => {
|
(new Promise( (resolve, reject) => {
|
||||||
|
|
||||||
popup.ask({
|
popup.ask({
|
||||||
title: 'Confirmation de suppression',
|
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',
|
action: 'Supprimer',
|
||||||
type: 'invalid'
|
type: 'invalid'
|
||||||
}, (popup_rs) => { popup_rs && resolve() });
|
}, (popup_rs) => { popup_rs && resolve() });
|
||||||
|
|
||||||
|
/* (4) On pop-up confirmation */
|
||||||
})).then(function(){
|
})).then(function(){
|
||||||
|
|
||||||
|
|
||||||
return new Promise( (resolve, reject) => {
|
return new Promise( (resolve, reject) => {
|
||||||
|
|
||||||
/* (2.1) Delete professor */
|
/* (4.1) Delete professor */
|
||||||
api.call('DELETE professor/'+prof_id, {}, function(rs){
|
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 )
|
if( rs.error !== 0 || rs.deleted !== true )
|
||||||
return reject(rs.error);
|
return reject(rs.error);
|
||||||
|
|
||||||
/* (2.1.2) Success */
|
/* (4.1.2) Success */
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* (3) On success */
|
/* (5) On success */
|
||||||
}).then(function(){
|
}).then(function(){
|
||||||
|
|
||||||
/* (3.1) Find index in gstore */
|
/* remove from visible */
|
||||||
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 */
|
|
||||||
gstore.get.professors.splice(gi, 1);
|
gstore.get.professors.splice(gi, 1);
|
||||||
|
|
||||||
|
|
||||||
/* (4) On error */
|
/* (6) On error */
|
||||||
}).catch(function(err_code){
|
}).catch(function(err_code){
|
||||||
|
|
||||||
popup.ask({
|
popup.ask({
|
||||||
|
@ -403,50 +405,51 @@ gstore.add('ie_handler', function(prof_id){
|
||||||
if( prof_id == null || isNaN(prof_id) )
|
if( prof_id == null || isNaN(prof_id) )
|
||||||
return;
|
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) => {
|
(new Promise( (resolve, reject) => {
|
||||||
|
|
||||||
popup.ask({
|
popup.ask({
|
||||||
title: 'Confirmation de modification',
|
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',
|
action: 'Modifier',
|
||||||
type: 'search'
|
type: 'search'
|
||||||
}, (popup_rs) => { popup_rs && resolve() });
|
}, (popup_rs) => { popup_rs && resolve() });
|
||||||
|
|
||||||
|
/* (4) On pop-up confirmation */
|
||||||
})).then(function(){
|
})).then(function(){
|
||||||
|
|
||||||
|
|
||||||
return new Promise( (resolve, reject) => {
|
return new Promise( (resolve, reject) => {
|
||||||
|
|
||||||
/* (2.1) Delete professor */
|
/* (4.1) Delete professor */
|
||||||
api.call('PUT professor/'+prof_id, {}, function(rs){
|
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 )
|
if( rs.error !== 0 || rs.updated !== true )
|
||||||
return reject(rs.error);
|
return reject(rs.error);
|
||||||
|
|
||||||
/* (2.1.2) Success */
|
/* (4.1.2) Success */
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* (3) On success */
|
/* (5) On success */
|
||||||
}).then(function(){
|
}).then(function(){
|
||||||
|
|
||||||
/* (3.1) Find index in gstore */
|
/* update VueJS element */
|
||||||
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];
|
// gstore.get.professors[gi];
|
||||||
|
|
||||||
|
|
||||||
|
/* (6) On error */
|
||||||
/* (4) On error */
|
|
||||||
}).catch(function(err_code){
|
}).catch(function(err_code){
|
||||||
|
|
||||||
popup.ask({
|
popup.ask({
|
||||||
|
|
Loading…
Reference in New Issue