-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize expantion panel by manuall open and make the filter function…
… private #3212
- Loading branch information
Showing
2 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
25 changes: 15 additions & 10 deletions
25
.../customConfigItemGroup/customConfigDescription/filterCustomConfigDataBySearchTerm.pipe.ts
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 |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import { Pipe, PipeTransform } from "@angular/core" | ||
import { CustomConfigItem } from "../../../customConfigs.component" | ||
|
||
@Pipe({ name: "filterCustomConfigDataBySearchTerm" }) | ||
@Pipe({ | ||
name: "filterCustomConfigDataBySearchTerm" | ||
}) | ||
export class FilterCustomConfigDataBySearchTermPipe implements PipeTransform { | ||
transform(customConfigItems: CustomConfigItem[], searchTerm: string) { | ||
transform(customConfigItems: CustomConfigItem[], searchTerm: string): CustomConfigItem[] { | ||
const lowerCasedSearchTerm = searchTerm.toLocaleLowerCase().trimEnd() | ||
return customConfigItems.filter(customConfigItem => { | ||
const isSearchTermIncludedInName = customConfigItem.name.toLocaleLowerCase().includes(lowerCasedSearchTerm) | ||
const isSearchTermInlcudedInMode = customConfigItem.mapSelectionMode.toLocaleLowerCase().includes(lowerCasedSearchTerm) | ||
const isSearchTermIncludedInMetrics = Object.values(customConfigItem.metrics).some(metric => | ||
metric?.toLocaleLowerCase().includes(lowerCasedSearchTerm) | ||
) | ||
return isSearchTermIncludedInName || isSearchTermInlcudedInMode || isSearchTermIncludedInMetrics | ||
}) | ||
return customConfigItems.filter(item => this.isItemMatchingSearchTerm(item, lowerCasedSearchTerm)) | ||
} | ||
|
||
private isItemMatchingSearchTerm(customConfigItem: CustomConfigItem, searchTerm: string): boolean { | ||
const isSearchTermIncludedInName = customConfigItem.name.toLocaleLowerCase().includes(searchTerm) | ||
const isSearchTermIncludedInMode = customConfigItem.mapSelectionMode.toLocaleLowerCase().includes(searchTerm) | ||
const isSearchTermIncludedInMetrics = Object.values(customConfigItem.metrics).some(metric => | ||
metric?.toLocaleLowerCase().includes(searchTerm) | ||
) | ||
|
||
return isSearchTermIncludedInName || isSearchTermIncludedInMode || isSearchTermIncludedInMetrics | ||
} | ||
} |
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