Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 7x 7x 25x 57x 57x 57x 57x 99x 57x | import { Pipe, PipeTransform } from "@angular/core" import { CustomConfigItem } from "../../../customConfigs.component" @Pipe({ name: "filterCustomConfigDataBySearchTerm", standalone: true }) export class FilterCustomConfigDataBySearchTermPipe implements PipeTransform { transform(customConfigItems: CustomConfigItem[], searchTerm: string): CustomConfigItem[] { const lowerCasedSearchTerm = searchTerm.toLocaleLowerCase().trimEnd() 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 } } |