From a65b08f72de1bb073d5c088a6b0b5bc02fcbeee8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 23 Feb 2021 16:24:24 -0500 Subject: [PATCH] LP1904036 Mark damaged; canceled holds display repair Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/items.component.html | 9 ++-- .../src/app/staff/circ/patron/items.component.ts | 14 +++-- .../src/app/staff/share/circ/grid.component.html | 6 +++ .../eg2/src/app/staff/share/circ/grid.component.ts | 61 ++++++++++++++++++++-- .../holdings/mark-damaged-dialog.component.html | 2 +- .../holdings/mark-damaged-dialog.component.ts | 10 +++- .../src/app/staff/share/holds/grid.component.ts | 7 ++- 7 files changed, 95 insertions(+), 14 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.html index 125c7340eb..c0b0f5e792 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.html @@ -15,7 +15,8 @@ - + + @@ -26,7 +27,8 @@ - + + @@ -39,7 +41,8 @@ - + + diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.ts index e342b1a93d..692d727ead 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.ts @@ -37,9 +37,9 @@ export class ItemsComponent implements OnInit, AfterViewInit { mainList: number[] = []; altList: number[] = []; - displayLost: number; // 1 | 2 | 5 | 6; - displayLongOverdue: number; - displayClaimsReturned: number; + displayLost: number = null; // 1 | 2 | 5 | 6; + displayLongOverdue: number = null; + displayClaimsReturned: number = null; fetchCheckedIn = true; displayAltList = true; @@ -91,7 +91,13 @@ export class ItemsComponent implements OnInit, AfterViewInit { promise.then(_ => this.loading = false); } - applyDisplaySettings() { + applyDisplaySettings(): Promise { + + if (this.displayLost !== null) { + // Logic already executed + return Promise.resolve(); + } + return this.serverStore.getItemBatch([ 'ui.circ.items_out.lost', 'ui.circ.items_out.longoverdue', diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html index 1a7ab9873a..2b8d81d187 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html @@ -3,6 +3,8 @@ + + @@ -38,6 +40,10 @@ (onClick)="editDueDate($event)"> + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts index da0f97b0be..56bebe16a7 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {Component, OnInit, Output, Input, ViewChild, EventEmitter} from '@angular/core'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {Observable, empty, of, from} from 'rxjs'; import {map, tap, switchMap} from 'rxjs/operators'; @@ -21,6 +21,8 @@ import {ArrayUtil} from '@eg/share/util/array'; import {PrintService} from '@eg/share/print/print.service'; import {StringComponent} from '@eg/share/string/string.component'; import {DueDateDialogComponent} from './due-date-dialog.component'; +import {MarkDamagedDialogComponent + } from '@eg/staff/share/holdings/mark-damaged-dialog.component'; export interface CircGridEntry { index: string; // class + id -- row index @@ -67,6 +69,12 @@ export class CircGridComponent implements OnInit { @Input() persistKey: string; @Input() printTemplate: string; // defaults to items_out + // Emitted when a grid action modified data in a way that could + // affect which cirulcations should appear in the grid. Caller + // should then refresh their data and call the load() or + // appendGridEntry() function. + @Output() reloadRequested: EventEmitter = new EventEmitter(); + entries: CircGridEntry[] = null; gridDataSource: GridDataSource = new GridDataSource(); cellTextGenerator: GridCellTextGenerator; @@ -80,6 +88,8 @@ export class CircGridComponent implements OnInit { @ViewChild('copyAlertsDialog') private copyAlertsDialog: CopyAlertsDialogComponent; @ViewChild('dueDateDialog') private dueDateDialog: DueDateDialogComponent; + @ViewChild('markDamagedDialog') + private markDamagedDialog: MarkDamagedDialogComponent; constructor( private org: OrgService, @@ -102,7 +112,7 @@ export class CircGridComponent implements OnInit { this.cellTextGenerator = { title: row => row.title, - barcode: row => row.copy ? row.copy.barcode() : '' + 'copy.barcode': row => row.copy ? row.copy.barcode() : '' }; this.rowFlair = (row: CircGridEntry) => { @@ -222,8 +232,18 @@ export class CircGridComponent implements OnInit { ); } - getCopies(rows: any): IdlObject[] { - return rows.filter(r => r.copy).map(r => r.copy); + // Which copies in the grid are selected. + getCopyIds(rows: CircGridEntry[], skipStatus?: number): number[] { + return this.getCopies(rows, skipStatus).map(c => Number(c.id())); + } + + getCopies(rows: CircGridEntry[], skipStatus?: number): IdlObject[] { + let copies = rows.filter(r => r.copy).map(r => r.copy); + if (skipStatus) { + copies = copies.filter( + c => Number(c.status().id()) !== Number(skipStatus)); + } + return copies; } getCircs(rows: any): IdlObject[] { @@ -273,5 +293,38 @@ export class CircGridComponent implements OnInit { } return row.overdue; } + + showMarkDamagedDialog(rows: CircGridEntry[]) { + const copyIds = this.getCopyIds(rows, 14 /* ignore damaged */); + + if (copyIds.length === 0) { return; } + + let rowsModified = false; + + const markNext = (ids: number[]): Promise => { + if (ids.length === 0) { + return Promise.resolve(); + } + + this.markDamagedDialog.copyId = ids.pop(); + + return this.markDamagedDialog.open({size: 'lg'}) + .toPromise().then(ok => { + if (ok) { rowsModified = true; } + return markNext(ids); + }); + }; + + markNext(copyIds).then(_ => { + if (rowsModified) { + this.emitReloadRequest(); + } + }); + } + + emitReloadRequest() { + this.entries = null; + this.reloadRequested.emit(); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-damaged-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-damaged-dialog.component.html index 0c53c9c5af..07e5c523bf 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-damaged-dialog.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/holdings/mark-damaged-dialog.component.html @@ -92,7 +92,7 @@ + (click)="markDamaged({})" i18n>Mark Damaged