From 6627d29c7c9719ffcb54aef3fcd03ce643c83709 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 30 Oct 2018 08:56:38 -0400 Subject: [PATCH] pre-select org an collection on add --- jslib | 2 +- src/popup/vault/add-edit.component.ts | 7 +++++++ src/popup/vault/ciphers.component.html | 4 ++-- src/popup/vault/ciphers.component.ts | 16 +++++++++++----- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/jslib b/jslib index aa0b274f8f..a98a8bda9b 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit aa0b274f8fd80db620abd4a85c3086f511e19c88 +Subproject commit a98a8bda9bea5b7bb4459cea9413e0f03b2aa068 diff --git a/src/popup/vault/add-edit.component.ts b/src/popup/vault/add-edit.component.ts index b4cda58eee..f32e1cde86 100644 --- a/src/popup/vault/add-edit.component.ts +++ b/src/popup/vault/add-edit.component.ts @@ -43,6 +43,13 @@ export class AddEditComponent extends BaseAddEditComponent { if (params.folderId) { this.folderId = params.folderId; } + if (params.collectionId) { + const collection = this.writeableCollections.filter((c) => c.id === params.collectionId); + if (collection != null && collection.length > 0) { + this.collectionIds = [collection[0].id]; + this.organizationId = collection[0].organizationId; + } + } if (params.type) { const type = parseInt(params.type, null); this.type = type; diff --git a/src/popup/vault/ciphers.component.html b/src/popup/vault/ciphers.component.html index 83066f5f07..af903b2e20 100644 --- a/src/popup/vault/ciphers.component.html +++ b/src/popup/vault/ciphers.component.html @@ -10,7 +10,7 @@ [(ngModel)]="searchText" (input)="search(200)" appAutofocus> -
+
@@ -57,7 +57,7 @@

{{'noItemsInList' | i18n}}

-
diff --git a/src/popup/vault/ciphers.component.ts b/src/popup/vault/ciphers.component.ts index eb9f0941e7..aa9768dd1c 100644 --- a/src/popup/vault/ciphers.component.ts +++ b/src/popup/vault/ciphers.component.ts @@ -45,8 +45,8 @@ const ComponentId = 'CiphersComponent'; export class CiphersComponent extends BaseCiphersComponent implements OnInit, OnDestroy { groupingTitle: string; state: any; - showAdd = true; folderId: string = null; + collectionId: string = null; type: CipherType = null; pagedCiphers: CipherView[] = []; nestedFolders: Array>; @@ -108,15 +108,15 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On } await super.load((c) => c.folderId === this.folderId); } else if (params.collectionId) { - this.showAdd = false; + this.collectionId = params.collectionId; this.searchPlaceholder = this.i18nService.t('searchCollection'); - const collectionNode = await this.collectionService.getNested(params.collectionId); + const collectionNode = await this.collectionService.getNested(this.collectionId); if (collectionNode != null && collectionNode.node != null) { this.groupingTitle = collectionNode.node.name; this.nestedCollections = collectionNode.children != null && collectionNode.children.length > 0 ? collectionNode.children : null; } - await super.load((c) => c.collectionIds != null && c.collectionIds.indexOf(params.collectionId) > -1); + await super.load((c) => c.collectionIds != null && c.collectionIds.indexOf(this.collectionId) > -1); } else { this.groupingTitle = this.i18nService.t('allItems'); await super.load(); @@ -195,7 +195,13 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On addCipher() { super.addCipher(); - this.router.navigate(['/add-cipher'], { queryParams: { folderId: this.folderId, type: this.type } }); + this.router.navigate(['/add-cipher'], { + queryParams: { + folderId: this.folderId, + type: this.type, + collectionId: this.collectionId, + }, + }); } back() {