LP1806087 Catalog holds display WIP
authorBill Erickson <berickxx@gmail.com>
Mon, 18 Feb 2019 15:40:12 +0000 (07:40 -0800)
committerBill Erickson <berickxx@gmail.com>
Mon, 18 Feb 2019 15:40:12 +0000 (07:40 -0800)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/holds.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts

index 29fd2d3..ee778cf 100644 (file)
@@ -1,9 +1,11 @@
 
+<eg-progress-dialog #progressDialog>
+</eg-progress-dialog>
+
 <div class='eg-holds w-100 mt-3'>
 
-  <eg-grid #holdsGrid [dataSource]="gridDataSource" 
-    [useLocalSort]="true"
-    persistKey="cat.catalog.wide_holds" 
+  <eg-grid #holdsGrid [dataSource]="gridDataSource" [sortable]="true"
+    [multiSortable]="true" persistKey="cat.catalog.wide_holds" 
     >
 
     <!--
     </eg-grid-column>
     <eg-grid-column i18n-label label="Queue Position" 
         path='relative_queue_position' [hidden]="true"></eg-grid-column>
-
-    <!--
-
-
     <eg-grid-column path='usr_id' i18n-label label="User ID" [hidden]="true"></eg-grid-column>
     <eg-grid-column path='usr_usrname' i18n-label label="Username" [hidden]="true"></eg-grid-column>
+
     <eg-grid-column path='usr_first_given_name' i18n-label label="First Name" [hidden]="true"></eg-grid-column>
     <eg-grid-column path='usr_family_name' i18n-label label="Last Name" [hidden]="true"></eg-grid-column>
     <eg-grid-column path='rusr_id' i18n-label label="Requestor ID" [hidden]="true"></eg-grid-column>
     <eg-grid-column i18n-label label="Notify Count" path='notification_count' [hidden]="true"></eg-grid-column>
     <eg-grid-column i18n-label label="Last Notify Time" path='last_notification_time' datatype="timestamp" [hidden]="true"></eg-grid-column>
 
--->
-
   </eg-grid>
 
 </div>
index 75517ce..769aec4 100644 (file)
@@ -9,6 +9,7 @@ import {StaffCatalogService} from '../catalog.service';
 import {Pager} from '@eg/share/util/pager';
 import {GridDataSource} from '@eg/share/grid/grid';
 import {GridComponent} from '@eg/share/grid/grid.component';
+import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
 
 @Component({
   selector: 'eg-catalog-holds',
@@ -21,8 +22,8 @@ export class HoldsComponent implements OnInit {
     gridDataSource: GridDataSource;
     pickupLib: IdlObject;
     holdsCount: number;
-    holdsContext: any;
-    @ViewChild('holdsGrid') copyGrid: GridComponent;
+    @ViewChild('holdsGrid') private copyGrid: GridComponent;
+    @ViewChild('progressDialog') private progressDialog: ProgressDialogComponent;
 
     @Input() set recordId(id: number) {
         this.recId = id;
@@ -47,18 +48,14 @@ export class HoldsComponent implements OnInit {
 
         this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
             // sorting not currently supported
-            return this.fetchHolds(pager);
+            return this.fetchHolds(pager, sort);
         };
-
-        this.holdsContext = {
-            
-        }
     }
 
-    fetchHolds(pager: Pager): Observable<any> {
+    fetchHolds(pager: Pager, sort: any[]): Observable<any> {
         if (!this.recId) { return of([]); }
 
-        const orgs = 
+        const orgs =
             this.org.descendants(this.staffCat.searchContext.searchOrg, true);
 
         const restrictions = {
@@ -69,27 +66,43 @@ export class HoldsComponent implements OnInit {
             pickup_lib: orgs
         };
 
+        const orderBy: any = [];
+        sort.forEach(obj => {
+            const subObj: any = {};
+            subObj[obj.name] = {dir: obj.dir, nulls: 'last'};
+            orderBy.push(subObj);
+        });
+
+        this.progressDialog.open();
+        this.progressDialog.update({value: 0, max: 1});
         let first = true;
+        let loadCount = 0;
         return this.net.request(
             'open-ils.circ',
             'open-ils.circ.hold.wide_hash.stream',
-            this.auth.token(),
-            restrictions
-            //restrictions, order_by, limit, offset
+            this.auth.token(), restrictions, orderBy, pager.limit, pager.offset
         ).pipe(
 
             filter(holdData => {
                 // First API response is the hold count.
                 if (first) {
-                    this.holdsCount = holdData;
-                    first = false;
-                    return false;
+                    this.holdsCount = Number(holdData);
+                    return first = false;
                 }
                 return true;
             }),
 
             map(holdData => {
-                console.log(holdData);
+
+                this.progressDialog.update(
+                    {value: ++loadCount, max: this.holdsCount});
+
+                if (loadCount === this.holdsCount) {
+                    this.progressDialog.close();
+                }
+
+                // Do we even need to modify anything?
+                // Probably not.
                 return holdData;
             })
         );
index 5b16f71..ed35231 100644 (file)
@@ -97,7 +97,12 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
                 selector = '#first-query-input';
         }
 
-        this.renderer.selectRootElement(selector).focus();
+        try {
+            // TODO: sometime the selector is not available in the DOM
+            // until even later (even with setTimeouts).  Need to fix this.
+            // Note the error is thrown selectRootElement().
+            this.renderer.selectRootElement(selector).focus();
+        } catch(E) {}
     }
 
     /**