Catalog default tab; holdings/conjoined tabs user/berick/ang-staff-catalog-continued
authorBill Erickson <berickxx@gmail.com>
Tue, 4 Dec 2018 15:25:24 +0000 (10:25 -0500)
committerBill Erickson <berickxx@gmail.com>
Tue, 4 Dec 2018 15:25:24 +0000 (10:25 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts

index d4dcd0d..d138523 100644 (file)
@@ -27,7 +27,7 @@
       </div>
     </div>
     <ngb-tabset #recordTabs [activeId]="recordTab" (tabChange)="onTabChange($event)">
-      <ngb-tab title="Copy Table" i18n-title id="copy_table">
+      <ngb-tab title="Copy Table" i18n-title id="catalog">
         <ng-template ngbTabContent>
           <eg-catalog-copies [recordId]="recordId"></eg-catalog-copies>
         </ng-template>
       </ngb-tab>
       <ngb-tab title="View Holds" i18n-title id="holds">
       </ngb-tab>
-      <ngb-tab title="Monograph Parts" i18n-title id="parts">
+      <ngb-tab title="Monograph Parts" i18n-title id="monoparts">
         <ng-template ngbTabContent>
           <eg-catalog-record-parts [recordId]="recordId">
           </eg-catalog-record-parts>
         </ng-template>
       </ngb-tab>
+      <ngb-tab title="Holdings View" i18n-title id="holdings">
+      </ngb-tab>
+      <ngb-tab title="Conjoined Items" i18n-title id="conjoined">
+      </ngb-tab>
     </ngb-tabset>
   </div>
 </div>
index abcc24e..0414a07 100644 (file)
@@ -10,6 +10,13 @@ import {StaffCatalogService} from '../catalog.service';
 import {BibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component';
 import {StoreService} from '@eg/core/store.service';
 
+const ANGJS_TABS: any = {
+    marc_edit: true,
+    holds: true,
+    holdings: true,
+    conjoined: true
+};
+
 @Component({
   selector: 'eg-catalog-record',
   templateUrl: 'record.component.html'
@@ -38,7 +45,7 @@ export class RecordComponent implements OnInit {
 
         this.defaultTab = 
             this.store.getLocalItem('eg.cat.default_record_tab')
-            || 'copy_table';
+            || 'catalog';
 
         // TODO: Implement default tab handling for tabs that require
         // and AngJS redirect.
@@ -50,9 +57,19 @@ export class RecordComponent implements OnInit {
         // This is done so no intermediate redirect is required, which
         // messes with browser back/forward navigation.
         this.route.paramMap.subscribe((params: ParamMap) => {
-            this.recordTab = params.get('tab') || this.defaultTab;
+            this.recordTab = params.get('tab');
             this.recordId = +params.get('id');
             this.searchContext = this.staffCat.searchContext;
+
+            if (!this.recordTab) {
+                this.recordTab = this.defaultTab || 'catalog';
+                // On initial load, if the default tab is set to one of
+                // the AngularJS tabs, redirect the user there.
+                if (this.recordTab in ANGJS_TABS) {
+                    return this.routeToTab();
+                }
+            }
+
             this.loadRecord();
         });
     }
@@ -70,20 +87,22 @@ export class RecordComponent implements OnInit {
         // prevent tab changing until after route navigation
         evt.preventDefault();
 
-        // Some tabs live in the AngJS app.
-        const angjsBase = '/eg/staff/cat/catalog/record';
-        switch(this.recordTab) {
-            case 'marc_edit':
-                window.location.href = 
-                    `${angjsBase}/${this.recordId}/marc_edit`;
-                return;
-            case 'holds':
-                window.location.href = 
-                    `${angjsBase}/${this.recordId}/holds`;
-                return;
+        this.routeToTab();
+    }
+
+    routeToTab() {
+
+        // Route to the AngularJS catalog tab
+        if (this.recordTab in ANGJS_TABS) {
+            const angjsBase = '/eg/staff/cat/catalog/record';
+
+            window.location.href = 
+                `${angjsBase}/${this.recordId}/${this.recordTab}`;
+            return;
         }
 
-        const url = `/staff/catalog/record/${this.recordId}/${this.recordTab}`;
+        const url = 
+            `/staff/catalog/record/${this.recordId}/${this.recordTab}`;
 
         // Retain search parameters
         this.router.navigate([url], {queryParamsHandling: 'merge'});