diff --git a/ui-ngx/src/app/shared/components/breadcrumb.component.ts b/ui-ngx/src/app/shared/components/breadcrumb.component.ts index 4aaa546f4a..9ee6a8ab9d 100644 --- a/ui-ngx/src/app/shared/components/breadcrumb.component.ts +++ b/ui-ngx/src/app/shared/components/breadcrumb.component.ts @@ -61,8 +61,19 @@ export class BreadcrumbComponent implements OnInit, OnDestroy { } } + private lastChild(route: ActivatedRouteSnapshot) { + let child = route; + while (child.firstChild !== null) { + child = child.firstChild; + } + return child; + } - buildBreadCrumbs(route: ActivatedRouteSnapshot, breadcrumbs: Array = []): Array { + buildBreadCrumbs(route: ActivatedRouteSnapshot, breadcrumbs: Array = [], + lastChild?: ActivatedRouteSnapshot): Array { + if (!lastChild) { + lastChild = this.lastChild(route); + } let newBreadcrumbs = breadcrumbs; if (route.routeConfig && route.routeConfig.data) { const breadcrumbConfig = route.routeConfig.data.breadcrumb as BreadCrumbConfig; @@ -72,7 +83,7 @@ export class BreadcrumbComponent implements OnInit, OnDestroy { let ignoreTranslate; if (breadcrumbConfig.labelFunction) { labelFunction = () => { - return breadcrumbConfig.labelFunction(route, this.translate, this.activeComponentValue); + return breadcrumbConfig.labelFunction(route, this.translate, this.activeComponentValue, lastChild.data); }; ignoreTranslate = true; } else { @@ -96,7 +107,7 @@ export class BreadcrumbComponent implements OnInit, OnDestroy { } } if (route.firstChild) { - return this.buildBreadCrumbs(route.firstChild, newBreadcrumbs); + return this.buildBreadCrumbs(route.firstChild, newBreadcrumbs, lastChild); } return newBreadcrumbs; } diff --git a/ui-ngx/src/app/shared/components/breadcrumb.ts b/ui-ngx/src/app/shared/components/breadcrumb.ts index 6063fd043b..2a1f3d5988 100644 --- a/ui-ngx/src/app/shared/components/breadcrumb.ts +++ b/ui-ngx/src/app/shared/components/breadcrumb.ts @@ -27,7 +27,7 @@ export interface BreadCrumb { queryParams: Params; } -export type BreadCrumbLabelFunction = (route: ActivatedRouteSnapshot, translate: TranslateService, component: C) => string; +export type BreadCrumbLabelFunction = (route: ActivatedRouteSnapshot, translate: TranslateService, component: C, data?: any) => string; export interface BreadCrumbConfig { labelFunction: BreadCrumbLabelFunction;