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 '~font-awesome/less/font-awesome';
@import '~angular-ui-notification/src/angular-ui-notification';
@import (inline) '~c3/c3.css'; @import (inline) '~c3/c3.css';

View File

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

View File

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