2015-05-05 03:10:25 +02:00
|
|
|
'use strict'
|
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
Application.Services.factory 'dialogs', ["$uibModal", ($uibModal) ->
|
2015-05-05 03:10:25 +02:00
|
|
|
confirm: (options, success, error)->
|
|
|
|
defaultOpts =
|
|
|
|
templateUrl: '<%= asset_path "shared/confirm_modal.html" %>'
|
|
|
|
size: 'sm'
|
|
|
|
resolve:
|
|
|
|
object: ->
|
|
|
|
title: 'Titre de confirmation'
|
2016-03-23 18:39:41 +01:00
|
|
|
msg: 'Message de confirmation'
|
|
|
|
controller: ['$scope', '$uibModalInstance', '$state', 'object', ($scope, $uibModalInstance, $state, object) ->
|
2015-05-05 03:10:25 +02:00
|
|
|
$scope.object = object
|
2016-03-23 18:39:41 +01:00
|
|
|
$scope.ok = (info) ->
|
|
|
|
$uibModalInstance.close( info )
|
2015-05-05 03:10:25 +02:00
|
|
|
$scope.cancel = ->
|
2016-03-23 18:39:41 +01:00
|
|
|
$uibModalInstance.dismiss('cancel')
|
2015-05-05 03:10:25 +02:00
|
|
|
]
|
|
|
|
angular.extend(defaultOpts, options) if angular.isObject options
|
2016-03-23 18:39:41 +01:00
|
|
|
$uibModal.open defaultOpts
|
|
|
|
.result['finally'](null).then (info)->
|
2015-05-05 03:10:25 +02:00
|
|
|
if angular.isFunction(success)
|
2016-03-23 18:39:41 +01:00
|
|
|
success(info)
|
|
|
|
, (reason)->
|
2015-05-05 03:10:25 +02:00
|
|
|
if angular.isFunction(error)
|
2016-03-23 18:39:41 +01:00
|
|
|
error(reason)
|
2015-05-05 03:10:25 +02:00
|
|
|
]
|