From ee43ef9ba1910d5deb0b48f6a2cb582efafee720 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Wed, 18 May 2022 10:36:33 -0400 Subject: [PATCH] [fix] Prefill add cipher form from filter data (#2700) --- apps/desktop/src/app/vault/vault.component.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/desktop/src/app/vault/vault.component.ts b/apps/desktop/src/app/vault/vault.component.ts index a3c606c29d..f3f8c520a7 100644 --- a/apps/desktop/src/app/vault/vault.component.ts +++ b/apps/desktop/src/app/vault/vault.component.ts @@ -397,7 +397,7 @@ export class VaultComponent implements OnInit, OnDestroy { this.addType = type; this.action = "add"; this.cipherId = null; - this.updateCollectionProperties(); + this.prefillNewCipherFromFilter(); this.go(); } @@ -747,19 +747,21 @@ export class VaultComponent implements OnInit, OnDestroy { }); } - private updateCollectionProperties() { - if (this.collectionId != null) { - const collection = this.vaultFilterComponent.collections?.fullList?.filter( - (c) => c.id === this.collectionId + private prefillNewCipherFromFilter() { + if (this.activeFilter.selectedCollectionId != null) { + const collection = this.vaultFilterComponent.collections.fullList.filter( + (c) => c.id === this.activeFilter.selectedCollectionId ); - if (collection != null && collection.length > 0) { + if (collection.length > 0) { this.addOrganizationId = collection[0].organizationId; - this.addCollectionIds = [this.collectionId]; - return; + this.addCollectionIds = [this.activeFilter.selectedCollectionId]; } + } else if (this.activeFilter.selectedOrganizationId) { + this.addOrganizationId = this.activeFilter.selectedOrganizationId; + } + if (this.activeFilter.selectedFolderId && this.activeFilter.selectedFolder) { + this.folderId = this.activeFilter.selectedFolderId; } - this.addOrganizationId = null; - this.addCollectionIds = null; } private async canNavigateAway(action: string, cipher?: CipherView) {