Skip to content

Commit 4c9f9e9

Browse files
authored
feat: expose treeViewService and add deselection capability to it (#2964)
1 parent f9dfd63 commit 4c9f9e9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/treeview/treeview.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class TreeViewComponent implements AfterViewInit, OnInit, OnDestroy {
109109

110110
constructor(
111111
@Inject(DOCUMENT) private document: Document,
112-
protected treeViewService: TreeViewService,
112+
public treeViewService: TreeViewService,
113113
private elementRef: ElementRef
114114
) {}
115115

src/treeview/treeview.service.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,25 @@ export class TreeViewService {
4444
this.value.set(node.id, node);
4545
this.selectionSubject.next(this.value);
4646
}
47+
48+
/**
49+
* Removes selected node from the map
50+
* @param node: Node
51+
*/
52+
deselectNode(node: Node) {
53+
if (!node) {
54+
return;
55+
}
56+
57+
this.value.delete(node.id);
58+
this.selectionSubject.next(this.value);
59+
}
60+
61+
/**
62+
* Removes all selected nodes from the map
63+
*/
64+
deselectAllNodes() {
65+
this.value.clear();
66+
this.selectionSubject.next(this.value);
67+
}
4768
}

0 commit comments

Comments
 (0)