]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts
645b56cd787e3307ebc1de20f272aa024045d6d3
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / bib-summary / bib-summary.component.ts
1 import {Component, OnInit, Input} from '@angular/core';
2 import {NetService} from '@eg/core/net.service';
3 import {OrgService} from '@eg/core/org.service';
4 import {PcrudService} from '@eg/core/pcrud.service';
5 import {CatalogService} from '@eg/share/catalog/catalog.service';
6 import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service';
7
8 @Component({
9   selector: 'eg-bib-summary',
10   templateUrl: 'bib-summary.component.html',
11   styles: ['.eg-bib-summary .card-header {padding: .25rem .5rem}']
12 })
13 export class BibSummaryComponent implements OnInit {
14
15     initDone = false;
16     expandDisplay = true;
17     @Input() set expand(e: boolean) {
18         this.expandDisplay = e;
19     }
20
21     // If provided, the record will be fetched by the component.
22     @Input() recordId: number;
23
24     // Otherwise, we'll use the provided bib summary object.
25     summary: BibRecordSummary;
26     @Input() set bibSummary(s: any) {
27         this.summary = s;
28         if (this.initDone && this.summary) {
29             this.summary.getBibCallNumber();
30         }
31     }
32
33     constructor(
34         private bib: BibRecordService,
35         private cat: CatalogService,
36         private net: NetService,
37         private org: OrgService,
38         private pcrud: PcrudService
39     ) {}
40
41     ngOnInit() {
42         this.initDone = true;
43         if (this.summary) {
44             this.summary.getBibCallNumber();
45         } else {
46             if (this.recordId) {
47                 this.loadSummary();
48             }
49         }
50     }
51
52     loadSummary(): void {
53         this.bib.getBibSummary(this.recordId).toPromise()
54         .then(summary => {
55             summary.getBibCallNumber();
56             this.bib.fleshBibUsers([summary.record]);
57             this.summary = summary;
58             console.log(this.summary.display);
59         });
60     }
61
62     orgName(orgId: number): string {
63         if (orgId) {
64             return this.org.get(orgId).shortname();
65         }
66     }
67
68 }
69
70