From 435cad12c7a05e999024f786b1e3bbc7536a6860 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 29 Oct 2018 22:43:02 -0400 Subject: [PATCH] set org and collections on add based on filters --- jslib | 2 +- src/app/vault/add-edit.component.ts | 5 +++++ src/app/vault/vault.component.html | 2 ++ src/app/vault/vault.component.ts | 20 ++++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) 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/app/vault/add-edit.component.ts b/src/app/vault/add-edit.component.ts index 5076a47b7e..4968e61c72 100644 --- a/src/app/vault/add-edit.component.ts +++ b/src/app/vault/add-edit.component.ts @@ -27,7 +27,12 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges userService, collectionService); } + async ngOnInit() { + // We use ngOnChanges instead. + } + async ngOnChanges() { + await super.init(); await super.load(); } } diff --git a/src/app/vault/vault.component.html b/src/app/vault/vault.component.html index ce441ae816..2520d4f5a0 100644 --- a/src/app/vault/vault.component.html +++ b/src/app/vault/vault.component.html @@ -24,6 +24,8 @@ c.collectionIds != null && c.collectionIds.indexOf(collectionId) > -1); this.clearFilters(); this.collectionId = collectionId; + this.updateCollectionProperties(); this.go(); } @@ -551,6 +555,9 @@ export class VaultComponent implements OnInit, OnDestroy { this.collectionId = null; this.favorites = false; this.type = null; + this.addCollectionIds = null; + this.addType = null; + this.addOrganizationId = null; } private go(queryParams: any = null) { @@ -587,4 +594,17 @@ export class VaultComponent implements OnInit, OnDestroy { this.changeDetectorRef.detectChanges(); }); } + + private updateCollectionProperties() { + if (this.collectionId != null) { + const collection = this.groupingsComponent.collections.filter((c) => c.id === this.collectionId); + if (collection.length > 0) { + this.addOrganizationId = collection[0].organizationId; + this.addCollectionIds = [this.collectionId]; + return; + } + } + this.addOrganizationId = null; + this.addCollectionIds = null; + } }