]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts
Docs: merge 3.2 release notes
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / catalog / result / record.component.ts
1 import {Component, OnInit, Input} from '@angular/core';
2 import {Router} from '@angular/router';
3 import {OrgService} from '@eg/core/org.service';
4 import {NetService} from '@eg/core/net.service';
5 import {CatalogService} from '@eg/share/catalog/catalog.service';
6 import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service';
7 import {CatalogSearchContext} from '@eg/share/catalog/search-context';
8 import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service';
9 import {StaffCatalogService} from '../catalog.service';
10
11 @Component({
12   selector: 'eg-catalog-result-record',
13   templateUrl: 'record.component.html'
14 })
15 export class ResultRecordComponent implements OnInit {
16
17     @Input() index: number;  // 0-index display row
18     @Input() summary: BibRecordSummary;
19     searchContext: CatalogSearchContext;
20
21     constructor(
22         private router: Router,
23         private org: OrgService,
24         private net: NetService,
25         private bib: BibRecordService,
26         private cat: CatalogService,
27         private catUrl: CatalogUrlService,
28         private staffCat: StaffCatalogService
29     ) {}
30
31     ngOnInit() {
32         this.searchContext = this.staffCat.searchContext;
33         this.summary.getHoldCount();
34     }
35
36     orgName(orgId: number): string {
37         return this.org.get(orgId).shortname();
38     }
39
40     iconFormatLabel(code: string): string {
41         if (this.cat.ccvmMap) {
42             const ccvm = this.cat.ccvmMap.icon_format.filter(
43                 format => format.code() === code)[0];
44             if (ccvm) {
45                 return ccvm.search_label();
46             }
47         }
48     }
49
50     placeHold(): void {
51         alert('Placing hold on bib ' + this.summary.id);
52     }
53
54     addToList(): void {
55         alert('Adding to list for bib ' + this.summary.id);
56     }
57
58     searchAuthor(summary: any) {
59         this.searchContext.reset();
60         this.searchContext.fieldClass = ['author'];
61         this.searchContext.query = [summary.display.author];
62         this.staffCat.search();
63     }
64
65     /**
66      * Propagate the search params along when navigating to each record.
67      */
68     navigatToRecord(id: number) {
69         const params = this.catUrl.toUrlParams(this.searchContext);
70
71         this.router.navigate(
72           ['/staff/catalog/record/' + id], {queryParams: params});
73     }
74
75 }
76
77