Skip to content

Commit 86e1ef4

Browse files
David Martínez RosDavid Martínez Ros
authored andcommitted
changes has done at home, make component recursive and begin to put the tree images
1 parent d86f87b commit 86e1ef4

File tree

12 files changed

+39
-20
lines changed

12 files changed

+39
-20
lines changed

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Component } from '@angular/core';
77
})
88
export class AppComponent {
99

10-
title = 'app works!';
10+
title = 'The Component Tree Project!';
1111

1212
constructor() {}
1313

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
<table border=1>
2-
<tr>
3-
<td>
4-
<h3>Id: {{ node.id }}</h3>
5-
</td>
6-
<td>
7-
<h3>name: {{ node.name }}</h3>
8-
</td>
9-
<td>
10-
<h3>IdParent: {{ node.idParent }}</h3>
11-
</td>
12-
<td>
13-
<h3>sheet: {{ node.sheet }}</h3>
14-
</td>
15-
</tr>
16-
</table>
1+
<div id="{{ node.id }}">
2+
<img *ngIf="!last" src="../assets/line_node_and_continue.png" (click)="clickExpandCollapse()"/>
3+
<img *ngIf="last" src="../assets/line_node_and_end.png" (click)="clickExpandCollapse()"/>
4+
<img *ngIf="!node.sheet && node.expand" src="../assets/collapse_icon.png" (click)="clickExpandCollapse()"/>
5+
<img *ngIf="!node.sheet && !node.expand" src="../assets/expand_icon.png" (click)="clickExpandCollapse()"/>
6+
<img *ngIf="node.sheet" src="../assets/line_sheet.png" (click)="clickExpandCollapse()"/>
7+
8+
<span><b>{{ node.name }}</b> el seu pare es: {{ node.idParent }}</span>
9+
</div>

src/app/node-tree/node-tree.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ export class NodeTreeComponent implements OnInit {
1111

1212
@Input() node: Node;
1313

14+
@Input() last: boolean;
15+
1416
constructor() { }
1517

1618
ngOnInit() {
1719
}
1820

21+
clickExpandCollapse() {
22+
this.node.expand = !this.node.expand;
23+
}
24+
1925
}

src/app/node.class.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ export class Node {
33
name: string;
44
idParent: number;
55
sheet: boolean;
6+
7+
childs: Node[];
8+
9+
expand: boolean = false;
610
}

src/app/tree/tree.component.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
<div *ngFor="let node of tree | async">
2-
<app-node-tree [node]="node"></app-node-tree>
1+
<div *ngFor="let node of tree | async; let i of index">
2+
<app-node-tree [node]="node" [last]="i == tree.length"></app-node-tree>
3+
<div *ngIf="!node.sheet">
4+
<div *ngIf="node.expand" style="padding-left:10px">
5+
<div *ngFor="let child of node.childs; let j of index">
6+
<app-node-tree [node]="child" [last]="j == node.childs.length"></app-node-tree>
7+
</div>
8+
</div>
9+
</div>
310
</div>

src/assets/collapse_icon.png

295 Bytes
Loading

src/assets/expand_icon.png

317 Bytes
Loading

src/assets/line_continue.png

122 Bytes
Loading
137 Bytes
Loading

src/assets/line_node_and_end.png

138 Bytes
Loading

0 commit comments

Comments
 (0)