From 67f521e984aabf2ed40393ecc06892190e8f5285 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 4 Dec 2018 10:25:24 -0500 Subject: [PATCH] Catalog default tab; holdings/conjoined tabs Signed-off-by: Bill Erickson --- .../app/staff/catalog/record/record.component.html | 8 +++- .../app/staff/catalog/record/record.component.ts | 47 +++++++++++++++------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html index d4dcd0d2b9..d1385230f3 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html @@ -27,7 +27,7 @@ - + @@ -42,12 +42,16 @@ - + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts index abcc24eb8d..0414a076b4 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts @@ -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'}); -- 2.11.0