From: Bill Erickson Date: Mon, 4 Jan 2021 21:12:50 +0000 (-0500) Subject: LP1910145 Hold notes and notifications WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e5a53312514babd849ffa08d77ffce5548e1970f;p=working%2FEvergreen.git LP1910145 Hold notes and notifications WIP Signed-off-by: Bill Erickson --- 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..616acc67aa 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,8 @@ - - - -
-
+
+

Hold #{{holdId}}

@@ -96,3 +93,45 @@
+
+
+ +
+
+
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..5a1ebbf7e2 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,6 +1,9 @@ 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'; @@ -11,25 +14,39 @@ 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; constructor( private net: NetService, + private pcrud: PcrudService, private org: OrgService, private auth: AuthService, ) { @@ -42,15 +59,37 @@ export class HoldDetailComponent implements OnInit { } fetchHold() { - if (!this._holdId) { return; } + if (!this.holdId && !this.hold) { return; } + + 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(); - this.net.request( - 'open-ils.circ', - 'open-ils.circ.hold.wide_hash.stream', - this.auth.token(), {id: this._holdId} - ).subscribe(wideHold => { + 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}, + {order_by: {ahn: 'notify_time DESC'}} + ).pipe(tap(notify => this.notifies.push(notify))).toPromise(); } getOrgName(id: number) { @@ -62,6 +101,11 @@ export class HoldDetailComponent implements OnInit { showListView() { this.onShowList.emit(); } + + deleteNote(note: IdlObject) { + this.pcrud.remove(note).toPromise() + .then(ok => { if (ok) { this.getNotes(); } }); + } } 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;