From 355a4f1cbb972c39b5cd7a8a2e7280e7e7de0ff1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 22 Nov 2017 11:06:46 -0500 Subject: [PATCH] LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- Open-ILS/webby-src/src/app/base.module.ts | 2 +- ...ase-resolver.service.ts => resolver.service.ts} | 0 .../{base-routing.module.ts => routing.module.ts} | 4 ++-- .../webby-src/src/app/staff/auth-guard.service.ts | 2 +- Open-ILS/webby-src/src/app/staff/routing.module.ts | 24 +++++++++++++--------- 5 files changed, 18 insertions(+), 14 deletions(-) rename Open-ILS/webby-src/src/app/{base-resolver.service.ts => resolver.service.ts} (100%) rename Open-ILS/webby-src/src/app/{base-routing.module.ts => routing.module.ts} (83%) diff --git a/Open-ILS/webby-src/src/app/base.module.ts b/Open-ILS/webby-src/src/app/base.module.ts index 27dca353a7..553e8aa0cc 100644 --- a/Open-ILS/webby-src/src/app/base.module.ts +++ b/Open-ILS/webby-src/src/app/base.module.ts @@ -10,7 +10,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { CookieModule } from 'ngx-cookie'; // import CookieMonster import { EgBaseComponent } from './base.component'; -import { EgBaseRoutingModule } from './base-routing.module'; +import { EgBaseRoutingModule } from './routing.module'; import { WelcomeComponent } from './welcome.component'; // Import and 'provide' globally required services. diff --git a/Open-ILS/webby-src/src/app/base-resolver.service.ts b/Open-ILS/webby-src/src/app/resolver.service.ts similarity index 100% rename from Open-ILS/webby-src/src/app/base-resolver.service.ts rename to Open-ILS/webby-src/src/app/resolver.service.ts diff --git a/Open-ILS/webby-src/src/app/base-routing.module.ts b/Open-ILS/webby-src/src/app/routing.module.ts similarity index 83% rename from Open-ILS/webby-src/src/app/base-routing.module.ts rename to Open-ILS/webby-src/src/app/routing.module.ts index 7280e37f9e..8085267fa9 100644 --- a/Open-ILS/webby-src/src/app/base-routing.module.ts +++ b/Open-ILS/webby-src/src/app/routing.module.ts @@ -1,10 +1,10 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { EgBaseResolver } from './base-resolver.service'; +import { EgBaseResolver } from './resolver.service'; import { WelcomeComponent } from './welcome.component'; /** - * Avoid adding bulk to the base module by lazy-loading sub-modules. + * Avoid requiring all apps to load all JS by lazy-loading sub-modules. * When lazy loading, no module references should be directly imported. * The refs are encoded in the loadChildren attribute of each route. */ diff --git a/Open-ILS/webby-src/src/app/staff/auth-guard.service.ts b/Open-ILS/webby-src/src/app/staff/auth-guard.service.ts index f2c276a2f8..d54ec410bc 100644 --- a/Open-ILS/webby-src/src/app/staff/auth-guard.service.ts +++ b/Open-ILS/webby-src/src/app/staff/auth-guard.service.ts @@ -27,7 +27,7 @@ export class EgStaffAuthGuard implements CanActivate, CanActivateChild { err => { this.egAuth.redirectUrl = state.url; this.router.navigate(['/staff/login']); - resolve(false); + resolve(false); // cannot activate } ); }); diff --git a/Open-ILS/webby-src/src/app/staff/routing.module.ts b/Open-ILS/webby-src/src/app/staff/routing.module.ts index df2d784d51..615c3e3c96 100644 --- a/Open-ILS/webby-src/src/app/staff/routing.module.ts +++ b/Open-ILS/webby-src/src/app/staff/routing.module.ts @@ -18,21 +18,25 @@ const routes: Routes = [{ path: 'logout', component: EgStaffLogoutComponent }, { - // Every path below here requires a valid authtoken. path: '', + // Require a valid authtoken to access child paths canActivate : [EgStaffAuthGuard], + // Load data common to all staff UI's before loading child paths. resolve: {dataResolver: EgStaffDataResolver}, + // EgStaffComponent houses the navbar and the page content shell. component: EgStaffComponent, children: [{ - path: '', - redirectTo: 'splash' - pathMatch: 'full', - }, { - path: 'splash', - component: EgStaffSplashComponent - }, { - path: 'circ', - loadChildren : '@eg/staff/circ/circ.module#EgCircModule' + path: '', + redirectTo: 'splash', // must be to sibling path + pathMatch: 'full', + }, { + path: 'splash', + component: EgStaffSplashComponent + }, { + // Lazy-load collections of sub-modules (circ, cat, etc.) + // with loadChildren + path: 'circ', + loadChildren : '@eg/staff/circ/circ.module#EgCircModule' }] }] }]; -- 2.11.0