From: Bill Erickson Date: Tue, 28 Jul 2020 16:28:35 +0000 (-0400) Subject: LP1889133 Staff catalog Hold Status display/sort repair X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flp1889133-staffcat-hold-status-display;p=working%2FEvergreen.git LP1889133 Staff catalog Hold Status display/sort repair 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 --- diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.html b/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.html index 7e44d6a9fa..d1f285021f 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.html @@ -9,6 +9,17 @@ + + + + + + + + + + +
@@ -124,8 +135,10 @@ [hidden]="true"> - + + + @@ -170,7 +183,6 @@ - diff --git a/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts b/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts index ff2514919e..920a3aff07 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.ts @@ -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; + // 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); } },