LP#1626157 Dependancy cleanup ; avoid importing parent modules
authorBill Erickson <berickxx@gmail.com>
Wed, 4 Apr 2018 20:39:18 +0000 (20:39 +0000)
committerBill Erickson <berickxx@gmail.com>
Wed, 4 Apr 2018 20:39:20 +0000 (20:39 +0000)
Importing the route-parent module wreaks havoc with the router.
Instead, put shared imports into separate "Common" modules for direct
import of child modules.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
16 files changed:
Open-ILS/src/eg2/src/app/app.module.ts
Open-ILS/src/eg2/src/app/common.module.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/routing.module.ts
Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.html
Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.module.ts
Open-ILS/src/eg2/src/app/staff/app.module.ts
Open-ILS/src/eg2/src/app/staff/catalog/app.module.ts
Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.module.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/routing.module.ts
Open-ILS/src/eg2/src/app/staff/circ/routing.module.ts
Open-ILS/src/eg2/src/app/staff/common.module.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/staff-banner.component.ts [new file with mode: 0644]
Open-ILS/src/templates/staff/navbar.tt2

index 146cd30..47c2093 100644 (file)
@@ -8,6 +8,7 @@ import {NgModule} from '@angular/core';
 import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; // ng-bootstrap
 import {CookieModule} from 'ngx-cookie'; // import CookieMonster
 
+import {EgCommonModule} from './common.module';
 import {EgBaseComponent} from './app.component';
 import {EgBaseRoutingModule} from './routing.module';
 import {WelcomeComponent} from './welcome.component';
@@ -28,6 +29,7 @@ import {EgOrgService} from '@eg/core/org';
     WelcomeComponent
   ],
   imports: [
+    EgCommonModule,
     EgBaseRoutingModule,
     BrowserModule,
     NgbModule.forRoot(),
diff --git a/Open-ILS/src/eg2/src/app/common.module.ts b/Open-ILS/src/eg2/src/app/common.module.ts
new file mode 100644 (file)
index 0000000..b64758d
--- /dev/null
@@ -0,0 +1,31 @@
+import {CommonModule} from '@angular/common';
+import {NgModule} from '@angular/core';
+import {FormsModule} from '@angular/forms';
+import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
+import {EgOrgSelectComponent} from '@eg/share/org-select.component';
+import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
+
+/**
+ * Collection of common modules and components used by all apps.
+ */ 
+
+@NgModule({
+  declarations: [
+    EgOrgSelectComponent,
+    EgConfirmDialogComponent
+  ],
+  imports: [
+    CommonModule,
+    FormsModule,
+    NgbModule
+  ],
+  exports: [
+    CommonModule,
+    NgbModule,
+    FormsModule,
+    EgOrgSelectComponent,
+    EgConfirmDialogComponent
+  ]
+})
+
+export class EgCommonModule {}
index ba78449..a1547f8 100644 (file)
@@ -1,7 +1,7 @@
-import { NgModule }             from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
-import { EgBaseResolver }       from './resolver.service';
-import { WelcomeComponent }     from './welcome.component';
+import {NgModule}             from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+import {EgBaseResolver}       from './resolver.service';
+import {WelcomeComponent}     from './welcome.component';
 
 /**
  * Avoid loading all application JS up front by lazy-loading sub-modules.
@@ -21,9 +21,9 @@ const routes: Routes = [
 ];
 
 @NgModule({
-  imports: [ RouterModule.forRoot(routes) ],
-  exports: [ RouterModule ],
-  providers: [ EgBaseResolver ]
+  imports: [RouterModule.forRoot(routes)],
+  exports: [RouterModule],
+  providers: [EgBaseResolver]
 })
 
 export class EgBaseRoutingModule {}
index 859c70c..490f9a6 100644 (file)
@@ -1,3 +1,5 @@
+<eg-staff-banner bannerText="Workstation Administration" i18n-bannerText>
+</eg-staff-banner>
 
 <!-- this will remain hidden until opened -->
 <eg-confirm-dialog 
index d0c5db3..00d9593 100644 (file)
@@ -1,6 +1,5 @@
 import {NgModule} from '@angular/core';
-import {CommonModule} from '@angular/common';
-import {EgStaffModule} from '@eg/staff/app.module';
+import {EgStaffCommonModule} from '@eg/staff/common.module';
 import {WorkstationsRoutingModule} from './routing.module';
 import {WorkstationsComponent} from './app.component';
 
@@ -9,15 +8,11 @@ import {WorkstationsComponent} from './app.component';
     WorkstationsComponent,
   ],
   imports: [
-    CommonModule,
-    EgStaffModule,
+    EgStaffCommonModule,
     WorkstationsRoutingModule
-  ],
-  providers: [
   ]
 })
 
-export class ManageWorkstationsModule {
-    constructor() {console.log('Loading ManageWorkstationsModule')}
-}
+export class ManageWorkstationsModule {}
+
 
index 6cefff5..3145d2b 100644 (file)
@@ -1,42 +1,24 @@
-import {CommonModule} from '@angular/common';
 import {NgModule} from '@angular/core';
-import {FormsModule} from '@angular/forms';
-import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
-import {EgBaseModule} from '@eg/app.module';
+import {EgStaffCommonModule} from '@eg/staff/common.module';
 
 import {EgStaffComponent} from './app.component';
 import {EgStaffRoutingModule} from './routing.module';
 import {EgStaffNavComponent} from './nav.component';
 import {EgStaffLoginComponent} from './login.component';
 import {EgStaffSplashComponent} from './splash.component';
-import {EgOrgSelectComponent} from '@eg/share/org-select.component';
-import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
-
 
 @NgModule({
   declarations: [
     EgStaffComponent,
     EgStaffNavComponent,
     EgStaffSplashComponent,
-    EgStaffLoginComponent,
-    EgOrgSelectComponent,
-    EgConfirmDialogComponent
+    EgStaffLoginComponent
   ],
   imports: [
-    CommonModule,
-    EgStaffRoutingModule,
-    FormsModule,
-    NgbModule
-  ],
-  exports: [
-    // Components available to all staff/sub modules
-    EgOrgSelectComponent,
-    EgConfirmDialogComponent,
-    FormsModule,
-    NgbModule
+    EgStaffCommonModule,
+    EgStaffRoutingModule
   ]
 })
 
-export class EgStaffModule { 
+export class EgStaffModule {}
 
-}
index b76cc0b..fbcf894 100644 (file)
@@ -1,6 +1,5 @@
-import {CommonModule} from '@angular/common';
 import {NgModule} from '@angular/core';
-import {EgStaffModule} from '../app.module';
+import {EgStaffCommonModule} from '@eg/staff/common.module';
 import {EgUnapiService} from '@eg/share/unapi';
 import {EgCatalogRoutingModule} from './routing.module';
 import {EgCatalogService} from '@eg/share/catalog/catalog.service';
@@ -31,8 +30,7 @@ import {RecordPaginationComponent} from './record/pagination.component';
     RecordPaginationComponent
   ],
   imports: [
-    EgStaffModule,
-    CommonModule,
+    EgStaffCommonModule,
     EgCatalogRoutingModule
   ],
   providers: [
index 467db52..9125c9d 100644 (file)
@@ -21,7 +21,7 @@ const routes: Routes = [{
 @NgModule({
   imports: [RouterModule.forChild(routes)],
   exports: [RouterModule],
-  providers: [EgCatalogResolver ]
+  providers: [EgCatalogResolver]
 })
 
 export class EgCatalogRoutingModule {}
index 1f55cb1..e091982 100644 (file)
@@ -1,8 +1,20 @@
-<h2 i18n="Barcode Search Header">Search for Patron by Barcode</h2>
 
-<span i18n>Barcode:</span><input type='text' [ngModel]='barcode'/>
+<eg-staff-banner bannerText="Search for Patron by Barcode" i18n-bannerText>
+</eg-staff-banner>
+
+<div class="col-4">
+    <div class="input-group">
+      <div class="input-group-prepend">
+        <span class="input-group-text" i18n>Barcode:</span>
+      </div>
+      <input type='text' id='barcode-search-input' 
+        class="form-control" placeholder="Barcode" i18n-placeholder
+        [ngModel]='barcode'/>
+      <div class="input-group-append">
+        <button class="btn btn-outline-secondary" 
+            (click)="findUser()">Submit</button>
+      </div>
+    </div>
+</div>
+
 
-<br/>
-<ul>
-    <li *ngFor="let str of strList">{{str}}</li>
-</ul>
index 43d36da..294a88e 100644 (file)
@@ -1,7 +1,7 @@
-import { Component, OnInit } from '@angular/core';
-import { ActivatedRoute } from '@angular/router';
-import { EgNetService } from '@eg/core/net';
-import { EgAuthService } from '@eg/core/auth';
+import {Component, OnInit, Renderer} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+import {EgNetService} from '@eg/core/net';
+import {EgAuthService} from '@eg/core/auth';
 
 @Component({
   templateUrl: 'app.component.html'
@@ -9,36 +9,27 @@ import { EgAuthService } from '@eg/core/auth';
 
 export class EgBcSearchComponent implements OnInit {
 
-    barcode: String = '';
-    strList: String[] = [];
+    barcode: string = '';
 
     constructor(
         private route: ActivatedRoute,
+        private renderer: Renderer,
         private net: EgNetService,
         private auth: EgAuthService
     ) {}
 
     ngOnInit() {
 
+        this.renderer.selectRootElement('#barcode-search-input').focus();
         this.barcode = this.route.snapshot.paramMap.get('barcode');
 
         if (this.barcode) {
-            // Find the user and redirect to the 
+            this.findUser();
         }
-
-        this.route.data.subscribe((data: { startup : any }) => {
-            console.debug('EgBcSearch ngOnInit complete');
-        });
-
-        this.net.request(
-            'open-ils.actor',
-            'opensrf.system.echo',
-            'hello', 'goodbye', 'in the middle'
-        ).subscribe(res => this.strList.push(res));
     }
 
     findUser(): void {
-        // find user by this.barcode;
+        alert('Searching for user ' + this.barcode);
     }
 }
 
index f119697..bb5f688 100644 (file)
@@ -1,17 +1,15 @@
-import { CommonModule }            from '@angular/common';
-import { NgModule }                from '@angular/core';
-import { FormsModule }             from '@angular/forms';
-import { EgBcSearchComponent }     from './app.component';
-import { EgBcSearchRoutingModule } from './routing.module';
+import {NgModule}                from '@angular/core';
+import {EgStaffCommonModule}     from '@eg/staff/common.module';
+import {EgBcSearchRoutingModule} from './routing.module';
+import {EgBcSearchComponent}     from './app.component';
 
 @NgModule({
   declarations: [
     EgBcSearchComponent
   ],
   imports: [
+    EgStaffCommonModule,
     EgBcSearchRoutingModule,
-    CommonModule,
-    FormsModule
   ],
 })
 
index 2a685f3..a8c5a04 100644 (file)
@@ -1,6 +1,6 @@
-import { NgModule }             from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
-import { EgBcSearchComponent }  from './app.component';
+import {NgModule}             from '@angular/core';
+import {RouterModule, Routes} from '@angular/router';
+import {EgBcSearchComponent}  from './app.component';
 
 const routes: Routes = [
   { path: '',
@@ -12,8 +12,8 @@ const routes: Routes = [
 ];
 
 @NgModule({
-  imports: [ RouterModule.forChild(routes) ],
-  exports: [ RouterModule ]
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule]
 })
 
 export class EgBcSearchRoutingModule {}
index 1b0a0f0..a61417a 100644 (file)
@@ -1,20 +1,18 @@
 import { NgModule }             from '@angular/core';
 import { RouterModule, Routes } from '@angular/router';
 
-const routes: Routes = [{ 
-  path: '',
-  children : [{
-    path: 'patron',
+const routes: Routes = [
+  { path: 'patron',
     children: [{
       path: 'bcsearch',
       loadChildren: '@eg/staff/circ/patron/bcsearch/app.module#EgBcSearchModule'
     }]
-  }]
-}];
+  }
+];
 
 @NgModule({
-  imports: [ RouterModule.forChild(routes) ],
-  exports: [ RouterModule ]
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule]
 })
 
 export class EgCircRoutingModule {}
diff --git a/Open-ILS/src/eg2/src/app/staff/common.module.ts b/Open-ILS/src/eg2/src/app/staff/common.module.ts
new file mode 100644 (file)
index 0000000..97a72a3
--- /dev/null
@@ -0,0 +1,23 @@
+import {NgModule} from '@angular/core';
+import {EgCommonModule} from '@eg/common.module';
+import {EgStaffBannerComponent} from './share/staff-banner.component';
+import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
+
+/**
+ * Imports the EG common modules and adds modules common to all staff UI's.
+ */ 
+
+@NgModule({
+  declarations: [
+    EgStaffBannerComponent,
+  ],
+  imports: [
+    EgCommonModule
+  ],
+  exports: [
+    EgCommonModule,
+    EgStaffBannerComponent
+  ]
+})
+
+export class EgStaffCommonModule {}
diff --git a/Open-ILS/src/eg2/src/app/staff/share/staff-banner.component.ts b/Open-ILS/src/eg2/src/app/staff/share/staff-banner.component.ts
new file mode 100644 (file)
index 0000000..b11cadb
--- /dev/null
@@ -0,0 +1,15 @@
+import {Component, OnInit, Input} from '@angular/core';
+
+@Component({
+  selector: 'eg-staff-banner',
+  template: 
+    '<div class="lead alert alert-primary text-center pt-1 pb-1 mb-1" role="alert">' +
+      '<span>{{bannerText}}</span>' +
+    '</div>'
+})
+
+export class EgStaffBannerComponent {
+    @Input() public bannerText: string;
+}
+
+
index a6a65ad..794d011 100644 (file)
             </a>
           </li>
           <li>
+            <a href="/eg2/staff/catalog/search" target="_self">
+              <span class="glyphicon glyphicon-search"></span>
+              <span>[% l('Staff Catalog (Experimental)') %]</span>
+            </a>
+          </li>
+          <li>
             <a href="./cat/bucket/record/view" target="_self">
               <span class="glyphicon glyphicon-list-alt"></span>
               [% l('Record Buckets') %]