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-summary',
10 templateUrl: 'bib-summary.component.html',
11 styleUrls: ['bib-summary.component.css']
13 export class BibSummaryComponent 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
49 this.summary.getBibCallNumber();
56 this.store.getItem('eg.cat.record.summary.collapse')
57 .then(value => this.expand = !value)
58 .then(() => this.initDone = true);
62 this.store.setItem('eg.cat.record.summary.collapse', !this.expand);
66 this.bib.getBibSummary(this.recordId).toPromise()
68 summary.getBibCallNumber();
69 this.summary = summary;
73 orgName(orgId: number): string {
75 return this.org.get(orgId).shortname();
79 iconFormatLabel(code: string): string {
80 return this.cat.iconFormatLabel(code);