From 1434ba059faf218b18f89e071762b03006dc1f43 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 15 Jul 2021 16:36:15 -0400 Subject: [PATCH] LP1936233 Item status actions menu Signed-off-by: Bill Erickson --- .../src/eg2/src/app/staff/cat/item/item.module.ts | 2 + .../src/app/staff/cat/item/status.component.html | 58 ++++++- .../eg2/src/app/staff/cat/item/status.component.ts | 175 ++++++++++++++++++++- .../src/app/staff/cat/item/summary.component.html | 4 - 4 files changed, 225 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts index fcb84ea10c..8f900486f4 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/item.module.ts @@ -15,6 +15,7 @@ import {ItemRecentHistoryComponent} from './recent-history.component'; import {ItemCircHistoryComponent} from './circ-history.component'; import {ItemHoldsTransitsComponent} from './holds.component'; import {GroupedMenuModule} from '@eg/share/grouped-menu/grouped-menu.module'; +import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module'; @NgModule({ declarations: [ @@ -35,6 +36,7 @@ import {GroupedMenuModule} from '@eg/share/grouped-menu/grouped-menu.module'; BookingModule, PatronModule, BillingModule, + WorkLogModule, GroupedMenuModule ], providers: [ diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html index 1efc194d99..b5f917af68 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html @@ -1,8 +1,10 @@ - + + + @@ -13,12 +15,12 @@ + -
@@ -38,15 +40,59 @@
+ + + + + + + + + + + i18n-group group="Add" (entryClicked)="addItemToBucket([item])"> + + + + + + + + + + + + + + + + + + + + + @@ -59,6 +105,12 @@
+
+
+ This item has been marked as Deleted. +
+
+
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts index bb846666f5..8d204ef516 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts @@ -1,6 +1,8 @@ import {Component, Input, OnInit, AfterViewInit, ViewChild} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; -import {IdlObject} from '@eg/core/idl.service'; +import {from, empty} from 'rxjs'; +import {concatMap, tap} from 'rxjs/operators'; +import {IdlObject, IdlService} from '@eg/core/idl.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {AuthService} from '@eg/core/auth.service'; import {NetService} from '@eg/core/net.service'; @@ -10,7 +12,12 @@ import {EventService} from '@eg/core/event.service'; import {PatronPenaltyDialogComponent} from '@eg/staff/share/patron/penalty-dialog.component'; import {BarcodeSelectComponent} from '@eg/staff/share/barcodes/barcode-select.component'; import {CatalogService} from '@eg/share/catalog/catalog.service'; +import {CircService} from '@eg/staff/share/circ/circ.service'; import {NgbNav, NgbNavChangeEvent} from '@ng-bootstrap/ng-bootstrap'; +import {ProgressDialogComponent} from '@eg/share/dialog/progress.component'; +import {WorkLogService, WorkLogEntry} from '@eg/staff/share/worklog/worklog.service'; +import {CancelTransitDialogComponent + } from '@eg/staff/share/circ/cancel-transit-dialog.component'; import {CopyAlertsDialogComponent } from '@eg/staff/share/holdings/copy-alerts-dialog.component'; import {ReplaceBarcodeDialogComponent @@ -69,16 +76,23 @@ export class ItemStatusComponent implements OnInit, AfterViewInit { private transferHoldings: TransferHoldingsComponent; @ViewChild('transferAlert') private transferAlert: AlertDialogComponent; + @ViewChild('progressDialog') + private progressDialog: ProgressDialogComponent; + @ViewChild('cancelTransitDialog') + private cancelTransitDialog: CancelTransitDialogComponent; constructor( private router: Router, private route: ActivatedRoute, private net: NetService, + private idl: IdlService, private printer: PrintService, private pcrud: PcrudService, private auth: AuthService, + private circ: CircService, private evt: EventService, private cat: CatalogService, + private worklog: WorkLogService, private holdings: HoldingsService ) {} @@ -89,15 +103,13 @@ export class ItemStatusComponent implements OnInit, AfterViewInit { if (!this.tab) { if (this.itemId) { - this.router.navigate([`/staff/cat/item/${this.itemId}/summary`]) - .then(ok => {if (ok) { this.load(); }}); - return; + this.tab = 'summary'; } else { this.tab = 'list'; } } - this.load(); + this.worklog.loadSettings().then(_ => this.load()); } load() { @@ -195,11 +207,160 @@ export class ItemStatusComponent implements OnInit, AfterViewInit { }); } - addToBucket() { + openProgressDialog(copies: IdlObject[]): ProgressDialogComponent { + this.progressDialog.update({value: 0, max: copies.length}); + this.progressDialog.open(); + return this.progressDialog; + } + + addItemToBucket(copies: IdlObject[]) { + if (copies.length === 0) { return; } this.bucketDialog.bucketClass = 'copy'; - this.bucketDialog.itemIds = [this.item.id()]; + this.bucketDialog.itemIds = copies.map(c => c.id()); + this.bucketDialog.open({size: 'lg'}); + } + + addRecordToBucket(copies: IdlObject[]) { + if (copies.length === 0) { return; } + const recId = copies[0].call_number().record().id(); + this.bucketDialog.bucketClass = 'biblio'; + this.bucketDialog.itemIds = [recId]; this.bucketDialog.open({size: 'lg'}); } + + makeItemsBookable(copies: IdlObject[]) { + if (copies.length === 0) { return; } + this.makeBookableDialog.copyIds = copies.map(c => c.id()); + this.makeBookableDialog.open({}); + } + + bookItems(copies: IdlObject[]) { + if (copies.length === 0) { return; } + const barcode = copies[0].barcode(); + this.router.navigate( + ['/staff/booking/create_reservation/for_resource', barcode]); + } + + manageReservations(copies: IdlObject[]) { + if (copies.length === 0) { return; } + const barcode = copies[0].barcode(); + this.router.navigate( + ['/staff/booking/manage_reservations/by_resource', barcode]); + } + + requestItems(copies: IdlObject[]) { + if (copies.length === 0) { return; } + const params = {target: copies.map(c => c.id()), holdFor: 'staff'}; + this.router.navigate(['/staff/catalog/hold/C'], {queryParams: params}); + } + + openConjoinedDialog(copies: IdlObject[]) { + if (copies.length === 0) { return; } + this.conjoinedDialog.copyIds = copies.map(c => c.id()); + this.conjoinedDialog.open({size: 'sm'}); + } + + deleteItems(copies: IdlObject[]) { + if (copies.length === 0) { return; } + const callNumHash: any = {}; + + // Collect the copies to be deleted, including their call numbers + // since the API expects fleshed call number objects. + copies.forEach(copy => { + const callNum = copy.call_number(); + if (!callNumHash[callNum.id()]) { + callNumHash[callNum.id()] = this.idl.clone(callNum); + callNumHash[callNum.id()].copies([]); + } + const delCopy = this.idl.clone(copy); + delCopy.isdeleted(true); + callNumHash[callNum.id()].copies().push(delCopy); + }); + + if (Object.keys(callNumHash).length === 0) { + // No data to process. + return; + } + + this.deleteHolding.callNums = Object.values(callNumHash); + this.deleteHolding.open({size: 'sm'}).subscribe(modified => this.load()); + } + + checkinItems(copies: IdlObject[]) { + if (copies.length === 0) { return; } + + const dialog = this.openProgressDialog(copies); + + let changesApplied = false; + + this.circ.checkinBatch(copies.map(c => c.id())) + .subscribe( + result => { + if (result) { changesApplied = true; } + dialog.increment(); + }, + err => { + console.error('' + err); + dialog.close(); + }, + () => { + dialog.close(); + this.load(); + } + ); + } + + renewItems(copies: IdlObject[]) { + if (copies.length === 0) { return; } + + const dialog = this.openProgressDialog(copies); + + let changesApplied = false; + + this.circ.renewBatch(copies.map(c => c.id())) + .subscribe( + result => { + if (result) { changesApplied = true; } + dialog.increment(); + }, + err => { + console.error('' + err); + dialog.close(); + }, + () => { + dialog.close(); + this.load(); + } + ); + } + + cancelTransits(copies: IdlObject[]) { + if (copies.length === 0) { return; } + + // Copies in transit are not always accompanied by their transit. + const transitIds = []; + from(copies).pipe(concatMap(c => { + return from( + this.circ.findCopyTransitById(c.id()) + .then( + transit => transitIds.push(transit.id()), + err => {} + ) + ); + })) + + .pipe(concatMap(_ => { + + if (transitIds.length > 0) { + this.cancelTransitDialog.transitIds = transitIds; + return this.cancelTransitDialog.open(); + } else { + return empty(); + } + + })).subscribe(); + } } + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html b/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html index 86d90e5a25..674ea0e93d 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.html @@ -1,10 +1,6 @@ -
- This item has been marked as Deleted. -
-
-- 2.11.0