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 {PcrudService} from '@eg/core/pcrud.service';
5 import {IdlObject} from '@eg/core/idl.service';
8 templateUrl: 'queued-record.component.html'
10 export class QueuedRecordComponent {
16 queuedRecord: IdlObject;
19 private router: Router,
20 private route: ActivatedRoute,
21 private pcrud: PcrudService) {
23 this.route.paramMap.subscribe((params: ParamMap) => {
24 this.queueId = +params.get('id');
25 this.recordId = +params.get('recordId');
26 this.queueType = params.get('qtype');
27 this.recordTab = params.get('recordTab');
28 if (this.recordTab === 'edit') {
34 // Changing a tab in the UI means changing the route.
35 // Changing the route ultimately results in changing the tab.
36 onTabChange(evt: NgbTabChangeEvent) {
37 this.recordTab = evt.nextId;
39 // prevent tab changing until after route navigation
43 `/staff/cat/vandelay/queue/${this.queueType}/${this.queueId}` +
44 `/record/${this.recordId}/${this.recordTab}`;
46 this.router.navigate([url]);
50 this.queuedRecord = null;
51 this.pcrud.retrieve((this.queueType === 'bib' ? 'vqbr' : 'vqar'), this.recordId)
52 .subscribe(rec => this.queuedRecord = rec);
55 handleMarcRecordSaved(saveEvent: any) {
56 this.queuedRecord.marc(saveEvent.marcXml);
57 if (this.queueType === 'bib') {
58 this.queuedRecord.bib_source(saveEvent.bibSource);
60 this.pcrud.update(this.queuedRecord).subscribe(
62 console.log('response = ', response);