Switch to uirouter.
This commit is contained in:
parent
9910c0e0d3
commit
83d7e61875
@ -46,11 +46,12 @@
|
|||||||
"@nsalaun/ng-logger": "^2.0.1",
|
"@nsalaun/ng-logger": "^2.0.1",
|
||||||
"@types/angular": "^1.6.25",
|
"@types/angular": "^1.6.25",
|
||||||
"@types/node": "^8.0.10",
|
"@types/node": "^8.0.10",
|
||||||
|
"@uirouter/angularjs": "^1.0.5",
|
||||||
|
"@uirouter/core": "^5.0.5",
|
||||||
"angular": "^1.6",
|
"angular": "^1.6",
|
||||||
"angular-http-auth": "^1.5",
|
"angular-http-auth": "^1.5",
|
||||||
"angular-messages": "^1.6",
|
"angular-messages": "^1.6",
|
||||||
"angular-resource": "^1.6",
|
"angular-resource": "^1.6",
|
||||||
"angular-route": "^1.6.5",
|
|
||||||
"angular-strap": "^2.3.12",
|
"angular-strap": "^2.3.12",
|
||||||
"angular-ui-notification": "^0.3",
|
"angular-ui-notification": "^0.3",
|
||||||
"base64util": "^1.0.2",
|
"base64util": "^1.0.2",
|
||||||
|
@ -4,26 +4,39 @@ var operationsTmpl = require('./operations/operations.html');
|
|||||||
var accountsTmpl = require('./accounts/accounts.html');
|
var accountsTmpl = require('./accounts/accounts.html');
|
||||||
var schedulerTmpl = require('./scheduler/scheduler.html');
|
var schedulerTmpl = require('./scheduler/scheduler.html');
|
||||||
|
|
||||||
export default function AppConfig($routeProvider) {
|
export default function AppConfig($uiRouterProvider) {
|
||||||
|
$uiRouterProvider.trace.enable(1);
|
||||||
|
|
||||||
// Defining template and controller in function of route.
|
// Defining template and controller in function of route.
|
||||||
$routeProvider
|
const $stateRegistry = $uiRouterProvider.stateRegistry;
|
||||||
.when('/account/:accountId/operations', {
|
|
||||||
|
$stateRegistry.register({
|
||||||
|
name: 'operations',
|
||||||
|
url: '/account/:accountId/operations',
|
||||||
templateUrl: operationsTmpl,
|
templateUrl: operationsTmpl,
|
||||||
controller: 'OperationController',
|
controller: 'OperationController',
|
||||||
controllerAs: 'operationsCtrl'
|
controllerAs: 'operationsCtrl'
|
||||||
})
|
});
|
||||||
.when('/account/:accountId/scheduler', {
|
|
||||||
|
$stateRegistry.register({
|
||||||
|
name: 'scheduler',
|
||||||
|
url: '/account/:accountId/scheduler',
|
||||||
templateUrl: schedulerTmpl,
|
templateUrl: schedulerTmpl,
|
||||||
controller: 'SchedulerController',
|
controller: 'SchedulerController',
|
||||||
controllerAs: 'schedulerCtrl'
|
controllerAs: 'schedulerCtrl'
|
||||||
})
|
});
|
||||||
.when('/accounts', {
|
|
||||||
|
$stateRegistry.register({
|
||||||
|
name: 'accounts',
|
||||||
|
url: '/accounts',
|
||||||
templateUrl: accountsTmpl,
|
templateUrl: accountsTmpl,
|
||||||
controller: 'AccountController',
|
controller: 'AccountController',
|
||||||
controllerAs: 'accountsCtrl'
|
controllerAs: 'accountsCtrl'
|
||||||
})
|
});
|
||||||
.otherwise({
|
|
||||||
redirectTo: '/accounts'
|
const $urlService = $uiRouterProvider.urlService;
|
||||||
|
$urlService.rules.otherwise({
|
||||||
|
state: 'accounts'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
var angular = require('angular');
|
var angular = require('angular');
|
||||||
|
|
||||||
var ngRoute = require('angular-route');
|
import uiRouter from '@uirouter/angularjs';
|
||||||
|
|
||||||
import accountModule from '@accountant/accounts';
|
import accountModule from '@accountant/accounts';
|
||||||
import loginModule from '@accountant/login';
|
import loginModule from '@accountant/login';
|
||||||
@ -32,7 +32,7 @@ import AppConfig from './app.config.ts';
|
|||||||
require('bootstrap-webpack!./bootstrap.config.ts');
|
require('bootstrap-webpack!./bootstrap.config.ts');
|
||||||
|
|
||||||
angular.module('accountant', [
|
angular.module('accountant', [
|
||||||
ngRoute,
|
uiRouter,
|
||||||
accountModule,
|
accountModule,
|
||||||
loginModule,
|
loginModule,
|
||||||
operationModule,
|
operationModule,
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div ng-view></div>
|
<div ui-view></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Custom Javascript libraries -->
|
<!-- Custom Javascript libraries -->
|
||||||
|
@ -35,12 +35,12 @@ module.exports = angular.module('balanceChartModule', [
|
|||||||
account: '<',
|
account: '<',
|
||||||
onUpdate: '&'
|
onUpdate: '&'
|
||||||
},
|
},
|
||||||
controller: function($routeParams, Balances, $element) {
|
controller: function($stateParams, Balances, $element) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
vm.loadData = function() {
|
vm.loadData = function() {
|
||||||
Balances.query({
|
Balances.query({
|
||||||
id: $routeParams.accountId
|
id: $stateParams.accountId
|
||||||
}, function(results) {
|
}, function(results) {
|
||||||
var headers = [['date', 'balances', 'expenses', 'revenues']];
|
var headers = [['date', 'balances', 'expenses', 'revenues']];
|
||||||
|
|
||||||
|
@ -35,12 +35,12 @@ module.exports = angular.module('categoryChartModule', [
|
|||||||
minDate: '<',
|
minDate: '<',
|
||||||
maxDate: '<'
|
maxDate: '<'
|
||||||
},
|
},
|
||||||
controller: function($routeParams, $element, Categories, Incomes) {
|
controller: function($stateParams, $element, Categories, Incomes) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
vm.loadData = function() {
|
vm.loadData = function() {
|
||||||
Categories.query({
|
Categories.query({
|
||||||
id: $routeParams.accountId,
|
id: $stateParams.accountId,
|
||||||
begin: vm.minDate ? moment(vm.minDate).format('YYYY-MM-DD') : null,
|
begin: vm.minDate ? moment(vm.minDate).format('YYYY-MM-DD') : null,
|
||||||
end: vm.maxDate ? moment(vm.maxDate).format('YYYY-MM-DD') : null
|
end: vm.maxDate ? moment(vm.maxDate).format('YYYY-MM-DD') : null
|
||||||
}, function(results) {
|
}, function(results) {
|
||||||
|
@ -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($routeParams, $modal, Notification, Operation,
|
module.exports = function($stateParams, $modal, Notification, Operation,
|
||||||
AccountService) {
|
AccountService) {
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
@ -12,7 +12,7 @@ module.exports = function($routeParams, $modal, Notification, Operation,
|
|||||||
vm.add = function() {
|
vm.add = function() {
|
||||||
var operation = new Operation({
|
var operation = new Operation({
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
account_id: $routeParams.accountId
|
account_id: $stateParams.accountId
|
||||||
});
|
});
|
||||||
|
|
||||||
return vm.modify(operation);
|
return vm.modify(operation);
|
||||||
@ -27,7 +27,7 @@ module.exports = function($routeParams, $modal, Notification, Operation,
|
|||||||
|
|
||||||
return Operation.query({
|
return Operation.query({
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
account_id: $routeParams.accountId,
|
account_id: $stateParams.accountId,
|
||||||
begin: minDate ? moment(minDate).format('YYYY-MM-DD') : null,
|
begin: minDate ? moment(minDate).format('YYYY-MM-DD') : null,
|
||||||
end: maxDate ? moment(maxDate).format('YYYY-MM-DD') : null
|
end: maxDate ? moment(maxDate).format('YYYY-MM-DD') : null
|
||||||
});
|
});
|
||||||
@ -145,7 +145,7 @@ module.exports = function($routeParams, $modal, Notification, Operation,
|
|||||||
vm.operations = vm.load(minDate, maxDate);
|
vm.operations = vm.load(minDate, maxDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
AccountService.get($routeParams.accountId).subscribe(account => {
|
AccountService.get($stateParams.accountId).subscribe(account => {
|
||||||
vm.account = account
|
vm.account = account
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
var scheduleFormTmpl = require('./schedule.form.tmpl.html'),
|
var scheduleFormTmpl = require('./schedule.form.tmpl.html'),
|
||||||
scheduleDeleteTmpl = require('./schedule.delete.tmpl.html');
|
scheduleDeleteTmpl = require('./schedule.delete.tmpl.html');
|
||||||
|
|
||||||
module.exports= function($rootScope, $routeParams, Notification, ScheduledOperation, $log, $modal) {
|
module.exports= function($rootScope, $stateParams, Notification, ScheduledOperation, $log, $modal) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
// Operation store.
|
// Operation store.
|
||||||
@ -13,7 +13,7 @@ module.exports= function($rootScope, $routeParams, Notification, ScheduledOperat
|
|||||||
vm.add = function() {
|
vm.add = function() {
|
||||||
var operation = new ScheduledOperation({
|
var operation = new ScheduledOperation({
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
account_id: $routeParams.accountId
|
account_id: $stateParams.accountId
|
||||||
});
|
});
|
||||||
|
|
||||||
return vm.modify(operation);
|
return vm.modify(operation);
|
||||||
@ -25,7 +25,7 @@ module.exports= function($rootScope, $routeParams, Notification, ScheduledOperat
|
|||||||
vm.load = function() {
|
vm.load = function() {
|
||||||
return ScheduledOperation.query({
|
return ScheduledOperation.query({
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
account_id: $routeParams.accountId
|
account_id: $stateParams.accountId
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user