LP1904036 Mark damaged; canceled holds display repair
authorBill Erickson <berickxx@gmail.com>
Tue, 23 Feb 2021 21:24:24 +0000 (16:24 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:24 +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/patron/items.component.html
Open-ILS/src/eg2/src/app/staff/circ/patron/items.component.ts
Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.html
Open-ILS/src/eg2/src/app/staff/share/circ/grid.component.ts
Open-ILS/src/eg2/src/app/staff/share/holdings/mark-damaged-dialog.component.html
Open-ILS/src/eg2/src/app/staff/share/holdings/mark-damaged-dialog.component.ts
Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts

index 125c734..c0b0f5e 100644 (file)
@@ -15,7 +15,8 @@
         <ng-container *ngIf="loading">
           <ng-container *ngTemplateOutlet="progress"></ng-container>
         </ng-container>
-        <eg-circ-grid #checkoutsGrid></eg-circ-grid>
+        <eg-circ-grid #checkoutsGrid (reloadRequested)="load()">
+        </eg-circ-grid>
       </ng-template>
     </li>
     <ng-container *ngIf="displayAltList">
@@ -26,7 +27,8 @@
             <ng-container *ngIf="loading">
               <ng-container *ngTemplateOutlet="progress"></ng-container>
             </ng-container>
-            <eg-circ-grid #otherGrid></eg-circ-grid>
+            <eg-circ-grid #otherGrid (reloadRequested)="load()">
+            </eg-circ-grid>
           </ng-container>
         </ng-template>
       </li>
@@ -39,7 +41,8 @@
             <ng-container *ngIf="loading">
               <ng-container *ngTemplateOutlet="progress"></ng-container>
             </ng-container>
-            <eg-circ-grid #nonCatGrid></eg-circ-grid>
+            <eg-circ-grid #nonCatGrid (reloadRequested)="load()">
+            </eg-circ-grid>
           </ng-container>
         </ng-container>
       </ng-template>
index e342b1a..692d727 100644 (file)
@@ -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<any> {
+
+        if (this.displayLost !== null) {
+            // Logic already executed
+            return Promise.resolve();
+        }
+
         return this.serverStore.getItemBatch([
             'ui.circ.items_out.lost',
             'ui.circ.items_out.longoverdue',
index 1a7ab98..2b8d81d 100644 (file)
@@ -3,6 +3,8 @@
 <eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
 <eg-string #overdueString i18n-text text="Overdue"></eg-string>
 <eg-due-date-dialog #dueDateDialog></eg-due-date-dialog>
+<eg-mark-damaged-dialog #markDamagedDialog [handleCheckin]="true">
+</eg-mark-damaged-dialog>
 
 <ng-template #titleTemplate let-r="row">
   <ng-container *ngIf="r.record">
     (onClick)="editDueDate($event)">
   </eg-grid-toolbar-action>
 
+  <eg-grid-toolbar-action
+    group="Mark" i18n-group i18n-label label="Mark Item Damaged"
+    (onClick)="showMarkDamagedDialog($event)"></eg-grid-toolbar-action>
+
   <eg-grid-column [index]="true" path="index" [hidden]="true"
     label="Row Index" i18n-label></eg-grid-column>
 
index da0f97b..56bebe1 100644 (file)
@@ -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<void> = new EventEmitter<void>();
+
     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<any> => {
+            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();
+    }
 }
 
index 0c53c9c..07e5c52 100644 (file)
@@ -92,7 +92,7 @@
       <button type="button" class="btn btn-warning" 
         (click)="close(false)" i18n>Cancel</button>
       <button type="button" class="btn btn-success" 
-        (click)="markDamaged()" i18n>Mark Damaged</button>
+        (click)="markDamaged({})" i18n>Mark Damaged</button>
     </ng-container>
     <ng-container *ngIf="chargeResponse">
       <button type="button" class="btn btn-warning" 
index 6ccea62..7bd0d17 100644 (file)
@@ -27,6 +27,10 @@ export class MarkDamagedDialogComponent
     extends DialogComponent {
 
     @Input() copyId: number;
+
+    // If the item is checked out, ask the API to check it in first.
+    @Input() handleCheckin = false;
+
     copy: IdlObject;
     bibSummary: BibRecordSummary;
     billingTypes: ComboboxEntry[];
@@ -121,12 +125,16 @@ export class MarkDamagedDialogComponent
     markDamaged(args: any) {
         this.chargeResponse = null;
 
-        if (args && args.apply_fines === 'apply') {
+        if (args.apply_fines === 'apply') {
             args.override_amount = this.newCharge;
             args.override_btype = this.newBtype;
             args.override_note = this.newNote;
         }
 
+        if (this.handleCheckin) {
+            args.handle_checkin = true;
+        }
+
         this.net.request(
             'open-ils.circ', 'open-ils.circ.mark_item_damaged',
             this.auth.token(), this.copyId, args
index 4920a5a..357074a 100644 (file)
@@ -339,7 +339,12 @@ export class HoldsGridComponent implements OnInit {
 
         const limit = this.enablePreFetch ? null : pager.limit;
         const offset = this.enablePreFetch ? 0 : pager.offset;
-        const options = this.showRecentlyCanceled ? {recently_canceled: true} : {};
+        const options: any = {};
+        if (this.showRecentlyCanceled) {
+            options.recently_canceled = true;
+        } else {
+            filters.cancel_time = null;
+        }
 
         let observer: Observer<any>;
         const observable = new Observable(obs => observer = obs);