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';
8 selector: 'eg-bib-summary',
9 templateUrl: 'bib-summary.component.html',
10 styles: ['.eg-bib-summary .card-header {padding: .25rem .5rem}']
12 export class BibSummaryComponent implements OnInit {
16 // True / false if the display is vertically expanded
17 private _exp: boolean;
18 set expand(e: boolean) {
21 this.saveExpandState();
24 get expand(): boolean { return this._exp; }
26 // If provided, the record will be fetched by the component.
27 @Input() recordId: number;
29 // Otherwise, we'll use the provided bib summary object.
30 summary: BibRecordSummary;
31 @Input() set bibSummary(s: any) {
33 if (this.initDone && this.summary) {
34 this.summary.getBibCallNumber();
39 private bib: BibRecordService,
40 private org: OrgService,
41 private store: ServerStoreService
47 this.summary.getBibCallNumber();
54 this.store.getItem('eg.cat.record.summary.collapse')
55 .then(value => this.expand = !value)
56 .then(() => this.initDone = true);
60 this.store.setItem('eg.cat.record.summary.collapse', !this.expand);
64 this.bib.getBibSummary(this.recordId).toPromise()
66 summary.getBibCallNumber();
67 this.bib.fleshBibUsers([summary.record]);
68 this.summary = summary;
69 console.log(this.summary.display);
73 orgName(orgId: number): string {
75 return this.org.get(orgId).shortname();