From: Bill Erickson Date: Mon, 19 Nov 2018 19:42:24 +0000 (-0500) Subject: place holds continued X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4ab2aaea4ee1d0e78a41efdc56609645c6a05181;p=working%2FEvergreen.git place holds continued Signed-off-by: Bill Erickson --- 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 0b0356e25d..87cda490c2 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 @@ -16,6 +16,7 @@ import {RecordActionsComponent} from './record/actions.component'; import {HoldingsService} from '@eg/staff/share/holdings.service'; import {BasketActionsComponent} from './basket-actions.component'; import {HoldComponent} from './hold/hold.component'; +import {HoldService} from '@eg/staff/share/hold.service'; @NgModule({ declarations: [ @@ -39,7 +40,8 @@ import {HoldComponent} from './hold/hold.component'; ], providers: [ StaffCatalogService, - HoldingsService + HoldingsService, + HoldService ] }) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html index 275686c724..f594ad09fd 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html @@ -110,18 +110,39 @@

-
Placing hold(s) on record(s)
-
Holds Status
+
Placing hold(s) on record(s)
- -
-
- + +
+ +
+
Title
+
Author
+
TCN
+
Call Number
+
Barcode
+
Holds Status
+
+
+ +
{{rec.display.author}}
+
{{rec.record.tcn_value()}}
+ + ANY + +
+
+ + ANY + +
+
Hold Pending
- +
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts index b499b067f4..0a342704b5 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts @@ -5,9 +5,11 @@ import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {IdlObject} from '@eg/core/idl.service'; +import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service'; import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {CatalogService} from '@eg/share/catalog/catalog.service'; import {StaffCatalogService} from '../catalog.service'; +import {HoldService} from '@eg/staff/share/hold.service'; @Component({ templateUrl: 'hold.component.html' @@ -28,6 +30,7 @@ export class HoldComponent implements OnInit { suspend: boolean; activeDate: string; recordIds: number[]; + recordSummaries: BibRecordSummary[]; currentUserBarcode: string; @@ -39,9 +42,14 @@ export class HoldComponent implements OnInit { private net: NetService, private auth: AuthService, private pcrud: PcrudService, + private bib: BibRecordService, private cat: CatalogService, - private staffCat: StaffCatalogService - ) {} + private staffCat: StaffCatalogService, + private holds: HoldService + ) { + this.recordIds = []; + this.recordSummaries = []; + } ngOnInit() { @@ -64,11 +72,20 @@ export class HoldComponent implements OnInit { findRecords() { if (this.holdType === 'T') { this.recordIds = this.holdTargets; + this.getRecordSummaries(); } else { // TODO OTHER HOLD TYPES } } + getRecordSummaries() { + this.bib.getBibSummary(this.recordIds).subscribe( + sum => this.recordSummaries.push(sum), + err => {}, + () => {} + ) + } + holdForChanged() { console.log('placing hold for ' + this.holdFor); @@ -179,7 +196,21 @@ export class HoldComponent implements OnInit { } } - placeHolds() { + placeHolds(idx?: number) { + if (!idx) { idx = 0; } + if (!this.holdTargets[idx]) { return; } + + this.holds.placeHold({ + holdTarget: this.holdTargets[idx], + holdType: this.holdType, + recipient: this.user.id(), + requestor: this.requestor.id(), + pickupLib: this.pickupLib + + }).subscribe(request => { + console.log('hold returned: ', request); + this.placeHolds(idx + 1); + }); } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts b/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts new file mode 100644 index 0000000000..dcd9cbb10a --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts @@ -0,0 +1,62 @@ +/** + * Common code for mananging holdings + */ +import {Injectable, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {map} from 'rxjs/operators/map'; +import {NetService} from '@eg/core/net.service'; +import {EventService, EgEvent} from '@eg/core/event.service'; +import {AuthService} from '@eg/core/auth.service'; + +export interface HoldRequest { + holdType: string; + holdTarget: number; + recipient: number; + requestor: number; + pickupLib: number; + override?: boolean; + //holdableFormats?: {[id: number]: string[]}; + + // result contains 'success', and (parsed) 'last_event' + result?: any; + // ... +}; + +@Injectable() +export class HoldService { + + constructor( + private evt: EventService, + private net: NetService, + private auth: AuthService + ) {} + + placeHold(request: HoldRequest): Observable { + + return this.net.request( + 'open-ils.circ', + 'open-ils.circ.holds.test_and_create.batch', + this.auth.token(), { + patronid: request.recipient, + pickup_lib: request.pickupLib, + hold_type: request.holdType, + //holdable_formats_map: request.holdableFormats + }, + [request.holdTarget] + ).pipe(map( + resp => { + const result = resp.result; + result.last_event = this.evt.parse(result.last_event); + result.success = Boolean(Number(result.success)); + if (result.sucesss) { + console.debug('Hold successfully placed'); + } else if (result.last_event) { + console.warn(`Hold Request returned: ${result.last_event}`); + } + request.result = result; + return request; + } + )); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts b/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts index d2596b5527..cf58409982 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings.service.ts @@ -3,6 +3,7 @@ */ import {Injectable, EventEmitter} from '@angular/core'; import {NetService} from '@eg/core/net.service'; +import {AnonCacheService} from '@eg/share/util/anon-cache.service'; interface NewVolumeData { owner: number; @@ -12,7 +13,10 @@ interface NewVolumeData { @Injectable() export class HoldingsService { - constructor(private net: NetService) {} + constructor( + private net: NetService, + private anonCache: AnonCacheService + ) {} // Open the holdings editor UI in a new browser window/tab. spawnAddHoldingsUi( @@ -30,28 +34,21 @@ export class HoldingsService { if (raw.length === 0) { raw.push({}); } - this.net.request( - 'open-ils.actor', - 'open-ils.actor.anon_cache.set_value', - null, 'edit-these-copies', { - record_id: recordId, - raw: raw, - hide_vols : false, - hide_copies : false + this.anonCache.setItem(null, 'edit-these-copies', { + record_id: recordId, + raw: raw, + hide_vols : false, + hide_copies : false + }).then(key => { + if (!key) { + console.error('Could not create holds cache key!'); + return; } - ).subscribe( - key => { - if (!key) { - console.error('Could not create holds cache key!'); - return; - } - setTimeout(() => { - const url = `/eg/staff/cat/volcopy/${key}`; - window.open(url, '_blank'); - }); - } - ); + setTimeout(() => { + const url = `/eg/staff/cat/volcopy/${key}`; + window.open(url, '_blank'); + }); + }); } - }