1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-09-27 03:53:00 +02:00

Apply save changes prompt to groupings

This commit is contained in:
Vincent Salucci 2020-03-20 17:07:19 -05:00
parent 68bc1ebbff
commit 9e8873e5c7
2 changed files with 133 additions and 0 deletions

View File

@ -7,6 +7,11 @@ import { UserService } from 'jslib/abstractions/user.service';
import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/components/groupings.component';
import { CipherType } from 'jslib/enums/cipherType';
import { CollectionView } from 'jslib/models/view/collectionView';
import { FolderView } from 'jslib/models/view/folderView';
@Component({
selector: 'app-vault-groupings',
templateUrl: 'groupings.component.html',
@ -16,4 +21,24 @@ export class GroupingsComponent extends BaseGroupingsComponent {
storageService: StorageService, userService: UserService) {
super(collectionService, folderService, storageService, userService);
}
selectAll() {
this.onAllClicked.emit();
}
selectFavorites() {
this.onFavoritesClicked.emit();
}
selectType(type: CipherType) {
this.onCipherTypeClicked.emit(type);
}
selectFolder(folder: FolderView) {
this.onFolderClicked.emit(folder);
}
selectCollection(collection: CollectionView) {
this.onCollectionClicked.emit(collection);
}
}

View File

@ -484,6 +484,21 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async clearGroupingFilters() {
if (this.groupingsComponent.selectedAll) {
return;
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.groupingsComponent != null) {
this.groupingsComponent.clearSelections();
this.groupingsComponent.selectedAll = true;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchVault');
await this.ciphersComponent.reload();
this.clearFilters();
@ -491,6 +506,21 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async filterFavorites() {
if (this.groupingsComponent.selectedFavorites) {
return;
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.groupingsComponent != null) {
this.groupingsComponent.clearSelections();
this.groupingsComponent.selectedFavorites = true;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchFavorites');
await this.ciphersComponent.reload((c) => c.favorite);
this.clearFilters();
@ -499,6 +529,21 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async filterCipherType(type: CipherType) {
if (this.groupingsComponent.selectedType === type) {
return;
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.groupingsComponent != null) {
this.groupingsComponent.clearSelections();
this.groupingsComponent.selectedType = type;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchType');
await this.ciphersComponent.reload((c) => c.type === type);
this.clearFilters();
@ -507,6 +552,22 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async filterFolder(folderId: string) {
if (this.groupingsComponent.selectedFolderId === folderId) {
return;
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.groupingsComponent != null) {
this.groupingsComponent.clearSelections();
this.groupingsComponent.selectedFolder = true;
this.groupingsComponent.selectedFolderId = folderId;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
folderId = folderId === 'none' ? null : folderId;
this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchFolder');
await this.ciphersComponent.reload((c) => c.folderId === folderId);
@ -516,6 +577,21 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async filterCollection(collectionId: string) {
if (this.groupingsComponent.selectedCollectionId === collectionId) {
return;
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.groupingsComponent != null) {
this.groupingsComponent.clearSelections();
this.groupingsComponent.selectedCollectionId = collectionId;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchCollection');
await this.ciphersComponent.reload((c) => c.collectionIds != null &&
c.collectionIds.indexOf(collectionId) > -1);
@ -526,6 +602,14 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async openPasswordGenerator(showSelect: boolean) {
if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
if (this.modal != null) {
this.modal.close();
}
@ -549,6 +633,14 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async openExportVault() {
if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
if (this.modal != null) {
this.modal.close();
}
@ -567,6 +659,14 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async addFolder() {
if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
if (this.modal != null) {
this.modal.close();
}
@ -587,6 +687,14 @@ export class VaultComponent implements OnInit, OnDestroy {
}
async editFolder(folderId: string) {
if (this.dirtyInput() && await this.wantsToSaveChanges()) {
return;
}
if (this.action === 'add' || this.action === 'edit' || this.action === 'clone') {
this.cancelledAddEdit(this.addEditComponent.cipher);
}
if (this.modal != null) {
this.modal.close();
}