Matteo Scandolo | 5d962a3 | 2017-08-01 18:16:14 -0700 | [diff] [blame] | 1 | import {IXosModelRelation} from '../../views/crud/crud'; |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 2 | export interface IXosState extends angular.ui.IState { |
| 3 | data: { |
Matteo Scandolo | 5d962a3 | 2017-08-01 18:16:14 -0700 | [diff] [blame] | 4 | model: string, |
| 5 | relations?: IXosModelRelation[] |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 6 | }; |
| 7 | }; |
| 8 | |
| 9 | export interface IXosRuntimeStatesService { |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 10 | addState(name: string, state: ng.ui.IState): void; |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 11 | } |
| 12 | |
Matteo Scandolo | 1aee198 | 2017-02-17 08:33:23 -0800 | [diff] [blame] | 13 | export function XosRuntimeStates($stateProvider: ng.ui.IStateProvider): ng.IServiceProvider { |
Matteo Scandolo | e0d71ea | 2016-12-19 11:56:12 -0800 | [diff] [blame] | 14 | this.$get = function($state: ng.ui.IStateService) { |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 15 | return { |
| 16 | addState: function(name: string, state: IXosState) { |
Matteo Scandolo | 0e36377 | 2017-01-13 11:41:29 -0800 | [diff] [blame] | 17 | // prevent to add multiple time the same state |
| 18 | if (!$state.get(name)) { |
| 19 | $stateProvider.state(name, state); |
| 20 | } |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 21 | } |
| 22 | }; |
| 23 | }; |
| 24 | return this; |
| 25 | } |