All files / src/components/zd-tree-grid iterable-tree.ts

100% Statements 14/14
100% Branches 9/9
100% Functions 5/5
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40    93x           46x       42x 37x         39x 1x 1x     38x 25x 25x     13x       1x       5x      
import { IIterableTree, ITreeGrid } from './interfaces';
 
export class IterableTree implements IIterableTree {
	private treeGrid: ITreeGrid;
 
	viewUpdateScrollData?: () => void;
 
	constructor(treeGrid: ITreeGrid) {
		this.treeGrid = treeGrid;
	}
 
	onMounted(): void {
		if (!this.treeGrid.lazyLoad || this.treeGrid.getData().length) {
			this.buildTree();
		}
	}
 
	buildTree(doGet = true): void {
		if (!doGet) {
			this.treeGrid.buildTreeStructure();
			return;
		}
 
		if (!this.treeGrid.fetchOnDemand) {
			this.treeGrid.reload();
			return;
		}
 
		this.treeGrid.filterRootData();
	}
 
	setViewUpdateScrollData(fn: () => void) {
		this.viewUpdateScrollData = fn;
	}
 
	updateScrollData(): void {
		if (this.treeGrid.virtualScroll && this.viewUpdateScrollData) this.viewUpdateScrollData();
	}
}