LP#626157 Combo experiements
authorBill Erickson <berickxx@gmail.com>
Mon, 5 Mar 2018 17:23:22 +0000 (17:23 +0000)
committerBill Erickson <berickxx@gmail.com>
Mon, 5 Mar 2018 17:24:06 +0000 (17:24 +0000)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/eg2-src/package.json
Open-ILS/eg2-src/src/app/app.module.ts
Open-ILS/src/templates/staff/base.tt2

index b67069b..b1f8c24 100644 (file)
@@ -21,6 +21,7 @@
     "@angular/platform-browser": "^5.0.0",
     "@angular/platform-browser-dynamic": "^5.0.0",
     "@angular/router": "^5.0.0",
+    "@angular/upgrade": "^5.2.6",
     "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
     "core-js": "^2.4.1",
     "jquery": "^3.2.1",
index e7a6198..e069594 100644 (file)
@@ -8,6 +8,10 @@ import {NgModule} from '@angular/core';
 import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; // ng-bootstrap
 import {CookieModule} from 'ngx-cookie'; // import CookieMonster
 
+// XXX required for multi-mode
+import {UpgradeModule} from '@angular/upgrade/static';
+import {Router} from '@angular/router';
+
 import {EgBaseComponent} from './app.component';
 import {EgBaseRoutingModule} from './routing.module';
 import {WelcomeComponent} from './welcome.component';
@@ -22,12 +26,18 @@ import {EgPermService} from '@eg/core/perm';
 import {EgPcrudService} from '@eg/core/pcrud';
 import {EgOrgService} from '@eg/core/org';
 
+// TODO: add environment controls for enabling multi-mode?
+// XXX required for multi-mode
+declare var angular: any;
+
+
 @NgModule({
   declarations: [
     EgBaseComponent,
     WelcomeComponent
   ],
   imports: [
+    UpgradeModule, // XXX multi-mode
     EgBaseRoutingModule,
     BrowserModule,
     NgbModule.forRoot(),
@@ -44,8 +54,38 @@ import {EgOrgService} from '@eg/core/org';
     EgOrgService
   ],
   exports: [],
-  bootstrap: [EgBaseComponent]
+  //bootstrap: [EgBaseComponent] // XXX multi-mode
 })
 
-export class EgBaseModule {}
+export class EgBaseModule {
+    
+    // XXX whole class def required for multi-mode only
+
+    constructor(
+        private upgrade: UpgradeModule,
+        private router: Router
+    ) {}
+
+    ngDoBootstrap() {
+        console.log('ngDoBootstrap()');
+
+        let myWin: any = window;
+
+        if (!myWin.ang1PageApp) {
+            console.error('NO PAGE APP DEFINED');
+            return;
+        }
+
+        /*
+        angular.module(myWin.ang1PageApp).directive('heroDetail',
+            downgradeComponent({ component: HeroDetailComponent })
+        );
+        */
+
+        // some of our ang1 apps are not strict-di compliant :(
+        this.upgrade.bootstrap(document.body, [myWin.ang1PageApp]);
+        //this.upgrade.bootstrap(document.body, [myWin.ang1PageApp], { strictDi: true });
+    }
+
+}
 
index 7ce42ae..a16acc2 100644 (file)
@@ -1,9 +1,15 @@
 <!doctype html>
 [%- PROCESS 'staff/config.tt2' %]
 <html lang="[% ctx.locale %]"
-    [%- IF ctx.page_app %] ng-app="[% ctx.page_app %]"[% END -%]
+    [%- IF ctx.page_app %] xng-app="[% ctx.page_app %]"[% END -%]
     [%- IF ctx.page_ctrl %] ng-controller="[% ctx.page_ctrl %]"[% END %]>
   <head>
+    <script>                                                                   
+      [%- IF ctx.page_app %]                                                   
+        // tell ang2 what ang1 wants to load.                                  
+        window.ang1PageApp = "[% ctx.page_app %]";                             
+      [% END -%]                                                               
+    </script> 
     <!-- enables ng-cloak to be usable before angular has been able to fully load -->
     <style type="text/css">
     [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
@@ -49,6 +55,9 @@
 
       # App-specific JS load commands go into an APP_JS block.
       PROCESS APP_JS;
+
+      # Angular2 scripts must be imported after app-specific ang1 imports
+      INCLUDE "staff/ang2_js.tt2";
     %]
 
     <!-- content printed via the browser is inserted here for