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: [
],
providers: [
StaffCatalogService,
- HoldingsService
+ HoldingsService,
+ HoldService
]
})
<div class="row"><div class="col-lg-12"><hr/></div></div>
<div class="row font-weight-bold pt-3 ml-1 mr-1">
- <div class="col-lg-10" i18n>Placing hold(s) on record(s)</div>
- <div class="col-lg-2" i18n>Holds Status</div>
+ <div class="col-lg-12" i18n>Placing hold(s) on record(s)</div>
</div>
-<ng-container *ngFor="let recId of recordIds">
- <div class="row mt-2 ml-1 mr-1">
- <div class="col-lg-10">
- <eg-bib-summary [recordId]="recId" [expand]="false"></eg-bib-summary>
+
+<div class="hold-records-list common-form striped-even">
+
+ <div class="row mt-2 ml-1 mr-1 font-weight-bold">
+ <div class="col-lg-3" i18n>Title</div>
+ <div class="col-lg-2" i18n>Author</div>
+ <div class="col-lg-1" i18n>TCN</div>
+ <div class="col-lg-2" i18n>Call Number</div>
+ <div class="col-lg-1" i18n>Barcode</div>
+ <div class="col-lg-3" i18n>Holds Status</div>
+ </div>
+ <div class="row mt-1 ml-1 mr-1" *ngFor="let rec of recordSummaries">
+ <div class="col-lg-3">
+ <a routerLink="/staff/catalog/record/{{rec.id}}">{{rec.display.title}}</a>
</div>
+ <div class="col-lg-2">{{rec.display.author}}</div>
+ <div class="col-lg-1">{{rec.record.tcn_value()}}</div>
<div class="col-lg-2">
+ <ng-container *ngIf="holdType == 'T'">
+ <span class="font-italic">ANY</span>
+ </ng-container>
+ </div>
+ <div class="col-lg-1">
+ <ng-container *ngIf="holdType == 'T' || holdType == 'V'">
+ <span class="font-italic">ANY</span>
+ </ng-container>
+ </div>
+ <div class="col-lg-3">
<div class="alert alert-info">Hold Pending</div>
</div>
</div>
-</ng-container>
+</div>
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'
suspend: boolean;
activeDate: string;
recordIds: number[];
+ recordSummaries: BibRecordSummary[];
currentUserBarcode: string;
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() {
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);
}
}
- 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);
+ });
}
}
--- /dev/null
+/**
+ * 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<HoldRequest> {
+
+ 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;
+ }
+ ));
+ }
+}
+
*/
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;
@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(
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');
+ });
+ });
}
-
}