From 332ecd557c5661dea2dd565f628f2cc4e8390ba1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Sat, 16 Feb 2019 11:42:14 -0800 Subject: [PATCH] LP1806087 Catalog holds display WIP Signed-off-by: Bill Erickson --- .../eg2/src/app/staff/catalog/catalog.module.ts | 4 +- .../app/staff/catalog/record/holds.component.html | 218 +++++++++++++++++++++ .../app/staff/catalog/record/holds.component.ts | 99 ++++++++++ .../app/staff/catalog/record/record.component.html | 3 + .../app/staff/catalog/record/record.component.ts | 1 - 5 files changed, 323 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 2d30199441..cc30f6cc1d 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -21,6 +21,7 @@ import {PartsComponent} from './record/parts.component'; import {PartMergeDialogComponent} from './record/part-merge-dialog.component'; import {BrowseComponent} from './browse.component'; import {BrowseResultsComponent} from './browse/results.component'; +import {HoldsComponent} from './record/holds.component'; @NgModule({ declarations: [ @@ -39,7 +40,8 @@ import {BrowseResultsComponent} from './browse/results.component'; PartsComponent, PartMergeDialogComponent, BrowseComponent, - BrowseResultsComponent + BrowseResultsComponent, + HoldsComponent ], imports: [ StaffCommonModule, 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 new file mode 100644 index 0000000000..29fd2d3451 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html @@ -0,0 +1,218 @@ + +
+ + + + + + + + + + + {{cp_barcode}} + + + + + + + + + + + + + + + + {{hold.title}} + + + + + + + + + + + + + + +
+ + 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 new file mode 100644 index 0000000000..75517ce795 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts @@ -0,0 +1,99 @@ +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {Observable, of} from 'rxjs'; +import {map, filter} from 'rxjs/operators'; +import {IdlObject} from '@eg/core/idl.service'; +import {NetService} from '@eg/core/net.service'; +import {OrgService} from '@eg/core/org.service'; +import {AuthService} from '@eg/core/auth.service'; +import {StaffCatalogService} from '../catalog.service'; +import {Pager} from '@eg/share/util/pager'; +import {GridDataSource} from '@eg/share/grid/grid'; +import {GridComponent} from '@eg/share/grid/grid.component'; + +@Component({ + selector: 'eg-catalog-holds', + templateUrl: 'holds.component.html' +}) +export class HoldsComponent implements OnInit { + + recId: number; + initDone = false; + gridDataSource: GridDataSource; + pickupLib: IdlObject; + holdsCount: number; + holdsContext: any; + @ViewChild('holdsGrid') copyGrid: GridComponent; + + @Input() set recordId(id: number) { + this.recId = id; + // Only force new data collection when recordId() + // is invoked after ngInit() has already run. + if (this.initDone) { + this.copyGrid.reload(); + } + } + + constructor( + private net: NetService, + private org: OrgService, + private auth: AuthService, + private staffCat: StaffCatalogService, + ) { + this.gridDataSource = new GridDataSource(); + } + + ngOnInit() { + this.initDone = true; + + this.gridDataSource.getRows = (pager: Pager, sort: any[]) => { + // sorting not currently supported + return this.fetchHolds(pager); + }; + + this.holdsContext = { + + } + } + + fetchHolds(pager: Pager): Observable { + if (!this.recId) { return of([]); } + + const orgs = + this.org.descendants(this.staffCat.searchContext.searchOrg, true); + + const restrictions = { + is_staff_request: true, + fulfillment_time: null, + cancel_time: null, + record_id: this.recId, + pickup_lib: orgs + }; + + let first = true; + return this.net.request( + 'open-ils.circ', + 'open-ils.circ.hold.wide_hash.stream', + this.auth.token(), + restrictions + //restrictions, order_by, limit, offset + ).pipe( + + filter(holdData => { + // First API response is the hold count. + if (first) { + this.holdsCount = holdData; + first = false; + return false; + } + return true; + }), + + map(holdData => { + console.log(holdData); + return holdData; + }) + ); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html index d1385230f3..5f3bf73a8a 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.html @@ -41,6 +41,9 @@ + + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts index e6832f1ab9..6c935ffdcf 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts @@ -12,7 +12,6 @@ import {StoreService} from '@eg/core/store.service'; const ANGJS_TABS: any = { marc_edit: true, - holds: true, holdings: true, conjoined: true }; -- 2.11.0