1
0
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:
Kyle Spearrin
2018-04-05 11:12:00 -04:00
parent a0ca51dda4
commit 22f0f97cda
3 changed files with 195 additions and 0 deletions

View 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;
});
}
}