]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.ts
LP1818288 Ang staff catalog record detail holds tab/actions
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / holds / detail.component.ts
1 import {Component, OnInit, Input, Output, ViewChild, EventEmitter} from '@angular/core';
2 import {Observable, Observer, of} from 'rxjs';
3 import {NetService} from '@eg/core/net.service';
4 import {OrgService} from '@eg/core/org.service';
5 import {AuthService} from '@eg/core/auth.service';
6
7 /** Hold details read-only view */
8
9 @Component({
10   selector: 'eg-hold-detail',
11   templateUrl: 'detail.component.html'
12 })
13 export class HoldDetailComponent implements OnInit {
14
15     _holdId: number;
16     @Input() set holdId(id: number) {
17         this._holdId = id;
18         if (this.initDone) {
19             this.fetchHold();
20         }
21     }
22
23     hold: any; // wide hold reference
24     @Input() set wideHold(wh: any) {
25         this.hold = wh;
26     }
27
28     initDone: boolean;
29     @Output() onShowList: EventEmitter<any>;
30
31     constructor(
32         private net: NetService,
33         private org: OrgService,
34         private auth: AuthService,
35     ) {
36         this.onShowList = new EventEmitter<any>();
37     }
38
39     ngOnInit() {
40         this.initDone = true;
41         this.fetchHold();
42     }
43
44     fetchHold() {
45         if (!this._holdId) { return; }
46
47         this.net.request(
48             'open-ils.circ',
49             'open-ils.circ.hold.wide_hash.stream',
50             this.auth.token(), {id: this._holdId}
51         ).subscribe(wideHold => {
52             this.hold = wideHold;
53         });
54     }
55
56     getOrgName(id: number) {
57         if (id) {
58             return this.org.get(id).shortname();
59         }
60     }
61
62     showListView() {
63         this.onShowList.emit();
64     }
65 }
66
67