LP1904036 clear holds on checkout support
authorBill Erickson <berickxx@gmail.com>
Thu, 22 Apr 2021 16:48:04 +0000 (12:48 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:32 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.html
Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.module.ts
Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts
Open-ILS/src/eg2/src/app/staff/share/circ/events-dialog.component.html
Open-ILS/src/eg2/src/app/staff/share/circ/events-dialog.component.ts

index 480ae7c..e994e68 100644 (file)
@@ -8,6 +8,7 @@
   text="Item CONC40000598 has never circulated."></eg-string>
 <eg-backdate-dialog #backdateDialog></eg-backdate-dialog>
 <eg-cancel-transit-dialog #cancelTransitDialog></eg-cancel-transit-dialog>
+<eg-worklog-strings-components></eg-worklog-strings-components>
 
 <div class="row" *ngIf="hasAlerts()">
   <div class="col-lg-12 alert alert-danger p-1">
index 2455fa0..9e4135d 100644 (file)
@@ -10,6 +10,7 @@ import {BookingModule} from '@eg/staff/share/booking/booking.module';
 import {PatronModule} from '@eg/staff/share/patron/patron.module';
 import {BarcodesModule} from '@eg/staff/share/barcodes/barcodes.module';
 import {CheckinComponent} from './checkin.component';
+import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module';
 
 @NgModule({
   declarations: [
@@ -25,7 +26,8 @@ import {CheckinComponent} from './checkin.component';
     HoldingsModule,
     BookingModule,
     PatronModule,
-    BarcodesModule
+    BarcodesModule,
+    WorkLogModule
   ],
   providers: [
   ]
index 3d4d453..1a70461 100644 (file)
@@ -618,13 +618,24 @@ export class CircService {
         const params = result.params;
         const mode = checkin ? 'checkin' : (params._renewal ? 'renew' : 'checkout');
 
+        const holdShelfEvent = events.filter(e => e.textcode === 'ITEM_ON_HOLDS_SHELF')[0];
+
+        if (holdShelfEvent) {
+            this.components.circEventsDialog.clearHolds = this.clearHoldsOnCheckout;
+            this.components.circEventsDialog.patronId = holdShelfEvent.payload.patron_id;
+            this.components.circEventsDialog.patronName = holdShelfEvent.payload.patron_name;
+        }
+
         this.components.circEventsDialog.events = events;
         this.components.circEventsDialog.mode = mode;
 
         return this.components.circEventsDialog.open().toPromise()
-        .then(confirmed => {
+        .then(resp => {
+            const confirmed = resp.override;
             if (!confirmed) { return null; }
 
+            let promise = Promise.resolve(null);
+
             if (!checkin) {
                 // Indicate these events have been seen and overridden.
                 events.forEach(evt => {
@@ -632,11 +643,30 @@ export class CircService {
                         this.autoOverrideCheckoutEvents[evt.textcode] = true;
                     }
                 });
-            }
 
-            params._override = true;
+                if (holdShelfEvent && resp.clearHold) {
+                    const holdId = holdShelfEvent.payload.hold_id;
+
+                    // Cancel the hold that put our checkout item
+                    // on the holds shelf.
+
+                    promise = promise.then(_ => {
+                        return this.net.request(
+                            'open-ils.circ',
+                            'open-ils.circ.hold.cancel',
+                            this.auth.token(),
+                            holdId,
+                            5, // staff forced
+                            'Item checked out by other patron' // FIXME I18n
+                        ).toPromise();
+                    });
+                }
+            }
 
-            return this[mode](params); // checkout/renew/checkin
+            return promise.then(_ => {
+                params._override = true;
+                return this[mode](params); // checkout/renew/checkin
+            });
         });
     }
 
index 0b83e0c..0c35a48 100644 (file)
               <div class="mt-2 font-weight-bold">{{evt.payload}}</div>
             </ng-container>
           </ng-container>
+          <ng-container *ngIf="evt.textcode == 'ITEM_ON_HOLDS_SHELF'">
+            <a target="_blank" class="mt-3"
+              routerLink="/staff/circ/patron/{{patronId}}/checkout">{{patronName}}</a>.
+
+            <div class="mt-3 mb-3">
+              <div class="form-check form-check-inline">
+                <input class="form-check-input" type="checkbox" 
+                  id="clear-hold-cbox" [(ngModel)]="clearHold"/>
+                <label class="form-check-label" for="clear-hold-cbox" i18n>
+                  Cancel this hold upon checkout?
+                </label>
+              </div>
+            </div>
+
+          </ng-container>
         </div>
       </div>
     </ng-container>
   </div>
   <div class="modal-footer">
     <button type="button" class="btn btn-info"
-      (click)="close(true)" i18n>Force Action?</button>
+      (click)="close({override: true, clearHold: clearHold})" i18n>
+      Force Action?</button>
     <button type="button" class="btn btn-warning"
       (click)="close(false)" i18n>Cancel</button>
   </div>
index bd1f21e..e7fb4d5 100644 (file)
@@ -18,6 +18,9 @@ export class CircEventsComponent extends DialogComponent implements OnInit {
     @Input() events: EgEvent[] = [];
     @Input() mode: 'checkout' | 'renew' | 'checkin';
     modeLabel: string;
+    clearHolds = false;
+    patronId: number = null;
+    patronName: string;
 
     constructor(
         private modal: NgbModal,