2018-11-21 11:08:53 +01:00
|
|
|
'use strict';
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-20 13:46:28 +01:00
|
|
|
Application.Services.factory('dialogs', ['$uibModal', function ($uibModal) {
|
|
|
|
return ({
|
2018-10-25 16:51:20 +02:00
|
|
|
confirm (options, success, error) {
|
|
|
|
const defaultOpts = {
|
|
|
|
templateUrl: '<%= asset_path "shared/confirm_modal.html" %>',
|
|
|
|
size: 'sm',
|
|
|
|
resolve: {
|
|
|
|
object () {
|
|
|
|
return {
|
|
|
|
title: 'Titre de confirmation',
|
|
|
|
msg: 'Message de confirmation'
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
},
|
|
|
|
controller: ['$scope', '$uibModalInstance', '$state', 'object', function ($scope, $uibModalInstance, $state, object) {
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.object = object;
|
|
|
|
$scope.ok = function (info) { $uibModalInstance.close(info); };
|
|
|
|
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
2018-11-20 13:46:28 +01:00
|
|
|
}]
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
|
|
|
if (angular.isObject(options)) { angular.extend(defaultOpts, options); }
|
2018-10-25 16:51:20 +02:00
|
|
|
return $uibModal.open(defaultOpts)
|
|
|
|
.result['finally'](null).then(function (info) {
|
2018-10-25 16:50:16 +02:00
|
|
|
if (angular.isFunction(success)) {
|
2018-11-21 11:08:53 +01:00
|
|
|
return success(info);
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-25 16:51:20 +02:00
|
|
|
, function (reason) {
|
2018-10-25 16:50:16 +02:00
|
|
|
if (angular.isFunction(error)) {
|
2018-11-21 11:08:53 +01:00
|
|
|
return error(reason);
|
2018-10-25 16:50:16 +02:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
});
|
2018-10-25 16:51:20 +02:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
});
|
|
|
|
}]);
|