From a2d575e94f627839a0fa401791a5e3911bccf755 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sat, 11 Nov 2017 12:56:46 +0100 Subject: [PATCH] Added confirmation Pop-Up for: 1. history.archive 2. machine.delete 3. user.delete --- public_html/view/js/history.js | 27 +++++++++++++++++++++++---- public_html/view/js/machines.js | 24 +++++++++++++++++++++--- public_html/view/js/settings.js | 2 +- public_html/view/js/users.js | 24 +++++++++++++++++++++--- 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/public_html/view/js/history.js b/public_html/view/js/history.js index 6350a6d..9091dbd 100644 --- a/public_html/view/js/history.js +++ b/public_html/view/js/history.js @@ -119,12 +119,31 @@ if( section.archive.element != null ){ e.preventDefault(); - api.send({path: 'historyDefault/archive'}, function(result){ - if( result.error == 0 ){ + /* (2) Create popup */ + var PopupManager = new Popup(); - document.location = result.link; + var confirm_content = { + title: "Archivage de l'historique", + content: "L'historique sera définitivement supprimé de la plateforme après la création de l'archive. Cette opération ne peut être annulée.", + type: "search", + action: "Archiver" + }; + + /* (3) Ask for confirmation */ + PopupManager.ask(confirm_content, function(is_confirmed){ + + // {3.1} If cancelled -> abort // + if( !is_confirmed ) + return; + + // {3.2} Manage request // + api.send({path: 'historyDefault/archive'}, function(result){ + + if( result.error == 0 ) + document.location = result.link; + + }); - } }); }, false); diff --git a/public_html/view/js/machines.js b/public_html/view/js/machines.js index 65810c7..746813c 100755 --- a/public_html/view/js/machines.js +++ b/public_html/view/js/machines.js @@ -503,8 +503,26 @@ if( section.remove.element != null ){ // On annule l'envoi de base (PHP) e.preventDefault(); - // Si l'id est defini - if( section.remove.input.search.id.value != '' ){ + // Si l'id n'est pas défini -> abort + if( section.remove.input.search.id.value == '' ) + return; + + /* (1) Create popup */ + var PopupManager = new Popup(); + + var confirm_content = { + title: "Suppression de machine", + content: "La machine "+section.remove.input.name.value+" sera définitivement supprimée de la plateforme. Cette opération ne peut être annulée.", + type: "invalid", + action: "Supprimer" + }; + + /* (2) Ask for confirmation */ + PopupManager.ask(confirm_content, function(is_confirmed){ + + // {2.1} If cancelled -> abort // + if( !is_confirmed ) + return; /* (2) On supprime la machine */ var request = { @@ -548,7 +566,7 @@ if( section.remove.element != null ){ console.error('ModuleError::'+answer.error); }); - } + }); }, false); diff --git a/public_html/view/js/settings.js b/public_html/view/js/settings.js index 4ac2cdf..6021240 100755 --- a/public_html/view/js/settings.js +++ b/public_html/view/js/settings.js @@ -135,7 +135,7 @@ if( section.admins.element != null ){ /* (3) Ask for confirmation */ PopupManager.ask(confirm_content, function(is_confirmed){ - /* (3.1) If not cancelled -> abort */ + /* (3.1) If cancelled -> abort */ if( !is_confirmed ) return; diff --git a/public_html/view/js/users.js b/public_html/view/js/users.js index 972b138..5a9f1c9 100755 --- a/public_html/view/js/users.js +++ b/public_html/view/js/users.js @@ -543,8 +543,26 @@ if( section.remove.element != null ){ // On annule l'envoi de base (PHP) e.preventDefault(); - // Si l'id est defini - if( section.remove.input.search.id.value != '' ){ + // Si l'id n'est pas defini -> abort + if( section.remove.input.search.id.value == '' ) + return; + + /* (1) Create popup */ + var PopupManager = new Popup(); + + var confirm_content = { + title: "Suppression d'utilisateur", + content: "L'utilisateur "+section.remove.input.username.value+" sera définitivement supprimé de la plateforme. Cette opération ne peut être annulée.", + type: "invalid", + action: "Supprimer" + }; + + /* (2) Ask for confirmation */ + PopupManager.ask(confirm_content, function(is_confirmed){ + + // {2.1} If cancelled -> abort // + if( !is_confirmed ) + return; /* (2) On supprime l'utilisateur */ var request = { @@ -589,7 +607,7 @@ if( section.remove.element != null ){ }); - } + }); }, false); }