LP1910145 Hold notes and notifications WIP user/berick/lp1910145-ang-hold-notes-and-notifies-wip
authorBill Erickson <berickxx@gmail.com>
Mon, 4 Jan 2021 22:30:42 +0000 (17:30 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 4 Jan 2021 22:30:42 +0000 (17:30 -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.ts
Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.ts [new file with mode: 0644]

index 46bc114..e80d1ff 100644 (file)
@@ -1,7 +1,5 @@
 <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">
       <li ngbNavItem="notifications">
         <a ngbNavLink i18n>Staff Notifications</a>
         <ng-template ngbNavContent>
-          NOTIFY
+          <button class="btn btn-outline-dark mt-3" 
+            (click)="newNotify()" i18n>Add Record of Notification</button>
+          <div class="mt-3" *ngFor="let notify of notifies">
+            <div class="d-flex">
+              <div class="font-weight-bold">{{notify.method()}}</div>
+              <div class="flex-1"></div>
+              <div>
+                <span>{{notify.notify_time() | date:'short'}}</span>
+                <span class="ml-2" i18n>
+                  Created by {{notify.notify_staff().usrname()}}</span>
+              </div>
+              <div>
+              </div>
+            </div>
+            <div class="well-table">
+              <div class="well-row">
+                <div class="well-value">{{notify.note()}}</div>
+              </div>
+            </div>
+          </div>
         </ng-template>
       </li>
     </ul>
index d7ddf16..2f28c24 100644 (file)
@@ -7,6 +7,7 @@ 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';
+import {HoldNotifyDialogComponent} from './notify-dialog.component';
 
 /** Hold details read-only view */
 
@@ -46,6 +47,7 @@ export class HoldDetailComponent implements OnInit {
     @Output() onShowList: EventEmitter<any>;
 
     @ViewChild('noteDialog') noteDialog: HoldNoteDialogComponent;
+    @ViewChild('notifyDialog') notifyDialog: HoldNotifyDialogComponent;
 
     constructor(
         private net: NetService,
@@ -83,16 +85,17 @@ export class HoldDetailComponent implements OnInit {
     getNotes(): Promise<any> {
         this.notes = [];
         return this.pcrud.search('ahrn', {hold: this.holdId})
-        .pipe(tap(note => this.notes.push(note))).toPromise()
+        .pipe(tap(note => this.notes.push(note))).toPromise();
     }
 
     getNotifies(): Promise<any> {
         this.notifies = [];
 
-        return this.pcrud.search('ahn',
-            {hold: this.holdId},
-            {order_by: {ahn: 'notify_time DESC'}}
-        ).pipe(tap(notify => this.notifies.push(notify))).toPromise();
+        return this.pcrud.search('ahn', {hold: this.holdId}, {
+            flesh: 1,
+            flesh_fields: {ahn: ['notify_staff']},
+            order_by: {ahn: 'notify_time DESC'}
+        }).pipe(tap(notify => this.notifies.push(notify))).toPromise();
     }
 
     getOrgName(id: number) {
@@ -113,6 +116,10 @@ export class HoldDetailComponent implements OnInit {
     newNote() {
         this.noteDialog.open().subscribe(note => this.notes.unshift(note));
     }
+
+    newNotify() {
+        this.notifyDialog.open().subscribe(notify => this.getNotifies()); // fleshing
+    }
 }
 
 
index 3d01139..b5b4bb2 100644 (file)
@@ -10,6 +10,7 @@ import {HoldTransferDialogComponent} from './transfer-dialog.component';
 import {HoldCancelDialogComponent} from './cancel-dialog.component';
 import {HoldManageDialogComponent} from './manage-dialog.component';
 import {HoldNoteDialogComponent} from './note-dialog.component';
+import {HoldNotifyDialogComponent} from './notify-dialog.component';
 
 @NgModule({
     declarations: [
@@ -20,7 +21,8 @@ import {HoldNoteDialogComponent} from './note-dialog.component';
         HoldTransferDialogComponent,
         HoldCancelDialogComponent,
         HoldManageDialogComponent,
-        HoldNoteDialogComponent
+        HoldNoteDialogComponent,
+        HoldNotifyDialogComponent
     ],
     imports: [
         StaffCommonModule,
index b703ed5..935dd5d 100644 (file)
@@ -15,7 +15,7 @@ import {DialogComponent} from '@eg/share/dialog/dialog.component';
   selector: 'eg-hold-note-dialog',
   templateUrl: 'note-dialog.component.html'
 })
-export class HoldNoteDialogComponent extends DialogComponent implements OnInit {
+export class HoldNoteDialogComponent extends DialogComponent {
     pub = false;
     slip = false;
     title: string;
@@ -27,11 +27,7 @@ export class HoldNoteDialogComponent extends DialogComponent implements OnInit {
         private modal: NgbModal,
         private idl: IdlService,
         private pcrud: PcrudService
-    ) {
-        super(modal);
-    }
-
-    ngOnInit() {}
+    ) { super(modal); }
 
     createNote() {
         const note = this.idl.create('ahrn');
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.html
new file mode 100644 (file)
index 0000000..e44a075
--- /dev/null
@@ -0,0 +1,25 @@
+<ng-template #dialogContent>
+  <div class="modal-header bg-info">
+    <h4 class="modal-title">Create Record of Hold Notification</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">
+                       <label for="method-input" i18n>Notification Method</label>
+                       <input type="text" class="form-control" id="method-input" required [(ngModel)]="method"/>
+               </div>
+               <div class="form-group">
+                       <label for="note-input" i18n>Note</label>
+                       <textarea class="form-control" id="note-input" required [(ngModel)]="note">
+      </textarea>
+               </div>
+    <div class="w-100">
+      <button class="btn btn-success ml-auto" (click)="createNotify()"
+        [disabled]="!method || !note" i18n>Create</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/notify-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.ts
new file mode 100644 (file)
index 0000000..06baa34
--- /dev/null
@@ -0,0 +1,45 @@
+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 notify dialog */
+
+@Component({
+  selector: 'eg-hold-notify-dialog',
+  templateUrl: 'notify-dialog.component.html'
+})
+export class HoldNotifyDialogComponent extends DialogComponent {
+    method: string;
+    note: string;
+
+    @Input() holdId: number;
+
+    constructor(
+        private modal: NgbModal,
+        private idl: IdlService,
+        private auth: AuthService,
+        private pcrud: PcrudService
+    ) { super(modal); }
+
+    createNotify() {
+        const notify = this.idl.create('ahn');
+        notify.hold(this.holdId);
+        notify.notify_staff(this.auth.user().id());
+        notify.method(this.method);
+        notify.note(this.note);
+
+        this.pcrud.create(notify).toPromise().then(
+            resp => this.close(resp), // new notify object
+            err => console.error('Could not create notify', err)
+        );
+    }
+}
+
+