diff --git a/dmp-frontend/src/app/widgets/breadcrumb/breadcrumb.component.ts b/dmp-frontend/src/app/widgets/breadcrumb/breadcrumb.component.ts index d7e5f3612..d5edd8186 100644 --- a/dmp-frontend/src/app/widgets/breadcrumb/breadcrumb.component.ts +++ b/dmp-frontend/src/app/widgets/breadcrumb/breadcrumb.component.ts @@ -32,8 +32,8 @@ export class BreadcrumbComponent implements OnInit { //this.breadcrumbData.length = 0; this.route.children.forEach( child => { - let menuItem : MenuItem = this.guessMenuItemFromActivatedRoute(child, event); - this.adaptBreadcrumbByMenuItem(menuItem); + let guessed = this.guessMenuItemFromActivatedRoute(child, event); + this.adaptBreadcrumbByMenuItem(guessed.menuItem, guessed.isBaseComponent); }) } @@ -45,6 +45,8 @@ export class BreadcrumbComponent implements OnInit { guessMenuItemFromActivatedRoute(activatedRoute : any, event : NavigationEnd) { //it's important to leave it as "any" let menuItem : MenuItem = null; + let isBaseComponent : boolean = false; + let componentName = activatedRoute.component.name; let params = activatedRoute.queryParams.getValue(); @@ -53,21 +55,26 @@ export class BreadcrumbComponent implements OnInit { if(componentName == "ProjectsComponent") { label = "Projects"; + isBaseComponent = true; } if(componentName == "DmpComponent"){ label = "My Data Management Plans"; + isBaseComponent = true; } if(componentName == "DatasetsComponent"){ label = "Datasets of DMP '"+params["label"]+"'"; + isBaseComponent = false; } if(componentName == "DynamicFormComponent"){ label = "Form of dataset '"+params["label"]+"'"; + isBaseComponent = false; } if(componentName == "DmpDetailedComponent"){ label = "Details of DMP '"+params["label"]+"'"; + isBaseComponent = false; } @@ -76,16 +83,19 @@ export class BreadcrumbComponent implements OnInit { console.log("COMPONENT NAME="+componentName); - return menuItem; + return {"menuItem": menuItem, "isBaseComponent": isBaseComponent}; } - adaptBreadcrumbByMenuItem(menuItem : MenuItem){ + adaptBreadcrumbByMenuItem(menuItem : MenuItem, isBaseComponent : boolean){ if(menuItem==null){ this.breadcrumbData.length = 0; return; } + if(isBaseComponent){ + this.breadcrumbData.length = 0; + } let breadcrumbDataNew: MenuItem[] = new Array(); for(var i=0; i