]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/catalog/record/opac.component.ts
22eee58728c61f98104802652a0b288a3e468ac4
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / catalog / record / opac.component.ts
1 import {Component, Input} from '@angular/core';
2 import {DomSanitizer} from '@angular/platform-browser';
3
4 const OPAC_BASE_URL = '/eg/opac/record';
5
6 @Component({
7   selector: 'eg-opac-record-detail',
8   templateUrl: 'opac.component.html'
9 })
10 export class OpacViewComponent {
11
12     url; // SafeResourceUrlImpl
13
14     _recordId: number;
15     @Input() set recordId(id: number) {
16
17         // Verify record ID is numeric only
18         if (id && (id + '').match(/^\d+$/)) {
19             this._recordId = id;
20             this.url = this.sanitizer.bypassSecurityTrustResourceUrl(
21                 `${OPAC_BASE_URL}/${id}`);
22         } else {
23             this._recordId = null;
24             this.url = null;
25         }
26     }
27
28     get recordId(): number {
29         return this._recordId;
30     }
31
32     constructor(private sanitizer: DomSanitizer) {}
33 }
34