From cf413cf3b4f079ad2559aa2f54189689bb0426f7 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 4 Jan 2021 16:12:50 -0500 Subject: [PATCH] LP1910145 Angular Hold Detail Notes & Notifications The hold detail view now displays hold notes and hold notification records. Notes and Notifications may be created by staff. Notes may be deleted by staff. Signed-off-by: Bill Erickson Signed-off-by: Garry Collum Signed-off-by: Galen Charlton --- .../staff/share/holds/detail.component.html | 69 +++++++++++++++- .../app/staff/share/holds/detail.component.ts | 80 ++++++++++++++++--- .../src/app/staff/share/holds/holds.module.ts | 6 +- .../share/holds/note-dialog.component.html | 37 +++++++++ .../share/holds/note-dialog.component.ts | 48 +++++++++++ .../share/holds/notify-dialog.component.html | 25 ++++++ .../share/holds/notify-dialog.component.ts | 45 +++++++++++ Open-ILS/src/eg2/src/styles.css | 8 ++ 8 files changed, 302 insertions(+), 16 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.html b/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.html index bc7e4f6627..e80d1ff524 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.html @@ -1,11 +1,11 @@ - - - + +
-
+
+

Hold #{{holdId}}

@@ -96,3 +96,64 @@
+
+
+ +
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.ts index 67b3801e0d..2f28c24bd9 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/detail.component.ts @@ -1,8 +1,13 @@ import {Component, OnInit, Input, Output, ViewChild, EventEmitter} from '@angular/core'; import {Observable, Observer, of} from 'rxjs'; +import {tap} from 'rxjs/operators'; +import {IdlObject} 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 {HoldNoteDialogComponent} from './note-dialog.component'; +import {HoldNotifyDialogComponent} from './notify-dialog.component'; /** Hold details read-only view */ @@ -11,25 +16,42 @@ import {AuthService} from '@eg/core/auth.service'; templateUrl: 'detail.component.html' }) export class HoldDetailComponent implements OnInit { + detailTab = 'notes'; + notes: IdlObject[] = []; + notifies: IdlObject[] = []; - _holdId: number; + private _holdId: number; @Input() set holdId(id: number) { - this._holdId = id; - if (this.initDone) { - this.fetchHold(); + if (this._holdId !== id) { + this._holdId = id; + if (this.initDone) { + this.fetchHold(); + } } } + get holdId(): number { + return this._holdId; + } + hold: any; // wide hold reference @Input() set wideHold(wh: any) { this.hold = wh; } + get wideHold(): any { + return this.hold; + } + initDone: boolean; @Output() onShowList: EventEmitter; + @ViewChild('noteDialog') noteDialog: HoldNoteDialogComponent; + @ViewChild('notifyDialog') notifyDialog: HoldNotifyDialogComponent; + constructor( private net: NetService, + private pcrud: PcrudService, private org: OrgService, private auth: AuthService, ) { @@ -42,15 +64,38 @@ export class HoldDetailComponent implements OnInit { } fetchHold() { - if (!this._holdId) { return; } + if (!this.holdId && !this.hold) { return; } - this.net.request( - 'open-ils.circ', - 'open-ils.circ.hold.wide_hash.stream', - this.auth.token(), {id: this._holdId} - ).subscribe(wideHold => { + const promise = this.hold ? Promise.resolve(this.hold) : + this.net.request( + 'open-ils.circ', + 'open-ils.circ.hold.wide_hash.stream', + this.auth.token(), {id: this.holdId} + ).toPromise(); + + return promise.then(wideHold => { this.hold = wideHold; - }); + // avoid this.holdId = since it re-fires this fetch. + this._holdId = wideHold.id; + }) + .then(_ => this.getNotes()) + .then(_ => this.getNotifies()); + } + + getNotes(): Promise { + this.notes = []; + return this.pcrud.search('ahrn', {hold: this.holdId}) + .pipe(tap(note => this.notes.push(note))).toPromise(); + } + + getNotifies(): Promise { + this.notifies = []; + + 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) { @@ -62,6 +107,19 @@ export class HoldDetailComponent implements OnInit { showListView() { this.onShowList.emit(); } + + deleteNote(note: IdlObject) { + this.pcrud.remove(note).toPromise() + .then(ok => { if (ok) { this.getNotes(); } }); + } + + newNote() { + this.noteDialog.open().subscribe(note => this.notes.unshift(note)); + } + + newNotify() { + this.notifyDialog.open().subscribe(notify => this.getNotifies()); // fleshing + } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/holds.module.ts b/Open-ILS/src/eg2/src/app/staff/share/holds/holds.module.ts index 5bcb68aeaf..b5b4bb25b7 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holds/holds.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/holds.module.ts @@ -9,6 +9,8 @@ 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'; +import {HoldNotifyDialogComponent} from './notify-dialog.component'; @NgModule({ declarations: [ @@ -18,7 +20,9 @@ import {HoldManageDialogComponent} from './manage-dialog.component'; HoldRetargetDialogComponent, HoldTransferDialogComponent, HoldCancelDialogComponent, - HoldManageDialogComponent + HoldManageDialogComponent, + HoldNoteDialogComponent, + HoldNotifyDialogComponent ], 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 index 0000000000..fa3ed9e8c6 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.html @@ -0,0 +1,37 @@ + + + + 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 index 0000000000..935dd5dc51 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/note-dialog.component.ts @@ -0,0 +1,48 @@ +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 { + pub = false; + slip = false; + title: string; + body: string; + + @Input() holdId: number; + + constructor( + private modal: NgbModal, + private idl: IdlService, + private pcrud: PcrudService + ) { super(modal); } + + 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) + ); + } +} + + 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 index 0000000000..5d8e0b0118 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.html @@ -0,0 +1,25 @@ + + + + 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 index 0000000000..06baa34756 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/notify-dialog.component.ts @@ -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) + ); + } +} + + diff --git a/Open-ILS/src/eg2/src/styles.css b/Open-ILS/src/eg2/src/styles.css index 9ec9f67262..5ff572a608 100644 --- a/Open-ILS/src/eg2/src/styles.css +++ b/Open-ILS/src/eg2/src/styles.css @@ -63,6 +63,14 @@ h5 {font-size: .95rem} min-height: 40px; } +.well-table .well-label-no-flex { + display: flex; + align-items: center; + margin: 4px; + padding: 4px; + min-height: 40px; +} + .well-table .well-value { flex: 1; display: flex; -- 2.43.2