<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>
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 */
@Output() onShowList: EventEmitter<any>;
@ViewChild('noteDialog') noteDialog: HoldNoteDialogComponent;
+ @ViewChild('notifyDialog') notifyDialog: HoldNotifyDialogComponent;
constructor(
private net: NetService,
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) {
newNote() {
this.noteDialog.open().subscribe(note => this.notes.unshift(note));
}
+
+ newNotify() {
+ this.notifyDialog.open().subscribe(notify => this.getNotifies()); // fleshing
+ }
}
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: [
HoldTransferDialogComponent,
HoldCancelDialogComponent,
HoldManageDialogComponent,
- HoldNoteDialogComponent
+ HoldNoteDialogComponent,
+ HoldNotifyDialogComponent
],
imports: [
StaffCommonModule,
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;
private modal: NgbModal,
private idl: IdlService,
private pcrud: PcrudService
- ) {
- super(modal);
- }
-
- ngOnInit() {}
+ ) { super(modal); }
createNote() {
const note = this.idl.create('ahrn');
--- /dev/null
+<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">×</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>
--- /dev/null
+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)
+ );
+ }
+}
+
+