mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
call into load method
This commit is contained in:
parent
45ba629371
commit
db83cab552
@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
|
||||||
Output,
|
Output,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ import { LoginUriView } from '../../models/view/loginUriView';
|
|||||||
import { LoginView } from '../../models/view/loginView';
|
import { LoginView } from '../../models/view/loginView';
|
||||||
import { SecureNoteView } from '../../models/view/secureNoteView';
|
import { SecureNoteView } from '../../models/view/secureNoteView';
|
||||||
|
|
||||||
export class AddEditComponent implements OnChanges {
|
export class AddEditComponent {
|
||||||
@Input() folderId: string;
|
@Input() folderId: string;
|
||||||
@Input() cipherId: string;
|
@Input() cipherId: string;
|
||||||
@Input() type: CipherType;
|
@Input() type: CipherType;
|
||||||
@ -116,7 +115,7 @@ export class AddEditComponent implements OnChanges {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnChanges() {
|
async load() {
|
||||||
this.editMode = this.cipherId != null;
|
this.editMode = this.cipherId != null;
|
||||||
|
|
||||||
if (this.editMode) {
|
if (this.editMode) {
|
||||||
@ -140,11 +139,11 @@ export class AddEditComponent implements OnChanges {
|
|||||||
this.folders = await this.folderService.getAllDecrypted();
|
this.folders = await this.folderService.getAllDecrypted();
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit(): Promise<boolean> {
|
||||||
if (this.cipher.name == null || this.cipher.name === '') {
|
if (this.cipher.name == null || this.cipher.name === '') {
|
||||||
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
||||||
this.i18nService.t('nameRequired'));
|
this.i18nService.t('nameRequired'));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cipher = await this.cipherService.encrypt(this.cipher);
|
const cipher = await this.cipherService.encrypt(this.cipher);
|
||||||
@ -157,7 +156,10 @@ export class AddEditComponent implements OnChanges {
|
|||||||
this.toasterService.popAsync('success', null,
|
this.toasterService.popAsync('success', null,
|
||||||
this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem'));
|
this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem'));
|
||||||
this.onSavedCipher.emit(this.cipher);
|
this.onSavedCipher.emit(this.cipher);
|
||||||
|
return true;
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
addUri() {
|
addUri() {
|
||||||
|
@ -25,7 +25,7 @@ import { CipherView } from '../../models/view/cipherView';
|
|||||||
import { FieldView } from '../../models/view/fieldView';
|
import { FieldView } from '../../models/view/fieldView';
|
||||||
import { LoginUriView } from '../../models/view/loginUriView';
|
import { LoginUriView } from '../../models/view/loginUriView';
|
||||||
|
|
||||||
export class ViewComponent implements OnChanges, OnDestroy {
|
export class ViewComponent implements OnDestroy {
|
||||||
@Input() cipherId: string;
|
@Input() cipherId: string;
|
||||||
@Output() onEditCipher = new EventEmitter<CipherView>();
|
@Output() onEditCipher = new EventEmitter<CipherView>();
|
||||||
|
|
||||||
@ -48,7 +48,11 @@ export class ViewComponent implements OnChanges, OnDestroy {
|
|||||||
protected i18nService: I18nService, protected analytics: Angulartics2,
|
protected i18nService: I18nService, protected analytics: Angulartics2,
|
||||||
protected auditService: AuditService) { }
|
protected auditService: AuditService) { }
|
||||||
|
|
||||||
async ngOnChanges() {
|
ngOnDestroy() {
|
||||||
|
this.cleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
async load() {
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
|
||||||
const cipher = await this.cipherService.get(this.cipherId);
|
const cipher = await this.cipherService.get(this.cipherId);
|
||||||
@ -67,10 +71,6 @@ export class ViewComponent implements OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.cleanUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
edit() {
|
edit() {
|
||||||
this.onEditCipher.emit(this.cipher);
|
this.onEditCipher.emit(this.cipher);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user