1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-04 15:24:23 +01:00
fab-manager/app/assets/javascripts/services/dialogs.coffee.erb

28 lines
967 B
Plaintext
Raw Normal View History

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
]