From 33ae48e773dbf96dc82e793d38e96ae1a0814779 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 29 Apr 2021 14:44:31 -0400 Subject: [PATCH] LP1904036 Cancel transit improvements during checkin In some cases, a checkin result may not have the transit for a copy that was just put into transit. When canceling transits, always fetch the latest/open copy transit before attempting to cancel. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../app/staff/circ/checkin/checkin.component.ts | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.ts index 3b6d42446a..e2d8e665ca 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/checkin/checkin.component.ts @@ -1,7 +1,7 @@ import {Component, ViewChild, OnInit, AfterViewInit, HostListener} from '@angular/core'; import {Location} from '@angular/common'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; -import {from} from 'rxjs'; +import {empty, from} from 'rxjs'; import {concatMap} from 'rxjs/operators'; import {IdlObject, IdlService} from '@eg/core/idl.service'; import {NetService} from '@eg/core/net.service'; @@ -337,14 +337,30 @@ export class CheckinComponent implements OnInit, AfterViewInit { cancelTransits(rows: CheckinGridEntry[]) { - const ids = rows - .filter(row => Boolean(row.transit)) - .map(row => row.transit.id()); - if (ids.length > 0) { - this.cancelTransitDialog.transitIds = ids; - this.cancelTransitDialog.open().subscribe(); - } + rows = rows.filter(row => row.copy && row.copy.status().id() === 6); + + // Copies in transit are not always accompanied by their transit. + from(rows).pipe(concatMap(row => { + return from( + this.circ.findCopyTransit(row) + .then(transit => row.transit = transit) + ); + })) + .pipe(concatMap(_ => { + + const ids = rows + .filter(row => Boolean(row.transit)) + .map(row => row.transit.id()); + + if (ids.length > 0) { + this.cancelTransitDialog.transitIds = ids; + return this.cancelTransitDialog.open(); + } else { + return empty(); + } + + })).subscribe(); } showRecordHolds(rows: CheckinGridEntry[]) { -- 2.11.0