Reset navigation link list when navigation back
All checks were successful
Java CI with Maven / build (push) Successful in 44s

This commit is contained in:
Sebastian Böckelmann 2023-11-13 19:20:28 +01:00
parent 2477f32d0b
commit 1e492a9111
3 changed files with 30 additions and 0 deletions

View File

@ -11,6 +11,11 @@ export interface NavigationLink {
styleUrls: ['./navigation-link-list.component.css'] styleUrls: ['./navigation-link-list.component.css']
}) })
export class NavigationLinkListComponent implements OnInit{ export class NavigationLinkListComponent implements OnInit{
resetComponent(defaultNavigationLinkPath: NavigationLink[]) {
this.navigationLinks = defaultNavigationLinkPath;
console.log("Navigation Links: ")
console.log(this.navigationLinks)
}
@ -27,7 +32,10 @@ export class NavigationLinkListComponent implements OnInit{
} }
if(this.navigationLinks.find(searchedLink => searchedLink.linkText === linkText) === undefined) { if(this.navigationLinks.find(searchedLink => searchedLink.linkText === linkText) === undefined) {
console.log("Test")
this.navigationLinks.push(navigationLink); this.navigationLinks.push(navigationLink);
} else {
console.log(linkText)
} }
} }

View File

@ -40,12 +40,24 @@ export class TaskgroupDashboardComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if(params.has('taskgroupID')) { if(params.has('taskgroupID')) {
console.log("Update of taskgroup")
this.taskgroupID = Number(params.get('taskgroupID')); this.taskgroupID = Number(params.get('taskgroupID'));
this.taskgroupService.taskgroupsTaskgroupIDGet(this.taskgroupID).subscribe({ this.taskgroupService.taskgroupsTaskgroupIDGet(this.taskgroupID).subscribe({
next: resp => { next: resp => {
this.taskgroups = resp.children this.taskgroups = resp.children
this.taskgroupPath = resp.ancestors this.taskgroupPath = resp.ancestors
this.taskgroup = resp.taskgroupInfo; this.taskgroup = resp.taskgroupInfo;
this.navLinkListComponent!.resetComponent([
{
linkText: "Dashboard",
routerLink: ['/']
},
{
linkText: "Taskgroups",
routerLink: ["/taskgroups"]
}
]);
console.log(this.taskgroups)
this.taskgroupPath.forEach(taskgroupEntity => { this.taskgroupPath.forEach(taskgroupEntity => {
this.navLinkListComponent!.addNavigationLink(taskgroupEntity.taskgroupName, ['/taskgroups', taskgroupEntity.taskgroupID.toString()]); this.navLinkListComponent!.addNavigationLink(taskgroupEntity.taskgroupName, ['/taskgroups', taskgroupEntity.taskgroupID.toString()]);
}) })

View File

@ -49,6 +49,16 @@ export class TaskDetailOverviewComponent implements OnInit {
this.taskgroups = resp.children this.taskgroups = resp.children
this.taskgroupPath = resp.ancestors this.taskgroupPath = resp.ancestors
this.taskgroup = resp.taskgroupInfo; this.taskgroup = resp.taskgroupInfo;
this.navLinkListComponent!.resetComponent([
{
linkText: "Dashboard",
routerLink: ['/']
},
{
linkText: "Taskgroups",
routerLink: ["/taskgroups"]
}
]);
this.taskgroupPath.forEach(taskgroupEntity => { this.taskgroupPath.forEach(taskgroupEntity => {
this.navLinkListComponent!.addNavigationLink(taskgroupEntity.taskgroupName, ['/taskgroups', taskgroupEntity.taskgroupID.toString()]); this.navLinkListComponent!.addNavigationLink(taskgroupEntity.taskgroupName, ['/taskgroups', taskgroupEntity.taskgroupID.toString()]);
}) })