LP#1626157 more service downgrades; docs
authorBill Erickson <berickxx@gmail.com>
Thu, 8 Mar 2018 16:29:21 +0000 (16:29 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 8 Mar 2018 16:29:21 +0000 (16:29 +0000)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/eg2-src/src/app/migration.module.ts
Open-ILS/eg2-src/src/app/resolver.service.ts
Open-ILS/eg2-src/src/app/routing.module.ts
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js

index 2c0c73f..f6783eb 100644 (file)
@@ -1,6 +1,9 @@
 /**
  * EgMigrationModule
  *
+ * This module has no internal components or routing.  It's just a 
+ * pass-through for AngularJS.
+ *
  * 1. Loads the ang1 => ang2 upgrade components.
  * 2. Downgrades and injects shared ang2 services and components for use
  *    by ang1.
@@ -15,6 +18,7 @@ import {UpgradeModule, downgradeInjectable,
     downgradeComponent} from '@angular/upgrade/static';
 
 // Import and provide some Angular built-ins
+// TODO: string interpolation a la ang1 egStrings titles
 import {Title} from '@angular/platform-browser';
 
 // Import and 'provide' globally required Evergreen services.
@@ -55,7 +59,7 @@ export class EgMigrationModule {
     constructor(private upgrade: UpgradeModule) {}
 
     ngDoBootstrap() {
-        let myWin: any = window; // make TS happy
+        let myWin: any = window; // avoid TS compiler warnings
 
         if (!myWin.ang1PageApp) {
             console.error('NO PAGE APP DEFINED');
@@ -69,7 +73,15 @@ export class EgMigrationModule {
             .directive('heroDetail', 
                 downgradeComponent({ component: HeroDetailComponent })
             */
-            .factory('eg2Net', downgradeInjectable(EgNetService))
+
+            .factory('eg2Event', downgradeInjectable(EgEventService))
+            .factory('eg2Store', downgradeInjectable(EgStoreService))
+            .factory('eg2Idl',   downgradeInjectable(EgIdlService))
+            .factory('eg2Net',   downgradeInjectable(EgNetService))
+            .factory('eg2Auth',  downgradeInjectable(EgAuthService))
+            .factory('eg2Perm',  downgradeInjectable(EgPermService))
+            .factory('eg2Pcrud', downgradeInjectable(EgPcrudService))
+            .factory('eg2Org',   downgradeInjectable(EgOrgService))
             .factory('ng2Title', downgradeInjectable(Title))
         ;
 
index 7ffa74b..8fd14d7 100644 (file)
@@ -13,19 +13,19 @@ export class EgBaseResolver implements Resolve<Promise<void>> {
         private org: EgOrgService,
     ) {}
 
+    /**
+     * Loads pre-auth data common to all applications.
+     * No auth token is available at this level.  When needed, auth is 
+     * enforced by application/group-specific resolvers at lower levels.
+     */
     resolve(
         route: ActivatedRouteSnapshot, 
         state: RouterStateSnapshot): Promise<void> {
 
         console.debug('EgBaseResolver:resolve()');
 
-        // Load data common to all applications.
-
         this.idl.parseIdl();
 
-        return this.org.fetchOrgs();
-        // Note that authentication happens at a deeper level, since 
-        // some applications (e.g. a public catalog) do not require
-        // up-front authentication to access.
+        return this.org.fetchOrgs(); // anonymous PCRUD.
     }
 }
index 7d7e70e..ba78449 100644 (file)
@@ -4,9 +4,11 @@ import { EgBaseResolver }       from './resolver.service';
 import { WelcomeComponent }     from './welcome.component';
 
 /**
- * Avoid requiring all apps to load all JS by lazy-loading sub-modules.
+ * Avoid loading all application JS up front 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.
+ * These modules are encoded as separate JS chunks that are fetched
+ * from the server only when needed.
  */
 const routes: Routes = [
   { path: '',
index 0c7b1bb..a9afc99 100644 (file)
@@ -35,9 +35,11 @@ angular.module('egCheckinApp', ['ngRoute', 'ui.bootstrap',
  */
 .controller('CheckinCtrl',
        ['$scope','$q','$window','$location', '$timeout','egCore',
-        'checkinSvc','egGridDataProvider','egCirc','egItem','eg2Net','ng2Title',
+        'checkinSvc','egGridDataProvider','egCirc','egItem','eg2Net',
+        'eg2Store','ng2Title',
 function($scope , $q , $window , $location , $timeout , egCore , 
-         checkinSvc , egGridDataProvider , egCirc, itemSvc , eg2Net , ng2Title)  {
+         checkinSvc , egGridDataProvider , egCirc, itemSvc , eg2Net , 
+         eg2Store , ng2Title)  {
 
     // TODO: TESTING
     eg2Net.request('open-ils.actor', 'opensrf.system.echo', 'Hello, Ang2')
@@ -57,7 +59,7 @@ function($scope , $q , $window , $location , $timeout , egCore ,
     $scope.grid_persist_key = $scope.is_capture ? 
         'circ.checkin.capture' : 'circ.checkin.checkin';
 
-    egCore.hatch.getItem('circ.checkin.strict_barcode')
+    eg2Store.getItem('circ.checkin.strict_barcode')
         .then(function(sb){ $scope.strict_barcode = sb });
 
     egCore.org.settings([
@@ -97,7 +99,7 @@ function($scope , $q , $window , $location , $timeout , egCore ,
 
     // set modifiers from stored preferences
     angular.forEach(modifiers, function(mod) {
-        egCore.hatch.getItem('eg.circ.checkin.' + mod)
+        eg2Store.getItem('eg.circ.checkin.' + mod)
         .then(function(val) { if (val) $scope.modifiers[mod] = true });
     });
 
@@ -106,10 +108,10 @@ function($scope , $q , $window , $location , $timeout , egCore ,
     $scope.toggle_mod = function(mod) {
         if ($scope.modifiers[mod]) {
             $scope.modifiers[mod] = false;
-            egCore.hatch.removeItem('eg.circ.checkin.' + mod);
+            eg2Store.removeItem('eg.circ.checkin.' + mod);
         } else {
             $scope.modifiers[mod] = true;
-            egCore.hatch.setItem('eg.circ.checkin.' + mod, true);
+            eg2Store.setItem('eg.circ.checkin.' + mod, true);
         }
     }
 
@@ -162,7 +164,7 @@ function($scope , $q , $window , $location , $timeout , egCore ,
             }
         }
 
-        egCore.hatch.setItem('circ.checkin.strict_barcode', $scope.strict_barcode);
+        eg2Store.setItem('circ.checkin.strict_barcode', $scope.strict_barcode);
         var options = {
             check_barcode : $scope.strict_barcode,
             no_precat_alert : $scope.modifiers.no_precat_alert,