Skip to content

Commit

Permalink
Ref dabeng#16 - Visible depth
Browse files Browse the repository at this point in the history
  • Loading branch information
ben12 committed Nov 1, 2021
1 parent b7a14e0 commit edb541c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(mousedown)="pan ? panStartHandler($event) : true" (mousemove)="pan && panning ? panHandler($event) : true"
(click)="onClickChart($event)">
<orgchart-node [datasource]="datasource" [nodeHeading]="nodeHeading" [nodeContent]="nodeContent"
[nodeTemplate]="nodeTemplate" [groupScale]="groupScale" [select]="select" (nodeClick)="onNodeClick($event)"></orgchart-node>
[nodeTemplate]="nodeTemplate" [groupScale]="groupScale" [select]="select" (nodeClick)="onNodeClick($event)"
[depth]="1" [visibleDepth]="visibleDepth"></orgchart-node>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ChartContainerComponent implements OnInit {
@Input() containerClass = '';
@Input() chartClass = '';
@Input() select = 'single';
@Input() visibleDepth = 0;

@Output() nodeClick = new EventEmitter<any>();
@Output() chartClick = new EventEmitter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<ng-container *ngFor="let temp of Arr(groupScale);let j=index;">
<orgchart-node *ngIf="i + j < datasource.children.length" [datasource]="datasource.children[i + j]"
[nodeHeading]="nodeHeading" [nodeContent]="nodeContent" [nodeTemplate]="nodeTemplate"
[groupScale]="groupScale" [select]="select" (nodeClick)="onNodeClick($event)">
[groupScale]="groupScale" [select]="select" (nodeClick)="onNodeClick($event)"
[depth]="depth + 1" [visibleDepth]="visibleDepth">
</orgchart-node>
</ng-container>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class ChartNodeComponent implements OnInit {
@Input() nodeTemplate: TemplateRef<any>;
@Input() groupScale: number;
@Input() select: string;
@Input() depth: number;
@Input() visibleDepth: number;

@Output() nodeClick = new EventEmitter<any>();

Expand All @@ -69,6 +71,13 @@ export class ChartNodeComponent implements OnInit {
}

ngOnInit() {
this.resetVisibility();
}

resetVisibility() {
if (this.visibleDepth && this.depth >= this.visibleDepth) {
this.isCollapsed = true;
}
}

toggleChildren() {
Expand Down

0 comments on commit edb541c

Please sign in to comment.