1 import {Component, OnInit, Input} from '@angular/core';
2 import {OrgService} from '@eg/core/org.service';
3 import {BibRecordService, BibRecordSummary
4 } from '@eg/share/catalog/bib-record.service';
5 import {ServerStoreService} from '@eg/core/server-store.service';
6 import {CatalogService} from '@eg/share/catalog/catalog.service';
7 import {StaffCatalogService} from '@eg/staff/catalog/catalog.service';
10 selector: 'eg-bib-staff-view',
11 templateUrl: 'bib-staff-view.component.html',
12 styleUrls: ['bib-staff-view.component.css']
14 export class BibStaffViewComponent implements OnInit {
19 // True / false if the display is vertically expanded
20 private _exp: boolean;
21 set expand(e: boolean) {
24 this.saveExpandState();
27 get expand(): boolean { return this._exp; }
29 @Input() set recordId(id: number) {
31 // Only force new data collection when recordId()
32 // is invoked after ngInit() has already run.
38 // Otherwise, we'll use the provided bib summary object.
39 summary: BibRecordSummary;
40 @Input() set bibSummary(s: any) {
42 if (this.initDone && this.summary) {
43 this.summary.getBibCallNumber();
48 private bib: BibRecordService,
49 private org: OrgService,
50 private store: ServerStoreService,
51 private cat: CatalogService,
52 private staffCat: StaffCatalogService
57 this.store.getItem('eg.cat.record.staff-view.collapse')
58 .then(value => this.expand = !value)
59 .then(_ => this.cat.fetchCcvms())
62 // ignore any existing this.summary, always refetch
63 return this.loadSummary();
65 }).then(_ => this.initDone = true);
69 this.store.setItem('eg.cat.record.staff-view.collapse', !this.expand);
72 loadSummary(): Promise<any> {
73 return this.bib.getBibSummary(
75 this.staffCat.searchContext.searchOrg.id(),
79 this.summary = summary;
80 return summary.getBibCallNumber();
84 orgName(orgId: number): string {
86 return this.org.get(orgId).shortname();
90 iconFormatLabel(code: string): string {
91 return this.cat.iconFormatLabel(code);