Closed prashantpimpale93 closed 5 years ago
Since we now support filtering in nested objects, we need to be able to "exclude" the nested properties.
I think we can do this by passing a filtering the 'exclusionList' to the checkInside
function and check there with ===
.
@aVolpe Have added one more condition to the If block:
excludes.includes(property)
So if it returns true then it will ignore the current iteration.
Suggest If I missed anything!
EDIT: excludes
is an array so have used includes
@prashantpimpale93 your test aren't passing in the latest version.
Failures:
1) Pipe: Default Ignore the property in the search
Message:
Expected $.length = 2 to equal 1.
Expected $[1] = Object({ a: Object({ b: 'e', c: Object({ b: 'd' }) }) }) to equal undefined.
Stack:
Error: Expected $.length = 2 to equal 1.
Expected $[1] = Object({ a: Object({ b: 'e', c: Object({ b: 'd' }) }) }) to equal undefined.
at UserContext.<anonymous> (/Users/arturovolpe/develop/avolpe/ng2-search-filter/src/ng2-filter.pipe.spec.ts:38:50)
5 specs, 1 failure
Finished in 0.021 seconds
Changing to this in the pipe seems to fix it:
if (checkInside(item[property], term)) {
return true;
}
- }
- if (item[property].toString().toLowerCase().includes(toCompare)) {
+ } else if (item[property].toString().toLowerCase().includes(toCompare)) {
return true;
}
@aVolpe okay will test it and commit again!
@aVolpe Updated the code and committed!
Have a look!
@aVolpe Did you review the code changes?
I think the changes are a first aproach to the issue, maybe in a future we can add more complex filters like:
"user.name", // to only filter the name of the user
"user.ci*"
@aVolpe Thanks a lot!
Added support to exclude the properties while searching - #Fix-40