From b91b7c41952a4b5d3c3b41cfa511d14beb38364e Mon Sep 17 00:00:00 2001 From: Dan Briem Date: Fri, 18 Feb 2022 17:25:26 -0500 Subject: [PATCH] LP#1954681 Individual overrides when placing multiple holds This adds an override all button above the override column if there are multiple overridable holds (Angular Staff Catalog). To test: 1. Ensure staff has permission to CREATE_DUPLICATE_HOLDS and HOLD_ITEM_CHECKED_OUT.override 2. Set org setting for Maximum number of duplicate holds allowed to a value greater than 1 3. Check out an item to a patron 4. Try to place a hold on that item with Number of copies set to a value greater than 1 5. Test that the Override All button appears and works Signed-off-by: Dan Briem Signed-off-by: Terran McCanna --- .../src/app/staff/catalog/hold/hold.component.html | 12 ++++++++ .../src/app/staff/catalog/hold/hold.component.ts | 34 ++++++++++++++-------- 2 files changed, 34 insertions(+), 12 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 df4130e3bb..adf4b59d8f 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 @@ -281,6 +281,18 @@
Holds Status
Override
+
+
+
+
+ +
+
+
+
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 e9c6893095..6155ec4746 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 @@ -532,10 +532,10 @@ export class HoldComponent implements OnInit { } // 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(); } } @@ -547,7 +547,9 @@ export class HoldComponent implements OnInit { 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) { @@ -587,6 +589,10 @@ export class HoldComponent implements OnInit { placeOneHold(ctx: HoldContext, override?: boolean): Promise { + if (override && !this.canOverride(ctx)) { + return Promise.resolve(); + } + ctx.processing = true; const selectedFormats = this.mrSelectorsToFilters(ctx); @@ -625,14 +631,6 @@ export class HoldComponent implements OnInit { if (request.result.success) { ctx.success = true; - // 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); @@ -656,7 +654,9 @@ export class HoldComponent implements OnInit { } override(ctx: HoldContext) { - this.placeOneHold(ctx, true); + this.placeOneHold(ctx, true).then(() => { + this.afterPlaceHolds(ctx.success); + }); } canOverride(ctx: HoldContext): boolean { @@ -664,6 +664,16 @@ export class HoldComponent implements OnInit { !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); } -- 2.11.0