1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-24 11:55:50 +01:00

set org and collections on add based on filters

This commit is contained in:
Kyle Spearrin 2018-10-29 22:43:02 -04:00
parent fc18a361d9
commit 435cad12c7
4 changed files with 28 additions and 1 deletions

2
jslib

@ -1 +1 @@
Subproject commit aa0b274f8fd80db620abd4a85c3086f511e19c88
Subproject commit a98a8bda9bea5b7bb4459cea9413e0f03b2aa068

View File

@ -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();
}
}

View File

@ -24,6 +24,8 @@
<app-vault-add-edit id="details"
*ngIf="action === 'add' || action === 'edit'"
[folderId]="action === 'add' && folderId !== 'none' ? folderId : null"
[organizationId]="action === 'add' ? addOrganizationId : null"
[collectionIds]="action === 'add' ? addCollectionIds : null"
[type]="action === 'add' ? (addType ? addType : type) : null"
[cipherId]="action === 'edit' ? cipherId : null"
(onSavedCipher)="savedCipher($event)"

View File

@ -70,6 +70,8 @@ export class VaultComponent implements OnInit, OnDestroy {
folderId: string = null;
collectionId: string = null;
addType: CipherType = null;
addOrganizationId: string = null;
addCollectionIds: string[] = null;
private modal: ModalComponent = null;
@ -296,6 +298,7 @@ export class VaultComponent implements OnInit, OnDestroy {
this.addType = type;
this.action = 'add';
this.cipherId = null;
this.updateCollectionProperties();
this.go();
}
@ -455,6 +458,7 @@ export class VaultComponent implements OnInit, OnDestroy {
await this.ciphersComponent.load((c) => 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;
}
}