]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.ts
LP1910145 Angular Hold Detail Notes & Notifications
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / holds / note-dialog.component.ts
1 import {Component, OnInit, Input, Output, ViewChild, EventEmitter} from '@angular/core';
2 import {Observable, Observer, of} from 'rxjs';
3 import {tap} from 'rxjs/operators';
4 import {IdlObject, IdlService} from '@eg/core/idl.service';
5 import {NetService} from '@eg/core/net.service';
6 import {PcrudService} from '@eg/core/pcrud.service';
7 import {OrgService} from '@eg/core/org.service';
8 import {AuthService} from '@eg/core/auth.service';
9 import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
10 import {DialogComponent} from '@eg/share/dialog/dialog.component';
11
12 /** New hold note dialog */
13
14 @Component({
15   selector: 'eg-hold-note-dialog',
16   templateUrl: 'note-dialog.component.html'
17 })
18 export class HoldNoteDialogComponent extends DialogComponent {
19     pub = false;
20     slip = false;
21     title: string;
22     body: string;
23
24     @Input() holdId: number;
25
26     constructor(
27         private modal: NgbModal,
28         private idl: IdlService,
29         private pcrud: PcrudService
30     ) { super(modal); }
31
32     createNote() {
33         const note = this.idl.create('ahrn');
34         note.staff('t');
35         note.hold(this.holdId);
36         note.title(this.title);
37         note.body(this.body);
38         note.slip(this.slip ? 't' : 'f');
39         note.pub(this.pub ? 't' : 'f');
40
41         this.pcrud.create(note).toPromise().then(
42             resp => this.close(resp), // new note object
43             err => console.error('Could not create note', err)
44         );
45     }
46 }
47
48