import { EventEmitter } from '@angular/core'; import { FlatTreeControl } from '@angular/cdk/tree'; import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; import { SelectionModel } from '@angular/cdk/collections'; import { BehaviorSubject, Observable } from 'rxjs'; import { User } from '../../models/user'; import { GroupService } from '../../../core/services/group/group.service'; import { Group } from '../../models/group'; /** * Node for group item */ export declare class GroupNode { children: GroupNode[]; item: string; id: number; users: User[]; } /** Flat node with expandable and level information */ export declare class GroupFlatNode { item: string; level: number; expandable: boolean; id: number; users: User[]; } /** * Checklist database, it can build a tree structured Json object. * Each node in Json object represents a group. */ export declare class ChecklistDatabase { groupService: GroupService; dataChange: BehaviorSubject; isLoadingResults: boolean; readonly data: GroupNode[]; groups: Group[]; constructor(groupService: GroupService); initialize(): void; /** * Build the file structure tree. * The return value is the list of `GroupNode`. */ buildFileTree(groups: Group[], level: number): any[]; } export declare class GroupTreeComponent { private database; groupSelection: EventEmitter; /** Map from flat node to nested node. This helps us finding the nested node to be modified */ flatNodeMap: Map; /** Map from nested node to flattened node. This helps us to keep the same object for selection */ nestedNodeMap: Map; treeControl: FlatTreeControl; treeFlattener: MatTreeFlattener; dataSource: MatTreeFlatDataSource; isLoadingResults: boolean; /** The selection for checklist */ checklistSelection: SelectionModel; constructor(database: ChecklistDatabase); getLevel: (node: GroupFlatNode) => number; isExpandable: (node: GroupFlatNode) => boolean; getChildren: (node: GroupNode) => Observable; hasChild: (_: number, _nodeData: GroupFlatNode) => boolean; hasNoContent: (_: number, _nodeData: GroupFlatNode) => boolean; /** * Transformer to convert nested node to flat node. Record the nodes in maps for later use. */ transformer: (node: GroupNode, level: number) => GroupFlatNode; /** Whether all the descendants of the node are selected */ descendantsAllSelected(node: GroupFlatNode): boolean; /** Whether part of the descendants are selected */ descendantsPartiallySelected(node: GroupFlatNode): boolean; /** Toggle the node selection. Select/deselect all the descendants node */ checkSelectionToggle(node: GroupFlatNode): void; /** Toggle the node selection. Select/deselect all the descendants node */ checkParentSelectionToggle(node: GroupFlatNode): void; afterSelection(): void; }