[Sot Delete] update to view and i18n for delete
This commit is contained in:
parent
3a10c1ff30
commit
6ea0ce5287
|
@ -328,8 +328,8 @@ export class AddEditComponent implements OnInit {
|
||||||
|
|
||||||
async delete(): Promise<boolean> {
|
async delete(): Promise<boolean> {
|
||||||
const confirmed = await this.platformUtilsService.showDialog(
|
const confirmed = await this.platformUtilsService.showDialog(
|
||||||
this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'),
|
this.i18nService.t(this.cipher.isDeleted ? 'permanentlyDeleteItemConfirmation' : 'deleteItemConfirmation'),
|
||||||
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
this.i18nService.t('deleteItem'), this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,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';
|
||||||
import { BroadcasterService } from '../services/broadcaster.service';
|
import { BroadcasterService } from '../services/broadcaster.service';
|
||||||
|
import { Cipher } from '../../models/domain';
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = 'ViewComponent';
|
const BroadcasterSubscriptionId = 'ViewComponent';
|
||||||
|
|
||||||
|
@ -34,7 +35,8 @@ export class ViewComponent implements OnDestroy, OnInit {
|
||||||
@Input() cipherId: string;
|
@Input() cipherId: string;
|
||||||
@Output() onEditCipher = new EventEmitter<CipherView>();
|
@Output() onEditCipher = new EventEmitter<CipherView>();
|
||||||
@Output() onCloneCipher = new EventEmitter<CipherView>();
|
@Output() onCloneCipher = new EventEmitter<CipherView>();
|
||||||
@Output() onRestoreCipher = new EventEmitter<CipherView>();
|
@Output() onRestoredCipher = new EventEmitter<CipherView>();
|
||||||
|
@Output() onDeletedCipher = new EventEmitter<CipherView>();
|
||||||
|
|
||||||
cipher: CipherView;
|
cipher: CipherView;
|
||||||
showPassword: boolean;
|
showPassword: boolean;
|
||||||
|
@ -111,11 +113,45 @@ export class ViewComponent implements OnDestroy, OnInit {
|
||||||
this.onCloneCipher.emit(this.cipher);
|
this.onCloneCipher.emit(this.cipher);
|
||||||
}
|
}
|
||||||
|
|
||||||
restore() {
|
async delete(): Promise<boolean> {
|
||||||
if (!this.cipher.isDeleted) {
|
const confirmed = await this.platformUtilsService.showDialog(
|
||||||
return;
|
this.i18nService.t(this.cipher.isDeleted ? 'permanentlyDeleteItemConfirmation' : 'deleteItemConfirmation'),
|
||||||
|
this.i18nService.t('deleteItem'), this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
||||||
|
if (!confirmed) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
this.onRestoreCipher.emit(this.cipher);
|
|
||||||
|
try {
|
||||||
|
await this.deleteCipher();
|
||||||
|
this.platformUtilsService.eventTrack((this.cipher.isDeleted ? 'Permanently ' : '') + 'Deleted Cipher');
|
||||||
|
this.platformUtilsService.showToast('success', null,
|
||||||
|
this.i18nService.t(this.cipher.isDeleted ? 'permanentlyDeletedItem' : 'deletedItem'));
|
||||||
|
this.onDeletedCipher.emit(this.cipher);
|
||||||
|
} catch { }
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async restore(): Promise<boolean> {
|
||||||
|
if (!this.cipher.isDeleted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmed = await this.platformUtilsService.showDialog(
|
||||||
|
this.i18nService.t('restoreItemConfirmation'), this.i18nService.t('restoreItem'),
|
||||||
|
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
|
||||||
|
if (!confirmed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.restoreCipher();
|
||||||
|
this.platformUtilsService.eventTrack('Restored Cipher');
|
||||||
|
this.platformUtilsService.showToast('success', null, this.i18nService.t('restoredItem'));
|
||||||
|
this.onRestoredCipher.emit(this.cipher);
|
||||||
|
} catch { }
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePassword() {
|
togglePassword() {
|
||||||
|
@ -225,6 +261,15 @@ export class ViewComponent implements OnDestroy, OnInit {
|
||||||
a.downloading = false;
|
a.downloading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected deleteCipher() {
|
||||||
|
return this.cipher.isDeleted ? this.cipherService.deleteWithServer(this.cipher.id)
|
||||||
|
: this.cipherService.softDeleteWithServer(this.cipher.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected restoreCipher() {
|
||||||
|
return this.cipherService.restoreWithServer(this.cipher.id);
|
||||||
|
}
|
||||||
|
|
||||||
private cleanUp() {
|
private cleanUp() {
|
||||||
this.totpCode = null;
|
this.totpCode = null;
|
||||||
this.cipher = null;
|
this.cipher = null;
|
||||||
|
|
|
@ -310,6 +310,9 @@ export class CipherService implements CipherServiceAbstraction {
|
||||||
const ciphers = await this.getAllDecrypted();
|
const ciphers = await this.getAllDecrypted();
|
||||||
|
|
||||||
return ciphers.filter((cipher) => {
|
return ciphers.filter((cipher) => {
|
||||||
|
if (cipher.isDeleted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (folder && cipher.folderId === groupingId) {
|
if (folder && cipher.folderId === groupingId) {
|
||||||
return true;
|
return true;
|
||||||
} else if (!folder && cipher.collectionIds != null && cipher.collectionIds.indexOf(groupingId) > -1) {
|
} else if (!folder && cipher.collectionIds != null && cipher.collectionIds.indexOf(groupingId) > -1) {
|
||||||
|
@ -352,6 +355,9 @@ export class CipherService implements CipherServiceAbstraction {
|
||||||
}
|
}
|
||||||
|
|
||||||
return ciphers.filter((cipher) => {
|
return ciphers.filter((cipher) => {
|
||||||
|
if (cipher.deletedDate != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (includeOtherTypes != null && includeOtherTypes.indexOf(cipher.type) > -1) {
|
if (includeOtherTypes != null && includeOtherTypes.indexOf(cipher.type) > -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue