From 770689d69c726a72d936762fadc926d4f4939563 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 2 Oct 2019 11:21:49 -0400 Subject: [PATCH] LP#1846042: turn on grid filtering for Angular admin pages 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 Signed-off-by: Jeff Davis Signed-off-by: Bill Erickson Signed-off-by: Michele Morgan --- .../share/admin-page/admin-page.component.html | 2 +- .../staff/share/admin-page/admin-page.component.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html index 215161f48d..dbc350d6b1 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html @@ -53,7 +53,7 @@ [stickyHeader]="true"> diff --git a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts index dfc85a23ef..2f85522a09 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts @@ -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 => { -- 2.11.0