addEditCipherInfo w/ collections from state

This commit is contained in:
Kyle Spearrin 2019-06-24 21:12:34 -04:00
parent bc5a6e02c1
commit 24ffb55ce0
1 changed files with 17 additions and 10 deletions

View File

@ -162,8 +162,13 @@ export class AddEditComponent implements OnInit {
this.title = this.i18nService.t('addItem'); this.title = this.i18nService.t('addItem');
} }
this.cipher = await this.stateService.get<CipherView>('addEditCipher'); const addEditCipherInfo: any = await this.stateService.get<any>('addEditCipherInfo');
await this.stateService.remove('addEditCipher'); if (addEditCipherInfo != null) {
this.cipher = addEditCipherInfo.cipher;
this.collectionIds = addEditCipherInfo.collectionIds;
}
await this.stateService.remove('addEditCipherInfo');
if (this.cipher == null) { if (this.cipher == null) {
if (this.editMode) { if (this.editMode) {
const cipher = await this.loadCipher(); const cipher = await this.loadCipher();
@ -179,15 +184,17 @@ export class AddEditComponent implements OnInit {
this.cipher.identity = new IdentityView(); this.cipher.identity = new IdentityView();
this.cipher.secureNote = new SecureNoteView(); this.cipher.secureNote = new SecureNoteView();
this.cipher.secureNote.type = SecureNoteType.Generic; this.cipher.secureNote.type = SecureNoteType.Generic;
}
}
await this.organizationChanged(); if (this.cipher != null && (!this.editMode || addEditCipherInfo != null)) {
if (this.collectionIds != null && this.collectionIds.length > 0 && this.collections.length > 0) { await this.organizationChanged();
this.collections.forEach((c) => { if (this.collectionIds != null && this.collectionIds.length > 0 && this.collections.length > 0) {
if (this.collectionIds.indexOf(c.id) > -1) { this.collections.forEach((c) => {
(c as any).checked = true; if (this.collectionIds.indexOf(c.id) > -1) {
} (c as any).checked = true;
}); }
} });
} }
} }