From c41e899d4fbfa2e7e42a74b9e40377f7d166ad04 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 27 Nov 2018 11:35:01 -0500 Subject: [PATCH] place holds continued Signed-off-by: Bill Erickson --- .../src/app/staff/catalog/hold/hold.component.html | 18 ++--- .../src/app/staff/catalog/hold/hold.component.ts | 85 +++------------------- .../src/eg2/src/app/staff/share/hold.service.ts | 77 ++++++++++++++++++-- 3 files changed, 90 insertions(+), 90 deletions(-) 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 2656c43b4d..8e09a274c9 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 @@ -183,9 +183,9 @@
Override
- +
- + {{iconFormatLabel(code)}}
-
{{ctx.bibSummary.display.author}}
+
{{ctx.fleshedTarget.bibSummary.display.author}}
- - {{ctx.volume.label()}} + + {{ctx.fleshedTarget.volume.label()}}
- - {{ctx.copy.barcode()}} + + {{ctx.fleshedTarget.copy.barcode()}}
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 7da3aba2d9..616060de0c 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 @@ -13,17 +13,13 @@ import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.s import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {CatalogService} from '@eg/share/catalog/catalog.service'; import {StaffCatalogService} from '../catalog.service'; -import {HoldService, HoldRequest} from '@eg/staff/share/hold.service'; +import {HoldService, HoldRequest, HoldRequestTarget} + from '@eg/staff/share/hold.service'; import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; class HoldContext { - recordId: number; - bibSummary: BibRecordSummary; + fleshedTarget: HoldRequestTarget; holdTarget: number; - volume: IdlObject; - copy: IdlObject; - part: IdlObject; - issuance: IdlObject; lastRequest: HoldRequest; canOverride?: boolean; } @@ -97,7 +93,7 @@ export class HoldComponent implements OnInit { return ctx; }); - this.findRecords(); + this.getTargetMeta(); this.org.settings('sms.enable').then(sets => { this.smsEnabled = sets['sms.enable'] @@ -117,74 +113,11 @@ export class HoldComponent implements OnInit { } // Load the bib, call number, copy, etc. data associated with each target. - findRecords() { - - switch (this.holdType) { - - case 'T': - this.holdContexts.forEach(ctx => ctx.recordId = ctx.holdTarget); - this.getRecordSummaries(); - break; - - case 'V': - const volIds = this.holdContexts.map(ctx => ctx.holdTarget); - this.pcrud.search('acn', {id: volIds}) - .subscribe( - vol => { - this.holdContexts.filter( - ctx => ctx.holdTarget === vol.id() - ).forEach(ctx => { - ctx.volume = vol; - ctx.recordId = vol.record(); - }); - }, - err => {}, - () => this.getRecordSummaries() - ); - break; - - case 'C': - case 'R': - case 'F': - const copyIds = this.holdContexts.map(ctx => ctx.holdTarget); - this.pcrud.search('acp', {id: copyIds}, - {flesh: 1, flesh_fields: {'acp': ['call_number']} - ).subscribe( - copy => { - this.holdContexts.filter( - ctx => ctx.holdTarget === copy.id() - ).forEach(ctx => { - ctx.copy = copy; - ctx.volume = copy.call_number(); - ctx.recordId = copy.call_number().record(); - }); - }, - err => {}, - () => this.getRecordSummaries() - ) - break; - - case 'I': // TODO - break; - - case 'P': // TODO - break; - } - } - - getRecordSummaries() { - - const ids = this.holdContexts.map(ctx => ctx.recordId); - - this.bib.getBibSummary(ids).subscribe( - sum => { - this.holdContexts.forEach(ctx => { - if (ctx.recordId === sum.id) { - ctx.bibSummary = sum; - } - }); - } - ); + getTargetMeta() { + this.holdContexts.forEach(ctx => { + this.holds.getHoldTargetMeta(this.holdType, ctx.holdTarget) + .then(fleshedTarget => ctx.fleshedTarget = fleshedTarget); + }); } holdForChanged() { 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 index 5651d5941b..a647e6f28f 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/hold.service.ts @@ -4,9 +4,13 @@ import {Injectable, EventEmitter} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {map} from 'rxjs/operators/map'; +import {IdlObject} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; +import {PcrudService} from '@eg/core/pcrud.service'; import {EventService, EgEvent} from '@eg/core/event.service'; import {AuthService} from '@eg/core/auth.service'; +import {BibRecordService, BibRecordSummary} + from '@eg/share/catalog/bib-record.service'; export interface HoldRequestResult { success: boolean; @@ -27,18 +31,31 @@ export interface HoldRequest { smsCarrier?: string; thawDate?: string; // ISO date frozen?: boolean; - //holdableFormats?: {[id: number]: string[]}; + holdableFormats?: {[id: number]: string[]}; result?: HoldRequestResult - // ... }; +// A fleshed hold request target blob with whatever data is +// available for each hold type / target. +export interface HoldRequestTarget { + metarecord?: IdlObject, + recordId?: number, + bibSummary?: BibRecordSummary, + part?: IdlObject, + volume?: IdlObject, + copy?: IdlObject, + issuance?: IdlObject +} + @Injectable() export class HoldService { constructor( private evt: EventService, private net: NetService, - private auth: AuthService + private pcrud: PcrudService, + private auth: AuthService, + private bib: BibRecordService, ) {} placeHold(request: HoldRequest): Observable { @@ -56,8 +73,8 @@ export class HoldService { thaw_date: request.thawDate, frozen: request.frozen, sms_notify: request.notifySms, - sms_carrier: request.smsCarrier - //holdable_formats_map: request.holdableFormats + sms_carrier: request.smsCarrier, + holdable_formats_map: request.holdableFormats }, [request.holdTarget] ).pipe(map( @@ -91,5 +108,55 @@ export class HoldService { } )); } + + addRecordSummary(target: HoldRequestTarget): Promise { + return this.bib.getBibSummary(target.recordId).toPromise() + .then(sum => { + target.bibSummary = sum; + return target; + }); + } + + getHoldTargetMeta(holdType: string, + holdTarget: number): Promise { + + const target: HoldRequestTarget = {}; + + switch (holdType) { + + case 'M': // TODO + break; + + case 'T': + target.recordId = holdTarget; + return this.addRecordSummary(target); + + case 'P': // TODO + break; + + case 'V': + return this.pcrud.retrieve('acn', holdTarget).toPromise() + .then(vol => { + target.volume = vol; + target.recordId = vol.record(); + return this.addRecordSummary(target); + }); + + case 'I': // TODO + break; + + case 'C': + case 'R': + case 'F': + return this.pcrud.retrieve('acp', holdTarget, + {flesh: 1, flesh_fields: {'acp': ['call_number']}} + ).toPromise().then(copy => { + target.copy = copy; + target.volume = copy.call_number(); + target.recordId = copy.call_number().record(); + return this.addRecordSummary(target); + }); + } + } } -- 2.11.0