From a7cee2891cfd06bfd5347237fb856d9e841ff759 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Mon, 24 Jul 2017 18:48:57 +0200 Subject: [PATCH] Move states in separate files. --- src/accounts/account.states.ts | 7 +++++++ src/app.config.ts | 32 ++++++------------------------ src/operations/operation.states.ts | 11 ++++++++++ src/scheduler/schedule.states.ts | 17 ++++++++++++++++ 4 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 src/accounts/account.states.ts create mode 100644 src/operations/operation.states.ts create mode 100644 src/scheduler/schedule.states.ts diff --git a/src/accounts/account.states.ts b/src/accounts/account.states.ts new file mode 100644 index 0000000..e691de6 --- /dev/null +++ b/src/accounts/account.states.ts @@ -0,0 +1,7 @@ +// vim: set tw=80 ts=2 sw=2 sts=2 : + +export const AccountListState = { + name: 'accounts', + url: '/accounts', + component: 'accountList' +} diff --git a/src/app.config.ts b/src/app.config.ts index 035c0d7..b0d3f3d 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -1,7 +1,9 @@ // vim: set tw=80 ts=2 sw=2 sts=2 : import { Level } from '@nsalaun/ng-logger'; -var operationsTmpl = require('./operations/operations.html'); +import { AccountListState } from './accounts/account.states'; +import { OperationListState } from './operations/operation.states'; +import { ScheduleListState } from './scheduler/schedule.states'; export default function AppConfig($uiRouterProvider) { $uiRouterProvider.trace.enable(1); @@ -9,33 +11,11 @@ export default function AppConfig($uiRouterProvider) { // Defining template and controller in function of route. const $stateRegistry = $uiRouterProvider.stateRegistry; - $stateRegistry.register({ - name: 'operations', - url: '/account/:accountId/operations', - templateUrl: operationsTmpl, - controller: 'OperationController', - controllerAs: 'operationsCtrl' - }); + $stateRegistry.register(OperationListState); - $stateRegistry.register({ - name: 'scheduler', - url: '/account/:accountId/scheduler', - component: 'scheduleComponent', - resolve: { - accountId: function($transition$) { - return $transition$.params().accountId; - }, - $modal: function($modal) { - return $modal; - } - } - }); + $stateRegistry.register(ScheduleListState); - $stateRegistry.register({ - name: 'accounts', - url: '/accounts', - component: 'accountList', - }); + $stateRegistry.register(AccountListState); const $urlService = $uiRouterProvider.urlService; $urlService.rules.otherwise({ diff --git a/src/operations/operation.states.ts b/src/operations/operation.states.ts new file mode 100644 index 0000000..0998ad9 --- /dev/null +++ b/src/operations/operation.states.ts @@ -0,0 +1,11 @@ +// vim: set tw=80 ts=2 sw=2 sts=2 : + +var operationsTmpl = require('./operations.html'); + +export const OperationListState = { + name: 'operations', + url: '/account/:accountId/operations', + templateUrl: operationsTmpl, + controller: 'OperationController', + controllerAs: 'operationsCtrl' +} diff --git a/src/scheduler/schedule.states.ts b/src/scheduler/schedule.states.ts new file mode 100644 index 0000000..a3b0eae --- /dev/null +++ b/src/scheduler/schedule.states.ts @@ -0,0 +1,17 @@ +// vim: set tw=80 ts=2 sw=2 sts=2 : + +import { ScheduleComponent } from './schedule.component'; + +export const ScheduleListState = { + name: 'scheduler', + url: '/account/:accountId/scheduler', + component: 'scheduleComponent', + resolve: { + accountId: function($transition$) { + return $transition$.params().accountId; + }, + $modal: function($modal) { + return $modal; + } + } +}