From b55617cc06d167b1f116b29f4a03bde84c7c7b76 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 18 Feb 2019 17:53:19 -0800 Subject: [PATCH] LP1806087 Catalog holds display WIP Signed-off-by: Bill Erickson --- .../app/staff/catalog/record/holds.component.html | 12 +++++ .../app/staff/catalog/record/holds.component.ts | 57 +++++++++++++--------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html index ee778cf403..59867a052c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html @@ -4,6 +4,18 @@
+
+
+
+
+
Pickup Library
+
+ + +
+
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts index 769aec44b7..5c281b6380 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts @@ -1,5 +1,5 @@ import {Component, OnInit, Input, ViewChild} from '@angular/core'; -import {Observable, of} from 'rxjs'; +import {Observable, Observer, of} from 'rxjs'; import {map, filter} from 'rxjs/operators'; import {IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; @@ -22,7 +22,7 @@ export class HoldsComponent implements OnInit { gridDataSource: GridDataSource; pickupLib: IdlObject; holdsCount: number; - @ViewChild('holdsGrid') private copyGrid: GridComponent; + @ViewChild('holdsGrid') private holdsGrid: GridComponent; @ViewChild('progressDialog') private progressDialog: ProgressDialogComponent; @Input() set recordId(id: number) { @@ -30,7 +30,7 @@ export class HoldsComponent implements OnInit { // Only force new data collection when recordId() // is invoked after ngInit() has already run. if (this.initDone) { - this.copyGrid.reload(); + this.holdsGrid.reload(); } } @@ -45,6 +45,7 @@ export class HoldsComponent implements OnInit { ngOnInit() { this.initDone = true; + this.pickupLib = this.staffCat.searchContext.searchOrg; this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { // sorting not currently supported @@ -52,11 +53,15 @@ export class HoldsComponent implements OnInit { }; } + pickupLibChanged(org: IdlObject) { + this.pickupLib = org; + this.holdsGrid.reload(); + } + fetchHolds(pager: Pager, sort: any[]): Observable { if (!this.recId) { return of([]); } - const orgs = - this.org.descendants(this.staffCat.searchContext.searchOrg, true); + const orgs = this.org.descendants(this.pickupLib, true); const restrictions = { is_staff_request: true, @@ -73,39 +78,43 @@ export class HoldsComponent implements OnInit { orderBy.push(subObj); }); + let observer: Observer; + const observable = new Observable(obs => observer = obs); + this.progressDialog.open(); this.progressDialog.update({value: 0, max: 1}); let first = true; let loadCount = 0; - return this.net.request( + this.net.request( 'open-ils.circ', 'open-ils.circ.hold.wide_hash.stream', this.auth.token(), restrictions, orderBy, pager.limit, pager.offset - ).pipe( + ).subscribe( + holdData => { - filter(holdData => { - // First API response is the hold count. - if (first) { + if (first) { // First response is the hold count. this.holdsCount = Number(holdData); - return first = false; - } - return true; - }), + first = false; - map(holdData => { + } else { // Subsequent responses are hold data blobs - this.progressDialog.update( - {value: ++loadCount, max: this.holdsCount}); + this.progressDialog.update( + {value: ++loadCount, max: this.holdsCount}); - if (loadCount === this.holdsCount) { - this.progressDialog.close(); + observer.next(holdData); } - - // Do we even need to modify anything? - // Probably not. - return holdData; - }) + }, + err => { + this.progressDialog.close(); + observer.error(err); + }, + () => { + this.progressDialog.close(); + observer.complete(); + } ); + + return observable; } } -- 2.11.0