LP1910145 Hold notes and notifications WIP
authorBill Erickson <berickxx@gmail.com>
Mon, 4 Jan 2021 22:06:51 +0000 (17:06 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 4 Jan 2021 22:06:51 +0000 (17:06 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.html
Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.ts
Open-ILS/src/eg2/src/app/staff/share/holds/holds.module.ts
Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.ts [new file with mode: 0644]

index 616acc6..46bc114 100644 (file)
@@ -1,3 +1,8 @@
+<eg-hold-note-dialog #noteDialog [holdId]="holdId"></eg-hold-note-dialog>
+<!--
+<eg-hold-notify-dialog #notifyDialog [holdId]="holdId"></eg-hold-notify-dialog>
+-->
+
 <div class="row">
   <div class="col-lg-2">
     <button (click)="showListView()" class="btn btn-info" i18n>List View</button>
               <div class="flex-1"></div>
               <div>
                 <span *ngIf="note.slip() == 't'" 
-                  class="ml-2 badge badge-info">Print on Slip</span>
+                  class="ml-2 badge badge-info p-1">Print on Slip</span>
                 <span *ngIf="note.pub() == 't'" 
-                  class="ml-2 badge badge-warning">Patron Visible</span>
+                  class="ml-2 badge badge-warning p-1">Patron Visible</span>
                 <span *ngIf="note.staff() == 't'" 
-                  class="ml-2 badge badge-info">Staff Create</span>
+                  class="ml-2 badge badge-info p-1">Staff Create</span>
               </div>
             </div>
             <div class="well-table">
index 5a1ebbf..d7ddf16 100644 (file)
@@ -6,6 +6,7 @@ import {NetService} from '@eg/core/net.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {OrgService} from '@eg/core/org.service';
 import {AuthService} from '@eg/core/auth.service';
+import {HoldNoteDialogComponent} from './note-dialog.component';
 
 /** Hold details read-only view */
 
@@ -44,6 +45,8 @@ export class HoldDetailComponent implements OnInit {
     initDone: boolean;
     @Output() onShowList: EventEmitter<any>;
 
+    @ViewChild('noteDialog') noteDialog: HoldNoteDialogComponent;
+
     constructor(
         private net: NetService,
         private pcrud: PcrudService,
@@ -106,6 +109,10 @@ export class HoldDetailComponent implements OnInit {
         this.pcrud.remove(note).toPromise()
         .then(ok => { if (ok) { this.getNotes(); } });
     }
+
+    newNote() {
+        this.noteDialog.open().subscribe(note => this.notes.unshift(note));
+    }
 }
 
 
index 5bcb68a..3d01139 100644 (file)
@@ -9,6 +9,7 @@ import {HoldRetargetDialogComponent} from './retarget-dialog.component';
 import {HoldTransferDialogComponent} from './transfer-dialog.component';
 import {HoldCancelDialogComponent} from './cancel-dialog.component';
 import {HoldManageDialogComponent} from './manage-dialog.component';
+import {HoldNoteDialogComponent} from './note-dialog.component';
 
 @NgModule({
     declarations: [
@@ -18,7 +19,8 @@ import {HoldManageDialogComponent} from './manage-dialog.component';
         HoldRetargetDialogComponent,
         HoldTransferDialogComponent,
         HoldCancelDialogComponent,
-        HoldManageDialogComponent
+        HoldManageDialogComponent,
+        HoldNoteDialogComponent
     ],
     imports: [
         StaffCommonModule,
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.html
new file mode 100644 (file)
index 0000000..983e5d2
--- /dev/null
@@ -0,0 +1,37 @@
+<ng-template #dialogContent>
+  <div class="modal-header bg-info">
+    <h4 class="modal-title">Add Hold Note for Hold #{{holdId}}</h4>
+    <button type="button" class="close"
+      i18n-aria-label aria-label="Close" (click)="close()">
+      <span aria-hidden="true">&times;</span>
+    </button>
+  </div>
+  <div class="modal-body form-validated">
+    <div class="form-group form-check">
+      <input type="checkbox" class="form-check-input" 
+        id="patron-visible-cbox" [(ngModel)]="pub">
+      <label class="form-check-label" 
+        for="patron-visible-cbox" i18n>Patron Visible?</label>
+    </div>
+    <div class="form-group form-check">
+      <input type="checkbox" class="form-check-input" 
+        id="hold-slip-cbox" [(ngModel)]="slip">
+      <label class="form-check-label" 
+        for="hold-slip-cbox" i18n>Print on Slip?</label>
+    </div>
+               <div class="form-group">
+                       <label for="title-input" i18n>Note Title</label>
+                       <input type="text" class="form-control" id="title-input" required [(ngModel)]="title"/>
+               </div>
+               <div class="form-group">
+                       <label for="body-input" i18n>Note Body</label>
+                       <textarea class="form-control" id="body-input" required [(ngModel)]="body">
+      </textarea>
+               </div>
+    <div class="w-100">
+      <button class="btn btn-success ml-auto" (click)="createNote()"
+        [disabled]="!title || !body" i18n>Create Note</button>
+      <button class="btn btn-warning ml-2" (click)="close()" i18n>Cancel</button>
+    </div>
+  </div>
+</ng-template>
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.ts
new file mode 100644 (file)
index 0000000..b703ed5
--- /dev/null
@@ -0,0 +1,52 @@
+import {Component, OnInit, Input, Output, ViewChild, EventEmitter} from '@angular/core';
+import {Observable, Observer, of} from 'rxjs';
+import {tap} from 'rxjs/operators';
+import {IdlObject, IdlService} from '@eg/core/idl.service';
+import {NetService} from '@eg/core/net.service';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {OrgService} from '@eg/core/org.service';
+import {AuthService} from '@eg/core/auth.service';
+import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
+import {DialogComponent} from '@eg/share/dialog/dialog.component';
+
+/** New hold note dialog */
+
+@Component({
+  selector: 'eg-hold-note-dialog',
+  templateUrl: 'note-dialog.component.html'
+})
+export class HoldNoteDialogComponent extends DialogComponent implements OnInit {
+    pub = false;
+    slip = false;
+    title: string;
+    body: string;
+
+    @Input() holdId: number;
+
+    constructor(
+        private modal: NgbModal,
+        private idl: IdlService,
+        private pcrud: PcrudService
+    ) {
+        super(modal);
+    }
+
+    ngOnInit() {}
+
+    createNote() {
+        const note = this.idl.create('ahrn');
+        note.staff('t');
+        note.hold(this.holdId);
+        note.title(this.title);
+        note.body(this.body);
+        note.slip(this.slip ? 't' : 'f');
+        note.pub(this.pub ? 't' : 'f');
+
+        this.pcrud.create(note).toPromise().then(
+            resp => this.close(resp), // new note object
+            err => console.error('Could not create note', err)
+        );
+    }
+}
+
+