LP1819179 PCRUD selector fleshing handles maps
[Evergreen.git] / Open-ILS / src / eg2 / src / app / resolver.service.ts
1 import {Injectable} from '@angular/core';
2 import {Router, Resolve, RouterStateSnapshot,
3         ActivatedRouteSnapshot} from '@angular/router';
4 import {IdlService} from '@eg/core/idl.service';
5 import {OrgService} from '@eg/core/org.service';
6 import {LocaleService} from '@eg/core/locale.service';
7
8 // For locale application
9 declare var OpenSRF;
10
11 @Injectable()
12 export class BaseResolver implements Resolve<Promise<void>> {
13
14     constructor(
15         private router: Router,
16         private idl: IdlService,
17         private org: OrgService,
18         private locale: LocaleService
19     ) {}
20
21     /**
22      * Loads pre-auth data common to all applications.
23      * No auth token is available at this level.  When needed, auth is
24      * enforced by application/group-specific resolvers at lower levels.
25      */
26     resolve(
27         route: ActivatedRouteSnapshot,
28         state: RouterStateSnapshot): Promise<void> {
29
30         OpenSRF.locale = this.locale.currentLocaleCode();
31
32         this.idl.parseIdl();
33
34         return this.org.fetchOrgs(); // anonymous PCRUD.
35     }
36 }