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

28 lines
909 B
Plaintext
Raw Normal View History

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