<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 class="row mt-1 ml-1 mr-1" *ngFor="let ctx of holdContexts">
+ <ng-container *ngIf="ctx.bibSummary">
+ <div class="col-lg-3">
+ <a routerLink="/staff/catalog/record/{{ctx.recordId}}">
+ {{ctx.bibSummary.display.title}}
+ </a>
+ </div>
+ <div class="col-lg-2">{{ctx.bibSummary.display.author}}</div>
+ <div class="col-lg-1">{{ctx.bibSummary.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">
+ <ng-container *ngIf="!ctx.lastRequest">
+ <div class="alert alert-info" i18n>Hold Pending</div>
+ </ng-container>
+ <ng-container *ngIf="ctx.lastRequest">
+ <ng-container *ngIf="ctx.lastRequest.result.success">
+ <div class="alert alert-success" i18n>Hold Succeeded</div>
+ </ng-container>
+ <ng-container *ngIf="!ctx.lastRequest.result.success">
+ <div class="alert alert-error">
+ {{ctx.lastRequest.result.last_event.toString()}}
+ </div>
+ </ng-container>
+ </ng-container>
+ </div>
+ </ng-container>
</div>
</div>
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';
+import {HoldService, HoldRequest} from '@eg/staff/share/hold.service';
+
+class HoldContext {
+ recordId: number;
+ bibSummary: BibRecordSummary;
+ holdTarget: number;
+ lastRequest: HoldRequest;
+}
@Component({
templateUrl: 'hold.component.html'
phoneValue: string;
suspend: boolean;
activeDate: string;
+
+ holdContexts: HoldContext[];
recordIds: number[];
recordSummaries: BibRecordSummary[];
private staffCat: StaffCatalogService,
private holds: HoldService
) {
- this.recordIds = [];
- this.recordSummaries = [];
+ this.holdContexts = [];
}
ngOnInit() {
this.holdTargets = [this.holdTargets];
}
+ this.holdTargets = this.holdTargets.map(t => Number(t));
this.holdFor = 'patron';
this.requestor = this.auth.user();
this.pickupLib = this.auth.user().ws_ou();
+
+ this.holdContexts = this.holdTargets.map(target => {
+ const ctx = new HoldContext();
+ ctx.holdTarget = target;
+ return ctx;
+ });
+
this.findRecords();
setTimeout(() => // Focus barcode input
findRecords() {
if (this.holdType === 'T') {
- this.recordIds = this.holdTargets;
+ this.holdContexts.forEach(ctx => ctx.recordId = ctx.holdTarget);
this.getRecordSummaries();
} else {
- // TODO OTHER HOLD TYPES
+ // TODO BIB IDS FOR OTHER HOLD TYPES
}
}
getRecordSummaries() {
- this.bib.getBibSummary(this.recordIds).subscribe(
- sum => this.recordSummaries.push(sum),
- err => {},
- () => {}
- )
+
+ const ids = this.holdContexts.map(ctx => ctx.recordId);
+
+ this.bib.getBibSummary(ids).subscribe(
+ sum => {
+ this.holdContexts.forEach(ctx => {
+ console.log(ctx.recordId, sum.id);
+ if (ctx.recordId === sum.id) {
+ ctx.bibSummary = sum;
+ }
+ });
+ }
+ );
}
holdForChanged() {
- console.log('placing hold for ' + this.holdFor);
if (this.holdFor === 'patron') {
if (this.userBarcode) {
}).subscribe(request => {
console.log('hold returned: ', request);
+ const ctx = this.holdContexts.filter(
+ ctx => ctx.holdTarget === request.holdTarget)[0];
+ ctx.lastRequest = request;
this.placeHolds(idx + 1);
});
}