This repository has been archived by the owner on May 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filter): enable filter in hierarchy mode
- Loading branch information
Can Kattw
committed
Jan 3, 2018
1 parent
61a03b7
commit 8bf3929
Showing
7 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Checks whether an array exists and contains items | ||
export function arrayExistsAndContains (arr: any[] | null): boolean { | ||
return !!arr && arr.length > 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {InternalOption} from '../model/internal-option.model'; | ||
import {arrayExistsAndContains} from './array-exists-and-contains'; | ||
|
||
export const filterInternals = function (resourceList: InternalOption[], searchStr: string): InternalOption[] { | ||
return resourceList.map(it => { | ||
if (arrayExistsAndContains(it.children)) { | ||
it.children = filterInternals(it.children, searchStr); | ||
} | ||
it.isSearchResultOrParent = it.label.toString().toLowerCase().includes(searchStr) || ContainsResult(it.children); | ||
return it; | ||
}); | ||
}; | ||
|
||
function ContainsResult (resource: InternalOption[]): boolean { | ||
return resource.some(resource => resource.isSearchResultOrParent || ContainsResult(resource.children)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters