[feat] Allow the org badge click event to expand collapsed vault filters (#2885)

* [feat] Allow the org badge click event to expand collapsed vault filters

* [fix] Restore a blank line
This commit is contained in:
Addison Beck 2022-06-09 18:51:46 -07:00 committed by GitHub
parent 8d87e32ea2
commit 96bd9784b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 1 deletions

View File

@ -20,6 +20,13 @@ export class VaultFilterComponent extends BaseVaultFilterComponent {
super(vaultFilterService); super(vaultFilterService);
} }
async ngOnInit() {
await super.ngOnInit();
this.vaultFilterService.collapsedFilterNodes$.subscribe((nodes) => {
this.collapsedFilterNodes = nodes;
});
}
searchTextChanged() { searchTextChanged() {
this.onSearchTextChanged.emit(this.searchText); this.onSearchTextChanged.emit(this.searchText);
} }

View File

@ -1,3 +1,5 @@
import { BehaviorSubject, Observable } from "rxjs";
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { DynamicTreeNode } from "jslib-angular/modules/vault-filter/models/dynamic-tree-node.model"; import { DynamicTreeNode } from "jslib-angular/modules/vault-filter/models/dynamic-tree-node.model";
@ -16,6 +18,9 @@ import { CollectionView } from "jslib-common/models/view/collectionView";
@Injectable() @Injectable()
export class VaultFilterService extends BaseVaultFilterService { export class VaultFilterService extends BaseVaultFilterService {
private _collapsedFilterNodes = new BehaviorSubject<Set<string>>(null);
collapsedFilterNodes$: Observable<Set<string>> = this._collapsedFilterNodes.asObservable();
constructor( constructor(
stateService: StateService, stateService: StateService,
organizationService: OrganizationService, organizationService: OrganizationService,
@ -35,6 +40,26 @@ export class VaultFilterService extends BaseVaultFilterService {
); );
} }
async buildCollapsedFilterNodes(): Promise<Set<string>> {
const nodes = await super.buildCollapsedFilterNodes();
this._collapsedFilterNodes.next(nodes);
return nodes;
}
async storeCollapsedFilterNodes(collapsedFilterNodes: Set<string>): Promise<void> {
await super.storeCollapsedFilterNodes(collapsedFilterNodes);
this._collapsedFilterNodes.next(collapsedFilterNodes);
}
async ensureVaultFiltersAreExpanded() {
const collapsedFilterNodes = await super.buildCollapsedFilterNodes();
if (!collapsedFilterNodes.has("vaults")) {
return;
}
collapsedFilterNodes.delete("vaults");
await this.storeCollapsedFilterNodes(collapsedFilterNodes);
}
async buildAdminCollections(organizationId: string) { async buildAdminCollections(organizationId: string) {
let result: CollectionView[] = []; let result: CollectionView[] = [];
const collectionResponse = await this.apiService.getCollections(organizationId); const collectionResponse = await this.apiService.getCollections(organizationId);

View File

@ -34,6 +34,7 @@ import { CollectionsComponent } from "../../../../vault/collections.component";
import { FolderAddEditComponent } from "../../../../vault/folder-add-edit.component"; import { FolderAddEditComponent } from "../../../../vault/folder-add-edit.component";
import { ShareComponent } from "../../../../vault/share.component"; import { ShareComponent } from "../../../../vault/share.component";
import { VaultFilterComponent } from "../../../vault-filter/vault-filter.component"; import { VaultFilterComponent } from "../../../vault-filter/vault-filter.component";
import { VaultFilterService } from "../../../vault-filter/vault-filter.service";
import { VaultService } from "../../vault.service"; import { VaultService } from "../../vault.service";
const BroadcasterSubscriptionId = "VaultComponent"; const BroadcasterSubscriptionId = "VaultComponent";
@ -87,7 +88,8 @@ export class IndividualVaultComponent implements OnInit, OnDestroy {
private organizationService: OrganizationService, private organizationService: OrganizationService,
private vaultService: VaultService, private vaultService: VaultService,
private cipherService: CipherService, private cipherService: CipherService,
private passwordRepromptService: PasswordRepromptService private passwordRepromptService: PasswordRepromptService,
private vaultFilterService: VaultFilterService
) {} ) {}
async ngOnInit() { async ngOnInit() {
@ -186,6 +188,7 @@ export class IndividualVaultComponent implements OnInit, OnDestroy {
this.activeFilter.myVaultOnly = true; this.activeFilter.myVaultOnly = true;
} else { } else {
this.activeFilter.selectedOrganizationId = orgId; this.activeFilter.selectedOrganizationId = orgId;
await this.vaultFilterService.ensureVaultFiltersAreExpanded();
} }
await this.applyVaultFilter(this.activeFilter); await this.applyVaultFilter(this.activeFilter);
} }