From: Bill Erickson Date: Mon, 3 Dec 2018 23:11:09 +0000 (-0500) Subject: Catalog set default tab WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=460d1234c4879b8d430b60a0a34aca2b6d4ae7ef;p=working%2FEvergreen.git Catalog set default tab WIP Signed-off-by: Bill Erickson --- 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 96c733ecde..d4dcd0d2b9 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 @@ -19,6 +19,13 @@
+
+
+ +
+
@@ -28,7 +35,7 @@ - + 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 7dfaf2f7b3..abcc24eb8d 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 @@ -8,6 +8,7 @@ import {CatalogService} from '@eg/share/catalog/catalog.service'; import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service'; import {StaffCatalogService} from '../catalog.service'; import {BibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component'; +import {StoreService} from '@eg/core/store.service'; @Component({ selector: 'eg-catalog-record', @@ -20,6 +21,7 @@ export class RecordComponent implements OnInit { summary: BibRecordSummary; searchContext: CatalogSearchContext; @ViewChild('recordTabs') recordTabs: NgbTabset; + defaultTab: string; // eg.cat.default_record_tab constructor( private router: Router, @@ -27,21 +29,39 @@ export class RecordComponent implements OnInit { private pcrud: PcrudService, private bib: BibRecordService, private cat: CatalogService, - private staffCat: StaffCatalogService + private staffCat: StaffCatalogService, + private store: StoreService ) {} ngOnInit() { this.searchContext = this.staffCat.searchContext; + this.defaultTab = + this.store.getLocalItem('eg.cat.default_record_tab') + || 'copy_table'; + + // TODO: Implement default tab handling for tabs that require + // and AngJS redirect. + // Watch for URL record ID changes + // This includes the initial route. + // When applying the default configured tab, no navigation occurs + // to apply the tab name to the URL, it displays as the default. + // 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') || 'copy_table'; + this.recordTab = params.get('tab') || this.defaultTab; this.recordId = +params.get('id'); this.searchContext = this.staffCat.searchContext; this.loadRecord(); }); } + setDefaultTab() { + this.defaultTab = this.recordTab; + this.store.setLocalItem('eg.cat.default_record_tab', this.recordTab); + } + // Changing a tab in the UI means changing the route. // Changing the route ultimately results in changing the tab. onTabChange(evt: NgbTabChangeEvent) { @@ -63,10 +83,7 @@ export class RecordComponent implements OnInit { return; } - let url = '/staff/catalog/record/' + this.recordId; - if (this.recordTab !== 'copy_table') { - url += '/' + this.recordTab; - } + const url = `/staff/catalog/record/${this.recordId}/${this.recordTab}`; // Retain search parameters this.router.navigate([url], {queryParamsHandling: 'merge'});