diff --git a/src/main.less b/src/main.less
index 2d6cce8..8fe1882 100644
--- a/src/main.less
+++ b/src/main.less
@@ -21,3 +21,21 @@
.c3-ygrid-line.overdraft line {
stroke: #FF0000;
}
+
+// Needed for modal backdrop opacity.
+.modal-backdrop.am-fade {
+ opacity: .5;
+ transition: opacity .15s linear;
+ &.ng-enter {
+ opacity: 0;
+ &.ng-enter-active {
+ opacity: .5;
+ }
+ }
+ &.ng-leave {
+ opacity: .5;
+ &.ng-leave-active {
+ opacity: 0;
+ }
+ }
+}
diff --git a/src/operations/index.js b/src/operations/index.js
index ad4eed9..a0e82be 100644
--- a/src/operations/index.js
+++ b/src/operations/index.js
@@ -31,14 +31,12 @@ var balanceChartModule = require('./balance-chart.component.js'),
var ngResource = require('angular-resource'),
ngMessages = require('angular-messages'),
- ngUiBootstrap = require('angular-ui-bootstrap'),
ngUiNotification = require('angular-ui-notification'),
ngStrap = require('angular-strap');
module.exports = angular.module('accountant.operations', [
ngResource,
ngMessages,
- ngUiBootstrap,
ngUiNotification,
ngStrap,
accountModule,
@@ -62,8 +60,8 @@ module.exports = angular.module('accountant.operations', [
/*
* Controller for the operations.
*/
- .controller('OperationController', function($routeParams, $uibModal,
- Notification, Operation, Account, $log, $q) {
+ .controller('OperationController', function($routeParams, $modal,
+ Notification, Operation, Account, $log) {
var vm = this;
@@ -113,7 +111,7 @@ module.exports = angular.module('accountant.operations', [
};
/*
- * Save an operation and return a promise.
+ * Save an operation and return a promise.
*/
vm.save = function(operation) {
operation.confirmed = true;
@@ -130,41 +128,47 @@ module.exports = angular.module('accountant.operations', [
Notification.error(
'Error while saving operation: ' + result.message
);
-
- return $q.reject(result);
});
};
/*
* Delete an operation and return a promise.
*/
+ vm.confirmDelete = function(operation) {
+ var title = "Delete operation #" + operation.id;
+
+ $modal({
+ templateUrl: operationDeleteTmpl,
+ controller: function($scope, title, operation, $delete) {
+ $scope.title = title;
+ $scope.operation = operation;
+ $scope.$delete = function() {
+ $scope.$hide();
+ $delete($scope.operation);
+ };
+ },
+ locals: {
+ title: title,
+ operation: operation,
+ $delete: vm.delete
+ }
+ });
+ };
+
vm.delete = function(operation) {
var id = operation.id;
- $uibModal.open({
- component: 'operationDeleteModalComponent',
- resolve: {
- operation: function() {
- return operation;
- }
- }
- }).result.then(function(operation) {
- return operation.$delete().then(function() {
- Notification.success('Operation #' + id + ' deleted.');
+ return operation.$delete().then(function() {
+ Notification.success('Operation #' + id + ' deleted.');
- vm.operations = vm.load();
+ vm.operations = vm.load();
- return operation;
- }, function(result) {
- Notification.error(
- 'An error occurred while trying to delete operation #' +
- id + ':
' + result
- );
-
- return $q.reject(result);
- });
- }, function() {
- return false;
+ return operation;
+ }, function(result) {
+ Notification.error(
+ 'An error occurred while trying to delete operation #' +
+ id + ':
' + result
+ );
});
};
@@ -173,17 +177,28 @@ module.exports = angular.module('accountant.operations', [
* @returns a promise.
*/
vm.modify = function(operation) {
- return $uibModal.open({
- component: 'operationModifyModalComponent',
- resolve: {
- operation: function() {
- return operation;
- }
+ // FIXME Alexis Lahouze 2017-06-15 i18n
+ var title = "Operation";
+
+ if (operation.id) {
+ title = title + " #" + operation.id;
+ }
+
+ $modal({
+ templateUrl: operationFormTmpl,
+ controller: function($scope, title, operation, $save) {
+ $scope.title = title;
+ $scope.operation = operation;
+ $scope.$save = function() {
+ $scope.$hide();
+ $save($scope.operation);
+ };
+ },
+ locals: {
+ title: title,
+ operation: operation,
+ $save: vm.save
}
- }).result.then(function(operation) {
- return vm.save(operation);
- }, function() {
- return false;
});
};
@@ -194,78 +209,4 @@ module.exports = angular.module('accountant.operations', [
vm.account = Account.get({id: $routeParams.accountId});
})
- .component('operationModifyModalComponent', {
- templateUrl: operationFormTmpl,
- bindings: {
- resolve: '<',
- close: '&',
- dismiss: '&'
- },
- controller: function() {
- var vm = this;
-
- vm.$onInit = function() {
- vm.operation = vm.resolve.operation;
- };
-
- vm.ok = function() {
- vm.close({
- $value: vm.operation
- });
- };
-
- vm.cancel = function() {
- vm.dismiss({
- $value: 'cancel'
- });
- };
-
- vm.title = function() {
- // FIXME Alexis Lahouze 2017-06-15 i18n
- if (vm.operation.id) {
- return "Operation #" + vm.operation.id;
- } else {
- return "Operation";
- }
- };
- }
- })
-
- .component('operationDeleteModalComponent', {
- templateUrl: operationDeleteTmpl,
- bindings: {
- resolve: '<',
- close: '&',
- dismiss: '&'
- },
- controller: function() {
- var vm = this;
-
- vm.$onInit = function() {
- vm.operation = vm.resolve.operation;
- };
-
- vm.ok = function() {
- vm.close({
- $value: vm.operation
- });
- };
-
- vm.cancel = function() {
- vm.dismiss({
- $value: 'cancel'
- });
- };
-
- vm.title = function() {
- // FIXME Alexis Lahouze 2017-06-15 i18n
- if (vm.operation.id) {
- return "Operation #" + vm.operation.id;
- } else {
- return "Operation";
- }
- };
- }
- })
-
.name;
diff --git a/src/operations/operation.delete.tmpl.html b/src/operations/operation.delete.tmpl.html
index 545ce03..6e79db9 100644
--- a/src/operations/operation.delete.tmpl.html
+++ b/src/operations/operation.delete.tmpl.html
@@ -1,16 +1,24 @@
-