From d7df058229d063a0d5cea56ab19211d0cb1f4659 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 Signed-off-by: Michele Morgan --- .../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 b374fbf19b..c9f72dab03 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 @@ -282,6 +282,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 9c72ae616a..a74bc37354 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 @@ -546,10 +546,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(); } } @@ -561,7 +561,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) { @@ -601,6 +603,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); @@ -646,14 +652,6 @@ export class HoldComponent implements OnInit { 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); @@ -677,7 +675,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 { @@ -685,6 +685,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