Skip to content

Commit c5176c1

Browse files
committed
fix the my team view! finaly! It looks awesome πŸ§™β€β™‚οΈπŸ˜
1 parent 8b25094 commit c5176c1

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

β€ŽPhonebook.Frontend/src/app/pages/dashboard/components/team/team.component.tsβ€Ž

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,17 @@ export class TeamComponent implements OnInit, OnDestroy {
2626
constructor(private organigramService: OrganigramService) { }
2727

2828
public ngOnInit() {
29-
if (this.currentUser != null) {
30-
this.organigramService.getOrganigramTree()
31-
.subscribe(organigram => {
32-
if (this.currentUser != null) {
33-
let orgUnitOfUser = this.organigramService.getNodeForUser(this.currentUser, organigram, 0)
34-
if (orgUnitOfUser != null) {
35-
this.teamPersons = [
36-
...orgUnitOfUser.supervisors,
37-
...orgUnitOfUser.assistents,
38-
...orgUnitOfUser.employees,
39-
...orgUnitOfUser.learners,
40-
];
41-
}
42-
}
43-
});
44-
}
29+
this.organigramService.getNodeForCurrentUser()
30+
.subscribe(orgUnitOfUser => {
31+
if (orgUnitOfUser != null) {
32+
this.teamPersons = [
33+
...orgUnitOfUser.supervisors,
34+
...orgUnitOfUser.assistents,
35+
...orgUnitOfUser.employees,
36+
...orgUnitOfUser.learners,
37+
];
38+
}
39+
});
4540
}
4641

4742
public ngOnDestroy(): void { }

β€ŽPhonebook.Frontend/src/app/services/api/organigram.service.tsβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class OrganigramService {
1212
private http: HttpClient,
1313
private personService: PersonService,
1414
private currentUserService: CurrentUserService
15-
) {}
15+
) { }
1616
public organigram: Observable<UnitTreeNode[]>;
1717
public orgUnits: Observable<OrgUnit[]>;
1818
public team: UnitTreeNode;
@@ -110,7 +110,10 @@ export class OrganigramService {
110110
if (user.Business.ShortOrgUnit.length > depth) {
111111
for (const node of nodeChilds) {
112112
if (node.id === user.Business.ShortOrgUnit[depth] && node.depth === depth) {
113-
return node;
113+
if (user.Business.ShortOrgUnit.length == depth + 1) {
114+
return node;
115+
}
116+
return this.getNodeForUser(user, node.children, depth + 1);
114117
}
115118
if (node.id !== user.Business.ShortOrgUnit[depth] && node.depth === depth) {
116119
continue;

0 commit comments

Comments
Β (0)