</eg-bib-summary>
</div>
<div id='staff-catalog-bib-tabs-container' class='mt-3'>
+ <div class="row">
+ <div class="col-lg-12 text-right">
+ <button class="btn btn-secondary btn-sm"
+ [disabled]="recordTab == defaultTab"
+ (click)="setDefaultTab()" i18n>Set Default View</button>
+ </div>
+ </div>
<ngb-tabset #recordTabs [activeId]="recordTab" (tabChange)="onTabChange($event)">
<ngb-tab title="Copy Table" i18n-title id="copy_table">
<ng-template ngbTabContent>
<!-- NOTE some tabs send the user over to the AngJS app -->
<ngb-tab title="MARC Edit" i18n-title id="marc_edit">
</ngb-tab>
- <ngb-tab title="MARC View" i18n-title id="marc_view">
+ <ngb-tab title="MARC View" i18n-title id="marc_html">
<ng-template ngbTabContent>
<eg-marc-html [recordId]="recordId" recordType="bib"></eg-marc-html>
</ng-template>
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',
summary: BibRecordSummary;
searchContext: CatalogSearchContext;
@ViewChild('recordTabs') recordTabs: NgbTabset;
+ defaultTab: string; // eg.cat.default_record_tab
constructor(
private router: Router,
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) {
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'});