diff --git a/app/assets/javascripts/controllers/machines.coffee.erb b/app/assets/javascripts/controllers/machines.coffee.erb
index 12af6cb96..1144abe3f 100644
--- a/app/assets/javascripts/controllers/machines.coffee.erb
+++ b/app/assets/javascripts/controllers/machines.coffee.erb
@@ -231,8 +231,8 @@ Application.Controllers.controller "EditMachineController", ["$scope", '$state',
##
# Controller used in the machine details page (public)
##
-Application.Controllers.controller "ShowMachineController", ['$scope', '$state', '$uibModal', '$stateParams', '_t', 'Machine', 'growl', 'machinePromise'
-, ($scope, $state, $uibModal, $stateParams, _t, Machine, growl, machinePromise) ->
+Application.Controllers.controller "ShowMachineController", ['$scope', '$state', '$uibModal', '$stateParams', '_t', 'Machine', 'growl', 'machinePromise', 'dialogs'
+, ($scope, $state, $uibModal, $stateParams, _t, Machine, growl, machinePromise, dialogs) ->
## Retrieve the details for the machine id in the URL, if an error occurs redirect the user to the machines list
$scope.machine = machinePromise
@@ -245,11 +245,17 @@ Application.Controllers.controller "ShowMachineController", ['$scope', '$state',
if $scope.currentUser.role isnt 'admin'
console.error _t('unauthorized_operation')
else
- # delete the machine then redirect to the machines listing
- machine.$delete ->
- $state.go('app.public.machines_list')
- , (error)->
- growl.warning(_t('the_machine_cant_be_deleted_because_it_is_already_reserved_by_some_users'))
+ dialogs.confirm
+ resolve:
+ object: ->
+ title: _t('confirmation_required')
+ msg: _t('do_you_really_want_to_delete_this_machine')
+ , -> # deletion confirmed
+ # delete the machine then redirect to the machines listing
+ machine.$delete ->
+ $state.go('app.public.machines_list')
+ , (error)->
+ growl.warning(_t('the_machine_cant_be_deleted_because_it_is_already_reserved_by_some_users'))
##
# Callback to book a reservation for the current machine
##
diff --git a/app/assets/javascripts/controllers/trainings.coffee.erb b/app/assets/javascripts/controllers/trainings.coffee.erb
index e7e955351..c712583ad 100644
--- a/app/assets/javascripts/controllers/trainings.coffee.erb
+++ b/app/assets/javascripts/controllers/trainings.coffee.erb
@@ -26,17 +26,43 @@ Application.Controllers.controller "TrainingsController", ['$scope', '$state', '
##
# Public view of a specific training
##
-Application.Controllers.controller "ShowTrainingController", ['$scope', '$state', 'trainingPromise', ($scope, $state, trainingPromise) ->
+Application.Controllers.controller "ShowTrainingController", ['$scope', '$state', 'trainingPromise', 'growl', '_t', 'dialogs', ($scope, $state, trainingPromise, growl, _t, dialogs) ->
## Current training
$scope.training = trainingPromise
+
+
+ ##
+ # Callback to delete the current training (admins only)
+ ##
+ $scope.delete = (training) ->
+ # check the permissions
+ if $scope.currentUser.role isnt 'admin'
+ console.error _t('unauthorized_operation')
+ else
+ dialogs.confirm
+ resolve:
+ object: ->
+ title: _t('confirmation_required')
+ msg: _t('do_you_really_want_to_delete_this_training')
+ , -> # deletion confirmed
+ # delete the training then redirect to the trainings listing
+ training.$delete ->
+ $state.go('app.public.trainings_list')
+ , (error)->
+ growl.warning(_t('the_training_cant_be_deleted_because_it_is_already_reserved_by_some_users'))
+
+
+
##
# Callback for the 'reserve' button
##
$scope.reserveTraining = (training, event) ->
$state.go('app.logged.trainings_reserve', {id: training.id})
+
+
##
# Revert view to the full list of trainings ("<-" button)
##
diff --git a/app/assets/templates/trainings/show.html.erb b/app/assets/templates/trainings/show.html.erb
index 2c470c4ad..c1ef7f3bc 100644
--- a/app/assets/templates/trainings/show.html.erb
+++ b/app/assets/templates/trainings/show.html.erb
@@ -18,6 +18,7 @@
{{ 'book_this_training' }}
{{ 'edit' | translate }}
+
diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml
index 411ff6589..296d8fa3d 100644
--- a/config/locales/app.public.en.yml
+++ b/config/locales/app.public.en.yml
@@ -179,7 +179,8 @@ en:
files_to_download: "Files to download"
projects_using_the_machine: "Projects using the machine"
_or_the_: " or the "
- unauthorized_operation: "Unauthoried operation"
+ do_you_really_want_to_delete_this_machine: "Do you really want to delete this machine?"
+ unauthorized_operation: "Unauthorized operation"
the_machine_cant_be_deleted_because_it_is_already_reserved_by_some_users: "The machine can't be deleted because it's already reserved by some users."
trainings_list:
@@ -189,6 +190,9 @@ en:
training_show:
# details of a training
book_this_training: "Book this training"
+ do_you_really_want_to_delete_this_training: "Do you really want to delete this training?"
+ unauthorized_operation: "Unauthorized operation"
+ the_training_cant_be_deleted_because_it_is_already_reserved_by_some_users: "The training can't be deleted because it's already reserved by some users."
plans:
# summary of the subscriptions
diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml
index 10e227a3f..d1a4420b3 100644
--- a/config/locales/app.public.fr.yml
+++ b/config/locales/app.public.fr.yml
@@ -178,6 +178,7 @@ fr:
files_to_download: "Fichiers à télécharger"
projects_using_the_machine: "Projets utilisant la machine"
_or_the_: " ou la "
+ do_you_really_want_to_delete_this_machine: "Êtes-vous sur de vouloir supprimer cette machine ?"
unauthorized_operation: "Opération non autorisée"
the_machine_cant_be_deleted_because_it_is_already_reserved_by_some_users: "La machine ne peut pas être supprimée car elle a déjà été réservée par des utilisateurs."
@@ -189,6 +190,9 @@ fr:
training_show:
# détails d'une formation
book_this_training: "Réserver cette formation"
+ do_you_really_want_to_delete_this_training: "Êtes-vous sur de vouloir supprimer cette formation ?"
+ unauthorized_operation: "Opération non autorisée"
+ the_training_cant_be_deleted_because_it_is_already_reserved_by_some_users: "La formation ne peut pas être supprimée car elle a déjà été réservée par des utilisateurs."
plans: