From 4153be281fb2915b9006d5bc92ce4387be34dc1a Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Wed, 11 Mar 2020 14:37:32 -0400 Subject: [PATCH] Require classes for search; be very verbose for typescript Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton --- .../provider/acq-provider-search-form.component.ts | 16 +++++------ .../acq/provider/acq-provider-search.service.ts | 32 +++++++++++++--------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search-form.component.ts index afd33bfc57..26219c9573 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search-form.component.ts @@ -68,13 +68,13 @@ export class AcqProviderSearchFormComponent implements OnInit, AfterViewInit { const searchTerms: AcqProviderSearchTerm[] = []; if (this.providerName) { - searchTerms.push({ fields: ['name'], op: 'ilike', value: this.providerName }); + searchTerms.push({ classes: ['acqpro'], fields: ['name'], op: 'ilike', value: this.providerName }); } if (this.providerCode) { - searchTerms.push({ fields: ['code'], op: 'ilike', value: this.providerCode }); + searchTerms.push({ classes: ['acqpro'], fields: ['code'], op: 'ilike', value: this.providerCode }); } if (this.providerOwners) { - searchTerms.push({ fields: ['owner'], op: 'in', value: this.providerOwners.orgIds }); + searchTerms.push({ classes: ['acqpro'], fields: ['owner'], op: 'in', value: this.providerOwners.orgIds }); } if (this.contactName) { searchTerms.push({ classes: ['acqpc'], fields: ['name'], op: 'ilike', value: this.contactName }); @@ -87,19 +87,19 @@ export class AcqProviderSearchFormComponent implements OnInit, AfterViewInit { searchTerms.push({ classes: ['acqpc','acqpro','acqpro'], fields: ['phone','phone','fax_phone'], op: 'ilike', value: this.providerPhone }); } if (this.providerCurrencyType) { - searchTerms.push({ fields: ['currency_type'], op: 'ilike', value: this.providerCurrencyType }); + searchTerms.push({ classes: ['acqpro'], fields: ['currency_type'], op: 'ilike', value: this.providerCurrencyType }); } if (this.providerSAN) { - searchTerms.push({ fields: ['san'], op: 'ilike', value: this.providerSAN }); + searchTerms.push({ classes: ['acqpro'], fields: ['san'], op: 'ilike', value: this.providerSAN }); } if (this.providerEDIDefault) { - searchTerms.push({ fields: ['edi_default'], op: '=', value: this.providerEDIDefault }); + searchTerms.push({ classes: ['acqpro'], fields: ['edi_default'], op: '=', value: this.providerEDIDefault }); } if (this.providerURL) { - searchTerms.push({ fields: ['url'], op: 'ilike', value: this.providerURL }); + searchTerms.push({ classes: ['acqpro'], fields: ['url'], op: 'ilike', value: this.providerURL }); } if (this.providerIsActive) { - searchTerms.push({ fields: ['active'], op: '=', value: (this.providerIsActive ? 't' : 'f') }); + searchTerms.push({ classes: ['acqpro'], fields: ['active'], op: '=', value: (this.providerIsActive ? 't' : 'f') }); } // tossing setTimeout here to ensure that the diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search.service.ts index 501ce598f6..9caa859ebe 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/acq-provider-search.service.ts @@ -8,7 +8,7 @@ import {Pager} from '@eg/share/util/pager'; import {EventService} from '@eg/core/event.service'; export interface AcqProviderSearchTerm { - classes?: string[]; + classes: string[]; fields: string[]; op: string; value: any; @@ -48,7 +48,7 @@ export class AcqProviderSearchService { class_list = class_list.filter((x, i, a) => x && x !== 'acqpro' && a.indexOf(x) == i); // build a join clause for use in the "opts" part of a pcrud query - class_list.forEach(cls => { joinPart[cls].type = 'left' }) + class_list.forEach(cls => { joinPart[cls] = {type : 'left' } }) if (Object.keys(joinPart).length == 0) return null; return joinPart; @@ -67,7 +67,8 @@ export class AcqProviderSearchService { } // not const because we may want an array - let query_part = new Object(); + let query_obj = new Object(); + let query_arr = new Array(); let op = term.op; if (!op) { op = '=' }; // just in case @@ -88,37 +89,42 @@ export class AcqProviderSearchService { isOR = true; let tmp = new Object(); if (first_cls) { - tmp['+'+first_cls] = query_part; + tmp['+'+first_cls] = query_obj; } else { - tmp = query_part; + tmp = query_obj; } - query_part = new Array(); - query_part.push(tmp); + query_arr.push(tmp); } if (curr_cls) { if (isOR) { let tmp = new Object(); + tmp['+'+curr_cls] = new Object(); + tmp['+'+curr_cls][field] = new Object(); tmp['+'+curr_cls][field][op] = val; - query_part.push(tmp); + query_arr.push(tmp); } else { - query_part['+'+curr_cls][field][op] = val; + query_obj['+'+curr_cls] = new Object(); + query_obj['+'+curr_cls][field] = new Object(); + query_obj['+'+curr_cls][field][op] = val; } } else { if (isOR) { let tmp = new Object(); + tmp[field] = new Object(); tmp[field][op] = val; - query_part.push(tmp); + query_arr.push(tmp); } else { - query_part[field][op] = val; + query_obj[field] = new Object(); + query_obj[field][op] = val; } } }); - if (isOR) { query_part = {'-or':query_part} } - query.push(query_part); + if (isOR) { query_obj = {'-or':query_arr} } + query.push(query_obj); }); // handle grid filters -- 2.11.0