From 15fc4e5f2d14d623a1419adbf800d7d723f661cd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 27 Jul 2018 21:59:49 -0400 Subject: [PATCH] filter ciphers before doing select all, resolves #227 --- src/app/vault/ciphers.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts index 50afe5e496..04470455b4 100644 --- a/src/app/vault/ciphers.component.ts +++ b/src/app/vault/ciphers.component.ts @@ -18,6 +18,8 @@ import { CipherType } from 'jslib/enums/cipherType'; import { CipherView } from 'jslib/models/view/cipherView'; +import { SearchCiphersPipe } from 'jslib/angular/pipes/search-ciphers.pipe'; + const MaxCheckedCount = 500; @Component({ @@ -32,10 +34,13 @@ export class CiphersComponent extends BaseCiphersComponent { cipherType = CipherType; + private searchPipe: SearchCiphersPipe; + constructor(cipherService: CipherService, protected analytics: Angulartics2, protected toasterService: ToasterService, protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService) { super(cipherService); + this.searchPipe = new SearchCiphersPipe(platformUtilsService); } checkCipher(c: CipherView, select?: boolean) { @@ -46,9 +51,14 @@ export class CiphersComponent extends BaseCiphersComponent { if (select) { this.selectAll(false); } - const selectCount = select && this.ciphers.length > MaxCheckedCount ? MaxCheckedCount : this.ciphers.length; + let filteredCiphers = this.ciphers; + if (select) { + filteredCiphers = this.searchPipe.transform(this.ciphers, this.searchText); + } + const selectCount = select && filteredCiphers.length > MaxCheckedCount ? + MaxCheckedCount : filteredCiphers.length; for (let i = 0; i < selectCount; i++) { - this.checkCipher(this.ciphers[i], select); + this.checkCipher(filteredCiphers[i], select); } }