blob: 17b30526c9eec897f8eadf1d97dc9e0e430dbf03 [file] [log] [blame]
Matteo Scandolo5d962a32017-08-01 18:16:14 -07001import {IXosModelRelation} from '../../views/crud/crud';
Matteo Scandolo1aee1982017-02-17 08:33:23 -08002export interface IXosState extends angular.ui.IState {
3 data: {
Matteo Scandolo5d962a32017-08-01 18:16:14 -07004 model: string,
5 relations?: IXosModelRelation[]
Matteo Scandolo1aee1982017-02-17 08:33:23 -08006 };
7};
8
9export interface IXosRuntimeStatesService {
Matteo Scandoloe0d71ea2016-12-19 11:56:12 -080010 addState(name: string, state: ng.ui.IState): void;
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080011}
12
Matteo Scandolo1aee1982017-02-17 08:33:23 -080013export function XosRuntimeStates($stateProvider: ng.ui.IStateProvider): ng.IServiceProvider {
Matteo Scandoloe0d71ea2016-12-19 11:56:12 -080014 this.$get = function($state: ng.ui.IStateService) {
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080015 return {
16 addState: function(name: string, state: IXosState) {
Matteo Scandolo0e363772017-01-13 11:41:29 -080017 // prevent to add multiple time the same state
18 if (!$state.get(name)) {
19 $stateProvider.state(name, state);
20 }
Matteo Scandolof2c3ed62016-12-15 14:32:50 -080021 }
22 };
23 };
24 return this;
25}