]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/cat/authority/marc-edit.component.ts
LP1852782 Linker links to auth record editor
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / cat / authority / marc-edit.component.ts
1 import {Component, OnInit, AfterViewInit, ViewChild, Renderer2} from '@angular/core';
2 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
3 import {MarcSavedEvent} from '@eg/staff/share/marc-edit/editor.component';
4
5 @Component({
6   templateUrl: 'marc-edit.component.html'
7 })
8 export class AuthorityMarcEditComponent implements AfterViewInit {
9
10     authorityId: number;
11
12     // Avoid setting authorityId during lookup because it can
13     // cause the marc editor to load prematurely.
14     loadId: number;
15
16     constructor(
17         private router: Router,
18         private route: ActivatedRoute,
19         private renderer: Renderer2) {
20         this.authorityId = +this.route.snapshot.paramMap.get('id');
21     }
22
23     ngAfterViewInit() {
24         if (!this.authorityId) {
25             this.renderer.selectRootElement('#auth-id-input').focus();
26         }
27     }
28
29     goToAuthority() {
30         if (this.loadId) {
31             this.router.navigate([`/staff/cat/authority/edit/${this.loadId}`]);
32         }
33     }
34 }
35