mirror of
https://github.com/bitwarden/jslib
synced 2025-12-23 19:53:55 +00:00
Refactor: use VaultFilter model instead of service class property
This commit is contained in:
@@ -11,6 +11,7 @@ export class VaultFilter {
|
||||
selectedOrganizationId?: string;
|
||||
myVaultOnly = false;
|
||||
refreshCollectionsAndFolders = false;
|
||||
useAdminCollections = false;
|
||||
|
||||
constructor(init?: Partial<VaultFilter>) {
|
||||
Object.assign(this, init);
|
||||
|
||||
@@ -72,7 +72,7 @@ export class VaultFilterComponent implements OnInit {
|
||||
this.folders = await this.vaultFilterService.buildFolders(filter.selectedOrganizationId);
|
||||
this.collections = filter.myVaultOnly
|
||||
? null
|
||||
: await this.vaultFilterService.buildCollections(filter.selectedOrganizationId);
|
||||
: await this.vaultFilterService.buildCollections(filter);
|
||||
}
|
||||
|
||||
async reloadOrganizations() {
|
||||
|
||||
@@ -16,11 +16,10 @@ import { CollectionView } from "jslib-common/models/view/collectionView";
|
||||
import { FolderView } from "jslib-common/models/view/folderView";
|
||||
|
||||
import { DynamicTreeNode } from "./models/dynamic-tree-node.model";
|
||||
import { VaultFilter } from "./models/vault-filter.model";
|
||||
|
||||
@Injectable()
|
||||
export class VaultFilterService {
|
||||
getAllCollectionsFromServer = false;
|
||||
|
||||
constructor(
|
||||
protected stateService: StateService,
|
||||
protected organizationService: OrganizationService,
|
||||
@@ -64,10 +63,10 @@ export class VaultFilterService {
|
||||
});
|
||||
}
|
||||
|
||||
async buildCollections(organizationId?: string): Promise<DynamicTreeNode<CollectionView>> {
|
||||
const collections = this.getAllCollectionsFromServer
|
||||
? await this.getAdminCollections(organizationId)
|
||||
: await this.getUserCollections(organizationId);
|
||||
async buildCollections(vaultFilter: VaultFilter): Promise<DynamicTreeNode<CollectionView>> {
|
||||
const collections = vaultFilter.useAdminCollections
|
||||
? await this.getAdminCollections(vaultFilter.selectedOrganizationId)
|
||||
: await this.getUserCollections(vaultFilter.selectedOrganizationId);
|
||||
|
||||
const nestedCollections = await this.collectionService.getAllNested(collections);
|
||||
return new DynamicTreeNode<CollectionView>({
|
||||
|
||||
Reference in New Issue
Block a user