<div class="col-lg-2" i18n>Holds Status</div>
<div class="col-lg-1" i18n>Override</div>
</div>
+ <div class="row mt-1 ml-1 mr-1" *ngIf="showOverrideAll()">
+ <div class="col-lg-12">
+ <div class="row">
+ <div class="col-lg-1 ml-auto">
+ <button class="btn btn-info" i18n
+ (click)="overrideAll()">
+ Override All
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
<div class="row mt-1 ml-1 mr-1" *ngFor="let ctx of holdContexts">
<div class="col-lg-12" *ngIf="ctx.holdMeta">
<div class="row">
}
// Attempt hold placement on all targets
- placeHolds(idx?: number) {
+ placeHolds(idx?: number, override?: boolean) {
if (!idx) {
idx = 0;
- if (this.multiHoldCount > 1) {
+ if (this.multiHoldCount > 1 && !override) {
this.addMultHoldContexts();
}
}
this.placeHoldsClicked = true;
const ctx = this.holdContexts[idx];
- this.placeOneHold(ctx).then(() => this.placeHolds(idx + 1));
+ this.placeOneHold(ctx, override).then(() =>
+ this.placeHolds(idx + 1, override)
+ );
}
afterPlaceHolds(somePlaced: boolean) {
placeOneHold(ctx: HoldContext, override?: boolean): Promise<any> {
+ if (override && !this.canOverride(ctx)) {
+ return Promise.resolve();
+ }
+
ctx.processing = true;
const selectedFormats = this.mrSelectorsToFilters(ctx);
user: this.user.family_name()
});
- // Overrides are processed one hold at a time, so
- // we have to invoke the post-holds logic here
- // instead of the batch placeHolds() method. If
- // there is ever a batch override option, this
- // logic will have to be adjusted avoid callling
- // afterPlaceHolds in batch mode.
- if (override) { this.afterPlaceHolds(true); }
-
} else {
console.debug('hold failed with: ', request);
}
override(ctx: HoldContext) {
- this.placeOneHold(ctx, true);
+ this.placeOneHold(ctx, true).then(() => {
+ this.afterPlaceHolds(ctx.success);
+ });
}
canOverride(ctx: HoldContext): boolean {
!ctx.lastRequest.result.success && ctx.canOverride;
}
+ showOverrideAll(): boolean {
+ return this.holdContexts.filter(ctx =>
+ this.canOverride(ctx)
+ ).length > 1;
+ }
+
+ overrideAll(): void {
+ this.placeHolds(0, true);
+ }
+
iconFormatLabel(code: string): string {
return this.cat.iconFormatLabel(code);
}