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';
9 selector: 'eg-bib-staff-view',
10 templateUrl: 'bib-staff-view.component.html',
11 styleUrls: ['bib-staff-view.component.css']
13 export class BibStaffViewComponent implements OnInit {
17 // True / false if the display is vertically expanded
18 private _exp: boolean;
19 set expand(e: boolean) {
22 this.saveExpandState();
25 get expand(): boolean { return this._exp; }
27 // If provided, the record will be fetched by the component.
28 @Input() recordId: number;
30 // Otherwise, we'll use the provided bib summary object.
31 summary: BibRecordSummary;
32 @Input() set bibSummary(s: any) {
34 if (this.initDone && this.summary) {
35 this.summary.getBibCallNumber();
40 private bib: BibRecordService,
41 private org: OrgService,
42 private store: ServerStoreService,
43 private cat: CatalogService
48 this.store.getItem('eg.cat.record.staff-view.collapse')
49 .then(value => this.expand = !value)
50 .then(_ => this.cat.fetchCcvms())
53 return this.summary.getBibCallNumber();
56 return this.loadSummary();
59 }).then(_ => this.initDone = true);
63 this.store.setItem('eg.cat.record.staff-view.collapse', !this.expand);
66 loadSummary(): Promise<any> {
67 return this.bib.getBibSummary(
73 this.summary = summary;
74 return summary.getBibCallNumber();
78 orgName(orgId: number): string {
80 return this.org.get(orgId).shortname();
84 iconFormatLabel(code: string): string {
85 return this.cat.iconFormatLabel(code);