Enhanced the Collapse all or Expand All button by implementing both in the same button and also fix the translation for both

This commit is contained in:
Vikash Prem Sharma
2024-04-22 16:39:47 -06:00
committed by Jose Alberto Hernandez
parent d846a8068f
commit 8ac82cc6a6
5 changed files with 47 additions and 11 deletions
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { NestedTreeControl } from '@angular/cdk/tree';
@Injectable({
providedIn: 'root'
})
export class TreeControlService {
constructor() { }
toggleExpandCollapse(nestedTreeControl: NestedTreeControl<any>, isTreeExpanded: boolean) {
if (isTreeExpanded) {
nestedTreeControl.collapseAll();
} else {
nestedTreeControl.expandAll();
}
// Toggle the state
return !isTreeExpanded;
}
}