mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
fix the filter pipe
This commit is contained in:
parent
9e311241b3
commit
bd02c78966
@ -1,17 +1,18 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { ToggleableItem } from 'src/app/components/common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component';
|
||||
import { MatchingModel } from '../data/matching-model';
|
||||
|
||||
@Pipe({
|
||||
name: 'filter'
|
||||
})
|
||||
export class FilterPipe implements PipeTransform {
|
||||
transform(toggleableItems: ToggleableItem[], searchText: string): any[] {
|
||||
if (!toggleableItems) return [];
|
||||
if (!searchText) return toggleableItems;
|
||||
transform(items: MatchingModel[], searchText: string): any[] {
|
||||
if (!items) return [];
|
||||
if (!searchText) return items;
|
||||
|
||||
return toggleableItems.filter(toggleableItem => {
|
||||
return Object.keys(toggleableItem.item).some(key => {
|
||||
return String(toggleableItem.item[key]).toLowerCase().includes(searchText.toLowerCase());
|
||||
return items.filter(item => {
|
||||
return Object.keys(item).some(key => {
|
||||
return String(item[key]).toLowerCase().includes(searchText.toLowerCase());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user