[SI-2944] - correct filtering for stations
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 b0489df..1098295 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 @@
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 e6db916..1c0f9bb 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 @@
}
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 {