Replace angular-ui-notifications by toastr.

This commit is contained in:
Alexis Lahouze 2017-07-25 22:08:18 +02:00
parent cd7aba50e5
commit b3d274eabf
3 changed files with 13 additions and 8 deletions

View File

@ -1,6 +1,5 @@
@import '~font-awesome/less/font-awesome';
@import '~angular-ui-notification/src/angular-ui-notification';
@import (inline) '~c3/c3.css';

View File

@ -22,9 +22,14 @@ var moment = require('moment');
var angular = require('angular');
import {
downgradeInjectable,
} from '@angular/upgrade/static';
import { ToastrService } from 'ngx-toastr';
var ngResource = require('angular-resource'),
ngMessages = require('angular-messages'),
ngUiNotification = require('angular-ui-notification'),
ngStrap = require('angular-strap');
var balanceChartModule = require('./balance-chart.component'),
@ -38,13 +43,14 @@ var OperationController = require('./operation.controller');
export default angular.module('accountant.operations', [
ngResource,
ngMessages,
ngUiNotification,
ngStrap,
accountModule,
balanceChartModule,
categoryChartModule
])
.factory('toastrService', downgradeInjectable(ToastrService))
.factory('Operation', OperationFactory)
.controller('OperationController', OperationController)

View File

@ -1,7 +1,7 @@
var operationFormTmpl = require('./operation.form.tmpl.html'),
operationDeleteTmpl = require('./operation.delete.tmpl.html');
module.exports = function($stateParams, $modal, Notification, Operation,
module.exports = function($stateParams, $modal, toastrService, Operation,
AccountService) {
var vm = this;
@ -58,13 +58,13 @@ module.exports = function($stateParams, $modal, Notification, Operation,
operation.confirmed = true;
return operation.$save().then(function(operation) {
Notification.success('Operation #' + operation.id + ' saved.');
toastrService.success('Operation #' + operation.id + ' saved.');
vm.operations = vm.load();
return operation;
}, function(result){
Notification.error(
toastrService.error(
'Error while saving operation: ' + result.message
);
});
@ -98,13 +98,13 @@ module.exports = function($stateParams, $modal, Notification, Operation,
var id = operation.id;
return operation.$delete().then(function() {
Notification.success('Operation #' + id + ' deleted.');
toastrService.success('Operation #' + id + ' deleted.');
vm.operations = vm.load();
return operation;
}, function(result) {
Notification.error(
toastrService.error(
'An error occurred while trying to delete operation #' +
id + ':<br />' + result
);