1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

combine edit into add/edit component

This commit is contained in:
Kyle Spearrin
2018-01-26 14:56:54 -05:00
parent 298b12bf0d
commit eee5f6ff32
11 changed files with 94 additions and 110 deletions

View File

@@ -34,10 +34,12 @@ export class VaultComponent implements OnInit {
this.route.queryParams.subscribe((params) => {
if (params['cipherId']) {
const cipherView = new CipherView();
cipherView.id = params['cipherId'];
if (params['action'] === 'edit') {
this.editCipher(params['cipherId']);
this.editCipher(cipherView);
} else {
this.viewCipher(params['cipherId']);
this.viewCipher(cipherView);
}
} else if (params['action'] === 'add') {
this.addCipher();
@@ -45,24 +47,24 @@ export class VaultComponent implements OnInit {
});
}
viewCipher(id: string) {
if (this.action === 'view' && this.cipherId === id) {
viewCipher(cipher: CipherView) {
if (this.action === 'view' && this.cipherId === cipher.id) {
return;
}
this.cipherId = id;
this.cipherId = cipher.id;
this.action = 'view';
this.go({ action: this.action, cipherId: id });
this.go({ action: this.action, cipherId: this.cipherId });
}
editCipher(id: string) {
if (this.action === 'edit' && this.cipherId === id) {
editCipher(cipher: CipherView) {
if (this.action === 'edit' && this.cipherId === cipher.id) {
return;
}
this.cipherId = id;
this.cipherId = cipher.id;
this.action = 'edit';
this.go({ action: this.action, cipherId: id });
this.go({ action: this.action, cipherId: this.cipherId });
}
addCipher() {
@@ -71,7 +73,28 @@ export class VaultComponent implements OnInit {
}
this.action = 'add';
this.go({ action: this.action });
this.cipherId = null;
this.go({ action: this.action, cipherId: this.cipherId });
}
savedCipher(cipher: CipherView) {
this.cipherId = cipher.id;
this.action = 'view';
this.go({ action: this.action, cipherId: this.cipherId });
}
deletedCipher(cipher: CipherView) {
}
editCipherAttachments(cipher: CipherView) {
}
cancelledAddEdit(cipher: CipherView) {
this.cipherId = cipher.id;
this.action = this.cipherId != null ? 'view' : null;
this.go({ action: this.action, cipherId: this.cipherId });
}
private go(queryParams: any) {