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;
|
selectedOrganizationId?: string;
|
||||||
myVaultOnly = false;
|
myVaultOnly = false;
|
||||||
refreshCollectionsAndFolders = false;
|
refreshCollectionsAndFolders = false;
|
||||||
|
useAdminCollections = false;
|
||||||
|
|
||||||
constructor(init?: Partial<VaultFilter>) {
|
constructor(init?: Partial<VaultFilter>) {
|
||||||
Object.assign(this, init);
|
Object.assign(this, init);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export class VaultFilterComponent implements OnInit {
|
|||||||
this.folders = await this.vaultFilterService.buildFolders(filter.selectedOrganizationId);
|
this.folders = await this.vaultFilterService.buildFolders(filter.selectedOrganizationId);
|
||||||
this.collections = filter.myVaultOnly
|
this.collections = filter.myVaultOnly
|
||||||
? null
|
? null
|
||||||
: await this.vaultFilterService.buildCollections(filter.selectedOrganizationId);
|
: await this.vaultFilterService.buildCollections(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
async reloadOrganizations() {
|
async reloadOrganizations() {
|
||||||
|
|||||||
@@ -16,11 +16,10 @@ import { CollectionView } from "jslib-common/models/view/collectionView";
|
|||||||
import { FolderView } from "jslib-common/models/view/folderView";
|
import { FolderView } from "jslib-common/models/view/folderView";
|
||||||
|
|
||||||
import { DynamicTreeNode } from "./models/dynamic-tree-node.model";
|
import { DynamicTreeNode } from "./models/dynamic-tree-node.model";
|
||||||
|
import { VaultFilter } from "./models/vault-filter.model";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class VaultFilterService {
|
export class VaultFilterService {
|
||||||
getAllCollectionsFromServer = false;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected stateService: StateService,
|
protected stateService: StateService,
|
||||||
protected organizationService: OrganizationService,
|
protected organizationService: OrganizationService,
|
||||||
@@ -64,10 +63,10 @@ export class VaultFilterService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async buildCollections(organizationId?: string): Promise<DynamicTreeNode<CollectionView>> {
|
async buildCollections(vaultFilter: VaultFilter): Promise<DynamicTreeNode<CollectionView>> {
|
||||||
const collections = this.getAllCollectionsFromServer
|
const collections = vaultFilter.useAdminCollections
|
||||||
? await this.getAdminCollections(organizationId)
|
? await this.getAdminCollections(vaultFilter.selectedOrganizationId)
|
||||||
: await this.getUserCollections(organizationId);
|
: await this.getUserCollections(vaultFilter.selectedOrganizationId);
|
||||||
|
|
||||||
const nestedCollections = await this.collectionService.getAllNested(collections);
|
const nestedCollections = await this.collectionService.getAllNested(collections);
|
||||||
return new DynamicTreeNode<CollectionView>({
|
return new DynamicTreeNode<CollectionView>({
|
||||||
|
|||||||
Reference in New Issue
Block a user