LP#1846042: turn on grid filtering for Angular admin pages
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 2 Oct 2019 15:21:49 +0000 (11:21 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 5 Jan 2021 18:43:37 +0000 (13:43 -0500)
This WIP patch enables grid filters for Angular administration
pages.

TODO:

1. Enable for pages that override or do not use the default
   AdminPageComponent
2. Reconcile with the gridFilter URL parameter that booking
   (e.g.) uses.
3. Reconcile the top-level org unit filter widget with
   grid column org unit filters.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>

Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index 215161f..dbc350d 100644 (file)
@@ -53,7 +53,7 @@
 </ng-template>
 
 <eg-grid #grid idlClass="{{idlClass}}" [dataSource]="dataSource" hideFields="{{hideGridFields}}"
-    [sortable]="true" persistKey="{{persistKey}}"
+    [sortable]="true" persistKey="{{persistKey}}" [filterable]="true">
     [stickyHeader]="true">
   <eg-grid-toolbar-button [disabled]="!canCreate" 
     label="New {{idlClassDef.label}}" i18n-label (onClick)="createNew()">
index dfc85a2..2f85522 100644 (file)
@@ -265,19 +265,32 @@ export class AdminPageComponent implements OnInit {
                 order_by: orderBy
             };
 
-            if (!this.contextOrg && !this.gridFilters) {
+            console.debug(this.dataSource);
+            console.debug(this.dataSource.filters);
+            if (!this.contextOrg && !this.gridFilters && !Object.keys(this.dataSource.filters).length) {
                 // No org filter -- fetch all rows
                 return this.pcrud.retrieveAll(
                     this.idlClass, searchOps, {fleshSelectors: true});
             }
 
-            const search: any = {};
+            const search: any = new Array();
+            const orgFilter: any = {};
 
-            if (this.orgField) {
-                search[this.orgField] =
+            if (this.orgField && (this.searchOrgs || this.contextOrg)) {
+                orgFilter[this.orgField] =
                     this.searchOrgs.orgIds || [this.contextOrg.id()];
+                search.push(orgFilter)
             }
 
+            Object.keys(this.dataSource.filters).forEach(key => {
+                Object.keys(this.dataSource.filters[key]).forEach(key2 => {
+                    search.push(this.dataSource.filters[key][key2]);
+                });
+            });
+
+            // FIXME - do we want to remove this, whose only present user
+            // is the booking grid, in favor of switching it to the built-in
+            // grid filtering?
             if (this.gridFilters) {
                 // Lay the URL grid filters over our search object.
                 Object.keys(this.gridFilters).forEach(key => {