1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

[admin] button to delete training from view + confirmation on machine/training deletion from view

This commit is contained in:
Sylvain 2016-09-27 15:32:49 +02:00
parent 9a71dc5ea2
commit b715078e83
5 changed files with 50 additions and 9 deletions

View File

@ -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
##

View File

@ -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)
##

View File

@ -18,6 +18,7 @@
<a ng-click="reserveTraining(training, $event)" class="btn btn-lg btn-warning bg-white b-2x rounded m-t-xs" ng-if="!isAuthorized('admin')" translate>{{ 'book_this_training' }}</a>
<a ui-sref="app.admin.trainings_edit({id: training.id})" ng-if="isAuthorized('admin')" class="btn btn-lg btn-warning bg-white b-2x rounded m-t-xs"><i class="fa fa-edit"></i> {{ 'edit' | translate }}</a>
<a ng-click="delete(training)" ng-if="isAuthorized('admin')" class="btn btn-lg btn-danger b-2x rounded no-b m-t-xs"><i class="fa fa-trash-o"></i></a>
</section>
</div>
</div>

View File

@ -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

View File

@ -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: