]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts
LP1879335 Manage Authorities Angular Port
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / cat / authority / manage.component.ts
1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
3 import {Observable, empty} from 'rxjs';
4 import {map, switchMap} from 'rxjs/operators';
5 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
6 import {IdlObject} from '@eg/core/idl.service';
7 import {Pager} from '@eg/share/util/pager';
8 import {NetService} from '@eg/core/net.service';
9 import {PcrudService} from '@eg/core/pcrud.service';
10 import {OrgService} from '@eg/core/org.service';
11 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
12
13 /* Find, merge, and edit authority records */
14
15 @Component({
16   templateUrl: 'manage.component.html'
17 })
18 export class ManageAuthorityComponent implements OnInit {
19
20     authId: number;
21     authTab = 'bibs';
22     authMeta: any;
23
24     constructor(
25         private router: Router,
26         private route: ActivatedRoute,
27         private net: NetService,
28         private org: OrgService,
29         private pcrud: PcrudService
30     ) {
31     }
32
33     ngOnInit() {
34         this.route.paramMap.subscribe((params: ParamMap) => {
35             this.authTab = params.get('tab') || 'bibs';
36             const id = +params.get('id');
37
38             if (id !== this.authId) {
39                 this.authId = id;
40
41                 this.net.request(
42                     'open-ils.search',
43                     'open-ils.search.authority.main_entry', this.authId
44                 ).subscribe(meta => this.authMeta = meta);
45             }
46         });
47     }
48
49     // Changing a tab in the UI means changing the route.
50     // Changing the route ultimately results in changing the tab.
51     beforeTabChange(evt: NgbTabChangeEvent) {
52
53         // prevent tab changing until after route navigation
54         evt.preventDefault();
55
56         this.authTab = evt.nextId;
57         this.routeToTab();
58     }
59
60     routeToTab() {
61         const url =
62             `/staff/cat/authority/manage/${this.authId}/${this.authTab}`;
63         this.router.navigate([url]);
64     }
65 }
66
67