mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
move ciphers, groupings, and search pipe to jslib
This commit is contained in:
36
src/angular/pipes/search-ciphers.pipe.ts
Normal file
36
src/angular/pipes/search-ciphers.pipe.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
Pipe,
|
||||
PipeTransform,
|
||||
} from '@angular/core';
|
||||
|
||||
import { CipherView } from '../../models/view/cipherView';
|
||||
|
||||
@Pipe({
|
||||
name: 'searchCiphers',
|
||||
})
|
||||
export class SearchCiphersPipe implements PipeTransform {
|
||||
transform(ciphers: CipherView[], searchText: string): CipherView[] {
|
||||
if (ciphers == null || ciphers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (searchText == null || searchText.length < 2) {
|
||||
return ciphers;
|
||||
}
|
||||
|
||||
searchText = searchText.toLowerCase();
|
||||
return ciphers.filter((c) => {
|
||||
if (c.name != null && c.name.toLowerCase().indexOf(searchText) > -1) {
|
||||
return true;
|
||||
}
|
||||
if (c.subTitle != null && c.subTitle.toLowerCase().indexOf(searchText) > -1) {
|
||||
return true;
|
||||
}
|
||||
if (c.login && c.login.uri != null && c.login.uri.toLowerCase().indexOf(searchText) > -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user