LP1889133 Staff catalog Hold Status display/sort repair user/berick/lp1889133-staffcat-hold-status-display
authorBill Erickson <berickxx@gmail.com>
Tue, 28 Jul 2020 16:28:35 +0000 (12:28 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 28 Jul 2020 16:28:37 +0000 (12:28 -0400)
The human-friendly hold status is now displayed in the general purpose
Angular holds grid.  The reduce confusion the column name has been
changed from "Status" to "Hold Status".  Additionally, the grid can now
sort the Hold Status column without causing server errors and subsequent
failure to render.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.html
Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts

index 7e44d6a..d1f2850 100644 (file)
@@ -9,6 +9,17 @@
 <eg-hold-cancel-dialog #cancelDialog></eg-hold-cancel-dialog>
 <eg-hold-manage-dialog #manageDialog></eg-hold-manage-dialog>
 
+<eg-string key="hold-status--1" i18n-text text="Unknown Error"></eg-string>
+<eg-string key="hold-status-1"  i18n-text text="Waiting for Item"></eg-string>
+<eg-string key="hold-status-2"  i18n-text text="Waiting for Capture"></eg-string>
+<eg-string key="hold-status-3"  i18n-text text="In Transit"></eg-string>
+<eg-string key="hold-status-4"  i18n-text text="Ready for Pickup"></eg-string>
+<eg-string key="hold-status-5"  i18n-text text="Hold Shelf Delay"></eg-string>
+<eg-string key="hold-status-6"  i18n-text text="Canceled"></eg-string>
+<eg-string key="hold-status-7"  i18n-text text="Suspended"></eg-string>
+<eg-string key="hold-status-8"  i18n-text text="Wrong Shelf"></eg-string>
+<eg-string key="hold-status-9"  i18n-text text="Fulfilled"></eg-string>
+
 <div class='eg-holds w-100 mt-3'>
 
   <ng-container *ngIf="mode == 'detail'">
           [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Potential Items" path='potentials' datatype="int">
       </eg-grid-column>
-      <eg-grid-column i18n-label label="Status" path='status_string'>
+
+      <eg-grid-column i18n-label label="Hold Status" path='status_string'>
       </eg-grid-column>
+
       <eg-grid-column i18n-label label="Queue Position"
           path='relative_queue_position' [hidden]="true" datatype="int"></eg-grid-column>
       <eg-grid-column path='usr_id' i18n-label label="User ID" [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Shelf Expire Time" path='shelf_expire_time' datatype="timestamp" [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Current Shelf Library" path='current_shelf_lib' [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Behind Desk" path='behind_desk' datatype="bool" [hidden]="true"></eg-grid-column>
-      <eg-grid-column i18n-label label="Status" path='hold_status' [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Clearable" path='clear_me' datatype="bool" [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Is Staff-placed Hold" path='is_staff_hold' datatype="bool" [hidden]="true"></eg-grid-column>
       <eg-grid-column i18n-label label="Cancelation Cause ID" path='cc_id' [hidden]="true"></eg-grid-column>
index ff25149..920a3af 100644 (file)
@@ -1,4 +1,4 @@
-import {Component, OnInit, Input, ViewChild} from '@angular/core';
+import {Component, OnInit, Input, ViewChild, QueryList, ViewChildren} from '@angular/core';
 import {Observable, Observer, of} from 'rxjs';
 import {IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
@@ -19,6 +19,7 @@ import {HoldTransferDialogComponent} from './transfer-dialog.component';
 import {HoldCancelDialogComponent} from './cancel-dialog.component';
 import {HoldManageDialogComponent} from './manage-dialog.component';
 import {PrintService} from '@eg/share/print/print.service';
+import {StringComponent} from '@eg/share/string/string.component';
 
 /** Holds grid with access to detail page and other actions */
 
@@ -74,6 +75,8 @@ export class HoldsGridComponent implements OnInit {
     @ViewChild('manageDialog', { static: true })
         private manageDialog: HoldManageDialogComponent;
 
+    @ViewChildren(StringComponent) strings: QueryList<StringComponent>;
+
     // Bib record ID.
     _recordId: number;
     @Input() set recordId(id: number) {
@@ -210,12 +213,22 @@ export class HoldsGridComponent implements OnInit {
         }
 
         const filters = this.applyFilters();
-
         const orderBy: any = [];
+
         if (sort.length > 0) {
             sort.forEach(obj => {
                 const subObj: any = {};
-                subObj[obj.name] = {dir: obj.dir, nulls: 'last'};
+                let fieldName = obj.name;
+
+                if (fieldName === 'status_string') {
+                    // status_string is a locally derived value which
+                    // cannot be server-sorted.  Instead, sort by the
+                    // status number for consistent sort behavior and to
+                    // avoid API explosions
+                    fieldName = 'hold_status';
+                }
+
+                subObj[fieldName] = {dir: obj.dir, nulls: 'last'};
                 orderBy.push(subObj);
             });
         }
@@ -246,6 +259,14 @@ export class HoldsGridComponent implements OnInit {
                     this.progressDialog.update(
                         {value: ++loadCount, max: this.holdsCount});
 
+                    // Map the status strings listed in our template
+                    // to the status number on the hold.
+                    this.strings.forEach(s => {
+                        if (s.key === 'hold-status-' + holdData.hold_status) {
+                            holdData.status_string = s.text;
+                        }
+                    });
+
                     observer.next(holdData);
                 }
             },