From de7223ea089b2c09601d1564cf1e87be613754b9 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 13 Nov 2019 18:13:46 -0500 Subject: [PATCH] WIP: start work on hooking up grid filters Notes: - changed provider.name to provider - need to do more fleshing of linked user fields on the line item grid - need to figure out how to completely suppress certain columns from grid display (e.g., LI MARC, although I could envision a later widget that pops up a human-readable view) - Wish typescript or Angular had a native deep copy of nested properties. Signed-off-by: Galen Charlton --- .../src/app/staff/acq/search/acq-search.service.ts | 25 +++++++++++++++++++++- .../acq/search/lineitem-results.component.html | 5 +++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts index 45ea4e3cb5..140b29cfa9 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/acq-search.service.ts @@ -61,6 +61,10 @@ const searchOptions = { } }; +const operatorMap = { + "=": "", +} + @Injectable() export class AcqSearchService { @@ -70,10 +74,29 @@ export class AcqSearchService { ) { } + generateAcqSearch(searchType, filters): any { + const baseSearch = JSON.parse(JSON.stringify(defaultSearch[searchType])); // deep copy + Object.keys(filters).forEach(filterField => { + const coreRecType = Object.keys(defaultSearch[searchType])[0]; + const filterOp = Object.keys(filters[filterField][0][filterField])[0]; + const filterVal = filters[filterField][0][filterField][filterOp]; + + const searchTerm: Object = {}; + searchTerm[filterField] = filterVal; + searchTerm[operatorMap[filterOp]] = true; + baseSearch[coreRecType].push(searchTerm); + }); + console.debug(baseSearch); + return baseSearch; + } + getAcqSearchDataSource(searchType: string): GridDataSource { const gridSource = new GridDataSource(); gridSource.getRows = (pager: Pager) => { + + const currentSearch = this.generateAcqSearch(searchType, gridSource.filters); + const opts = { ...searchOptions[searchType] }; opts['offset'] = pager.offset; opts['limit'] = pager.limit; @@ -81,7 +104,7 @@ export class AcqSearchService { 'open-ils.acq', 'open-ils.acq.' + searchType + '.unified_search', this.auth.token(), - defaultSearch[searchType], + currentSearch, null, null, opts diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html index 3a6c81d90d..07091e5b3d 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/lineitem-results.component.html @@ -50,13 +50,14 @@ persistKey="acq.search.lineitems" idlClass="jub" [dataSource]="gridSource" [stickyHeader]="true" + [filterable]="true" [showDeclaredFieldsOnly]="true"> - - + + -- 2.11.0