mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-05 09:10:53 +01:00
added collpase/expand functions to groupings
This commit is contained in:
parent
b4fad203b9
commit
786fa02b90
@ -13,6 +13,10 @@ import { TreeNode } from '../../models/domain/treeNode';
|
||||
|
||||
import { CollectionService } from '../../abstractions/collection.service';
|
||||
import { FolderService } from '../../abstractions/folder.service';
|
||||
import { StorageService } from '../../abstractions/storage.service';
|
||||
import { UserService } from '../../abstractions/user.service';
|
||||
|
||||
import { ConstantsService } from '../../services/constants.service';
|
||||
|
||||
export class GroupingsComponent {
|
||||
@Input() showFolders = true;
|
||||
@ -40,9 +44,22 @@ export class GroupingsComponent {
|
||||
selectedFolderId: string = null;
|
||||
selectedCollectionId: string = null;
|
||||
|
||||
constructor(protected collectionService: CollectionService, protected folderService: FolderService) { }
|
||||
private collapsedGroupings: Set<string>;
|
||||
private collapsedGroupingsKey: string;
|
||||
|
||||
constructor(protected collectionService: CollectionService, protected folderService: FolderService,
|
||||
protected storageService: StorageService, protected userService: UserService) { }
|
||||
|
||||
async load(setLoaded = true) {
|
||||
const userId = await this.userService.getUserId();
|
||||
this.collapsedGroupingsKey = ConstantsService.collapsedGroupingsKey + '_' + userId;
|
||||
const collapsedGroupings = await this.storageService.get<string[]>(this.collapsedGroupingsKey);
|
||||
if (collapsedGroupings == null) {
|
||||
this.collapsedGroupings = new Set<string>();
|
||||
} else {
|
||||
this.collapsedGroupings = new Set(collapsedGroupings);
|
||||
}
|
||||
|
||||
await this.loadFolders();
|
||||
await this.loadCollections();
|
||||
|
||||
@ -119,4 +136,21 @@ export class GroupingsComponent {
|
||||
this.selectedFolderId = null;
|
||||
this.selectedCollectionId = null;
|
||||
}
|
||||
|
||||
collapse(grouping: FolderView | CollectionView, idPrefix = '') {
|
||||
if (grouping.id == null) {
|
||||
return;
|
||||
}
|
||||
const id = idPrefix + grouping.id;
|
||||
if (this.isCollapsed(grouping, idPrefix)) {
|
||||
this.collapsedGroupings.delete(id);
|
||||
} else {
|
||||
this.collapsedGroupings.add(id);
|
||||
}
|
||||
this.storageService.save(this.collapsedGroupingsKey, this.collapsedGroupings);
|
||||
}
|
||||
|
||||
isCollapsed(grouping: FolderView | CollectionView, idPrefix = '') {
|
||||
return this.collapsedGroupings.has(idPrefix + grouping.id);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ export class ConstantsService {
|
||||
static readonly installedVersionKey: string = 'installedVersion';
|
||||
static readonly localeKey: string = 'locale';
|
||||
static readonly themeKey: string = 'theme';
|
||||
static readonly collapsedGroupingsKey: string = 'collapsedGroupings';
|
||||
|
||||
readonly environmentUrlsKey: string = ConstantsService.environmentUrlsKey;
|
||||
readonly disableGaKey: string = ConstantsService.disableGaKey;
|
||||
@ -27,4 +28,5 @@ export class ConstantsService {
|
||||
readonly installedVersionKey: string = ConstantsService.installedVersionKey;
|
||||
readonly localeKey: string = ConstantsService.localeKey;
|
||||
readonly themeKey: string = ConstantsService.themeKey;
|
||||
readonly collapsedGroupingsKey: string = ConstantsService.collapsedGroupingsKey;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user