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';
12 selector: 'eg-catalog-result-record',
13 templateUrl: 'record.component.html'
15 export class ResultRecordComponent implements OnInit {
17 @Input() index: number; // 0-index display row
18 @Input() summary: BibRecordSummary;
19 searchContext: CatalogSearchContext;
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
32 this.searchContext = this.staffCat.searchContext;
33 this.summary.getHoldCount();
36 orgName(orgId: number): string {
37 return this.org.get(orgId).shortname();
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];
45 return ccvm.search_label();
51 alert('Placing hold on bib ' + this.summary.id);
55 alert('Adding to list for bib ' + this.summary.id);
58 searchAuthor(summary: any) {
59 this.searchContext.reset();
60 this.searchContext.fieldClass = ['author'];
61 this.searchContext.query = [summary.display.author];
62 this.staffCat.search();
66 * Propagate the search params along when navigating to each record.
68 navigatToRecord(id: number) {
69 const params = this.catUrl.toUrlParams(this.searchContext);
72 ['/staff/catalog/record/' + id], {queryParams: params});