diff --git a/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.spec.ts b/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.spec.ts index b0489dffbce08e4740a82af61d7abdd62a1a6bff..10982954f9d37deb484a4fa8a529063f65610834 100644 --- a/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.spec.ts +++ b/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.spec.ts @@ -243,7 +243,7 @@ describe('SetFilterComponent', () => { component['_valueGetter'] = () => 'oncle tom'; component.setItems = { oncle: { checked: true } }; const returnValue = component.doesFilterPass({} as any); - expect(returnValue).toBeFalsy(); + expect(returnValue).toBeTruthy(); }); it('should set params via agInit()', () => { diff --git a/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.ts b/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.ts index e6db91641752010b73ebad7b2edbe20e38eeb36a..1c0f9bba09938d9756e005f8b2d36f9dc58afbc1 100644 --- a/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.ts +++ b/projects/grid-failure-information-app/src/app/shared/filters/ag-grid/set-filter/set-filter.component.ts @@ -89,8 +89,28 @@ export class SetFilterComponent implements AgFilterComponent, OnDestroy { } doesFilterPass(params: IDoesFilterPassParams): boolean { - const itemKey = this._valueGetter(params.node); - return this.setItems[itemKey || null] !== undefined && this.setItems[itemKey || null].checked; + const nodeValue = this._valueGetter(params.node); + let passed: boolean = false; + + for (let itemKey in this.setItems) { + if (isNaN(nodeValue)) { + if (itemKey === 'null') { + passed = !nodeValue || nodeValue === ''; // nodeValue is falsy or empty string + } else { + passed = !!nodeValue && nodeValue.includes(itemKey); + } + } else { + // is numeric or null + if (!nodeValue) { + passed = nodeValue === null && itemKey === 'null'; + } else { + passed = nodeValue.toString() === itemKey; + } + } + passed = passed && this.setItems[itemKey].checked; + if (passed) return passed; + } + return passed; } getModel(): any {