]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts
LP#1779158 Ang6 Vandelay UI Port
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / cat / vandelay / match-set.component.ts
1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {Router, ActivatedRoute, ParamMap} from '@angular/router';              
3 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
4 import {IdlObject} from '@eg/core/idl.service';
5 import {PcrudService} from '@eg/core/pcrud.service';
6 import {OrgService} from '@eg/core/org.service';
7
8 @Component({
9   templateUrl: 'match-set.component.html'
10 })
11 export class MatchSetComponent implements OnInit {
12
13     matchSet: IdlObject;
14     matchSetId: number;
15     matchSetTab: string;
16
17     constructor(
18         private router: Router,
19         private route: ActivatedRoute,
20         private pcrud: PcrudService,
21         private org: OrgService
22     ) {
23         this.route.paramMap.subscribe((params: ParamMap) => {                  
24             this.matchSetId = +params.get('id');
25             this.matchSetTab = params.get('matchSetTab');
26         });
27     }
28
29     ngOnInit() {
30         this.pcrud.retrieve('vms', this.matchSetId)
31             .toPromise().then(ms => {
32                 ms.owner(this.org.get(ms.owner()));
33                 this.matchSet = ms;
34             });
35     }
36
37     // Changing a tab in the UI means changing the route.
38     // Changing the route ultimately results in changing the tab.
39     onTabChange(evt: NgbTabChangeEvent) {
40         this.matchSetTab = evt.nextId;
41
42         // prevent tab changing until after route navigation
43         evt.preventDefault();
44
45         const url = 
46           `/staff/cat/vandelay/match_sets/${this.matchSetId}/${this.matchSetTab}`;
47
48         this.router.navigate([url]);
49     }
50 }
51