1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 00:03:56 +00:00

delete item

This commit is contained in:
Kyle Spearrin
2018-01-26 15:44:02 -05:00
parent eee5f6ff32
commit 450ada64cb
4 changed files with 62 additions and 14 deletions

View File

@@ -36,6 +36,7 @@ export class AddEditComponent implements OnChanges {
@Input() folderId: string;
@Input() cipherId: string;
@Output() onSavedCipher = new EventEmitter<CipherView>();
@Output() onDeletedCipher = new EventEmitter<CipherView>();
@Output() onCancelled = new EventEmitter<CipherView>();
@Output() onEditAttachments = new EventEmitter<CipherView>();
@@ -134,7 +135,7 @@ export class AddEditComponent implements OnChanges {
this.analytics.eventTrack.next({ action: this.editMode ? 'Edited Cipher' : 'Added Cipher' });
this.toasterService.popAsync('success', null, this.i18nService.t(this.editMode ? 'editedItem' : 'addedItem'));
this.onSavedCipher.emit(this.cipher);
};
}
addField() {
if (this.cipher.fields == null) {
@@ -144,7 +145,7 @@ export class AddEditComponent implements OnChanges {
const f = new FieldView();
f.type = this.addFieldType;
this.cipher.fields.push(f);
};
}
removeField(field: FieldView) {
const i = this.cipher.fields.indexOf(field);
@@ -155,9 +156,20 @@ export class AddEditComponent implements OnChanges {
cancel() {
this.onCancelled.emit(this.cipher);
};
}
attachments() {
this.onEditAttachments.emit(this.cipher);
};
}
async delete() {
if (!confirm(this.i18nService.t('deleteItemConfirmation'))) {
return;
}
await this.cipherService.deleteWithServer(this.cipher.id);
this.analytics.eventTrack.next({ action: 'Deleted Cipher' });
this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem'));
this.onDeletedCipher.emit(this.cipher);
}
}