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:
committed by
Jose Alberto Hernandez
parent
d846a8068f
commit
8ac82cc6a6
@@ -75,11 +75,8 @@
|
||||
<div class="container" [hidden]="viewGroup.value !== 'treeView'">
|
||||
|
||||
<div class="m-b-20" fxLayout="row" fxLayoutAlign="start" fxLayoutGap="20px">
|
||||
<button mat-raised-button (click)="nestedTreeControl.expandAll()">
|
||||
{{'Expand All'|translate}}
|
||||
</button>
|
||||
<button mat-raised-button (click)="nestedTreeControl.collapseAll()">
|
||||
{{'Collapse All'|translate}}
|
||||
<button mat-raised-button (click)="toggleExpandCollapse()">
|
||||
{{ (isTreeExpanded ? "labels.buttons.Collapse All" : "labels.buttons.Expand All") | translate }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import { OfficeNode } from './office-node.model';
|
||||
import { NestedTreeControl } from '@angular/cdk/tree';
|
||||
import { MatTreeNestedDataSource } from '@angular/material/tree';
|
||||
import { OfficeTreeService } from './office-tree-service.service';
|
||||
import { TreeControlService } from 'app/shared/common-logic/tree-control.service';
|
||||
|
||||
/**
|
||||
* Offices component.
|
||||
@@ -43,6 +44,8 @@ export class OfficesComponent implements OnInit, AfterViewInit {
|
||||
office: OfficeNode;
|
||||
/** Office data tables. */
|
||||
dataTablesData: any;
|
||||
/** Flag to check if tree is expanded or collapsed. */
|
||||
isTreeExpanded: boolean = true;
|
||||
|
||||
/** Paginator for offices table. */
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
@@ -70,6 +73,7 @@ export class OfficesComponent implements OnInit, AfterViewInit {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private officeTreeService: OfficeTreeService,
|
||||
private treeControlService: TreeControlService,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) {
|
||||
this.route.data.subscribe(( data: { offices: any, officeDataTables: any }) => {
|
||||
@@ -186,4 +190,11 @@ export class OfficesComponent implements OnInit, AfterViewInit {
|
||||
this.router.navigate(['/organization']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand and Collapse the tree
|
||||
*/
|
||||
toggleExpandCollapse() {
|
||||
this.isTreeExpanded = this.treeControlService.toggleExpandCollapse(this.nestedTreeControl, this.isTreeExpanded);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user