mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
[Soft Delete] jslib updates for new API updates
New API methods and cipher Deleted Date property, plus search expansion to toggle on deleted flag.
This commit is contained in:
@@ -21,6 +21,7 @@ export class CiphersComponent {
|
||||
searchText: string;
|
||||
searchPlaceholder: string = null;
|
||||
filter: (cipher: CipherView) => boolean = null;
|
||||
deleted: boolean = false;
|
||||
|
||||
protected searchPending = false;
|
||||
protected didScroll = false;
|
||||
@@ -32,7 +33,8 @@ export class CiphersComponent {
|
||||
|
||||
constructor(protected searchService: SearchService) { }
|
||||
|
||||
async load(filter: (cipher: CipherView) => boolean = null) {
|
||||
async load(filter: (cipher: CipherView) => boolean = null, deleted: boolean = false) {
|
||||
this.deleted = deleted || false;
|
||||
await this.applyFilter(filter);
|
||||
this.loaded = true;
|
||||
}
|
||||
@@ -79,13 +81,13 @@ export class CiphersComponent {
|
||||
clearTimeout(this.searchTimeout);
|
||||
}
|
||||
if (timeout == null) {
|
||||
this.ciphers = await this.searchService.searchCiphers(this.searchText, this.filter);
|
||||
this.ciphers = await this.searchService.searchCiphers(this.searchText, this.filter, null, this.deleted);
|
||||
await this.resetPaging();
|
||||
return;
|
||||
}
|
||||
this.searchPending = true;
|
||||
this.searchTimeout = setTimeout(async () => {
|
||||
this.ciphers = await this.searchService.searchCiphers(this.searchText, this.filter);
|
||||
this.ciphers = await this.searchService.searchCiphers(this.searchText, this.filter, null, this.deleted);
|
||||
await this.resetPaging();
|
||||
this.searchPending = false;
|
||||
}, timeout);
|
||||
|
||||
@@ -22,9 +22,11 @@ export class GroupingsComponent {
|
||||
@Input() showFolders = true;
|
||||
@Input() showCollections = true;
|
||||
@Input() showFavorites = true;
|
||||
@Input() showTrash = true;
|
||||
|
||||
@Output() onAllClicked = new EventEmitter();
|
||||
@Output() onFavoritesClicked = new EventEmitter();
|
||||
@Output() onTrashClicked = new EventEmitter();
|
||||
@Output() onCipherTypeClicked = new EventEmitter<CipherType>();
|
||||
@Output() onFolderClicked = new EventEmitter<FolderView>();
|
||||
@Output() onAddFolder = new EventEmitter();
|
||||
@@ -39,6 +41,7 @@ export class GroupingsComponent {
|
||||
cipherType = CipherType;
|
||||
selectedAll: boolean = false;
|
||||
selectedFavorites: boolean = false;
|
||||
selectedTrash: boolean = false;
|
||||
selectedType: CipherType = null;
|
||||
selectedFolder: boolean = false;
|
||||
selectedFolderId: string = null;
|
||||
@@ -101,6 +104,12 @@ export class GroupingsComponent {
|
||||
this.onFavoritesClicked.emit();
|
||||
}
|
||||
|
||||
selectTrash() {
|
||||
this.clearSelections();
|
||||
this.selectedTrash = true;
|
||||
this.onTrashClicked.emit();
|
||||
}
|
||||
|
||||
selectType(type: CipherType) {
|
||||
this.clearSelections();
|
||||
this.selectedType = type;
|
||||
@@ -131,6 +140,7 @@ export class GroupingsComponent {
|
||||
clearSelections() {
|
||||
this.selectedAll = false;
|
||||
this.selectedFavorites = false;
|
||||
this.selectedTrash = false;
|
||||
this.selectedType = null;
|
||||
this.selectedFolder = false;
|
||||
this.selectedFolderId = null;
|
||||
|
||||
@@ -19,17 +19,22 @@ export class SearchCiphersPipe implements PipeTransform {
|
||||
this.onlySearchName = platformUtilsService.getDevice() === DeviceType.EdgeExtension;
|
||||
}
|
||||
|
||||
transform(ciphers: CipherView[], searchText: string): CipherView[] {
|
||||
transform(ciphers: CipherView[], searchText: string, deleted: boolean = false): CipherView[] {
|
||||
if (ciphers == null || ciphers.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (searchText == null || searchText.length < 2) {
|
||||
return ciphers;
|
||||
return ciphers.filter((c) => {
|
||||
return deleted !== c.isDeleted;
|
||||
});
|
||||
}
|
||||
|
||||
searchText = searchText.trim().toLowerCase();
|
||||
return ciphers.filter((c) => {
|
||||
if (deleted !== c.isDeleted) {
|
||||
return false;
|
||||
}
|
||||
if (c.name != null && c.name.toLowerCase().indexOf(searchText) > -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user