more routerLink fixes
This commit is contained in:
parent
28f8df5a36
commit
b2d68ed16e
|
@ -194,10 +194,10 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||||
if (this.authentication.getSelectedTenantName() && this.authentication.getSelectedTenantName() !== '')
|
if (this.authentication.getSelectedTenantName() && this.authentication.getSelectedTenantName() !== '')
|
||||||
this.breadcrumbService.addIdResolvedValue(this.authentication.selectedTenant(), this.authentication.getSelectedTenantName());
|
this.breadcrumbService.addIdResolvedValue(this.authentication.selectedTenant(), this.authentication.getSelectedTenantName());
|
||||||
|
|
||||||
const enrichedUrl = this.tenantHandlingService.getUrlEnrichedWithTenantCode(event.url, this.authentication.selectedTenant() ?? 'default');
|
// const enrichedUrl = this.tenantHandlingService.getUrlEnrichedWithTenantCode(event.url, this.authentication.selectedTenant() ?? 'default');
|
||||||
if (event.url != enrichedUrl) {
|
// if (event.url != enrichedUrl) {
|
||||||
this.router.navigateByUrl(enrichedUrl);
|
// this.router.navigateByUrl(enrichedUrl);
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
|
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
|
||||||
|
|
|
@ -11,10 +11,10 @@ export class RouterUtilsService {
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
generateUrl(url: string | string[]): string {
|
generateUrl(url: string | string[], joinAt: string = ''): string {
|
||||||
const tenant = this.authService.selectedTenant() ?? 'default';
|
const tenant = this.authService.selectedTenant() ?? 'default';
|
||||||
if (Array.isArray(url)) {
|
if (Array.isArray(url)) {
|
||||||
return this.tenantHandlingService.getUrlEnrichedWithTenantCode(url.join(''), tenant)
|
return this.tenantHandlingService.getUrlEnrichedWithTenantCode(url.join(joinAt), tenant)
|
||||||
} else {
|
} else {
|
||||||
return this.tenantHandlingService.getUrlEnrichedWithTenantCode(url, tenant);
|
return this.tenantHandlingService.getUrlEnrichedWithTenantCode(url, tenant);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class TenantHandlingService {
|
||||||
|
|
||||||
const urlTree: UrlTree = this.router.parseUrl(url);
|
const urlTree: UrlTree = this.router.parseUrl(url);
|
||||||
const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET];
|
const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET];
|
||||||
const urlSegments: UrlSegment[] = urlSegmentGroup?.segments;
|
const urlSegments: UrlSegment[] = urlSegmentGroup?.segments ?? [];
|
||||||
|
|
||||||
const tenantParamIndex = urlSegments?.findIndex(x => x.path == 't');
|
const tenantParamIndex = urlSegments?.findIndex(x => x.path == 't');
|
||||||
if (tenantParamIndex >= 0) {
|
if (tenantParamIndex >= 0) {
|
||||||
|
@ -45,7 +45,7 @@ export class TenantHandlingService {
|
||||||
tenantCodeSegment.path = tenantCode;
|
tenantCodeSegment.path = tenantCode;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tenantCode != 'default') {
|
if (tenantCode != 'default' && urlTree?.root?.children[PRIMARY_OUTLET]) {
|
||||||
urlTree.root.children[PRIMARY_OUTLET].segments = [new UrlSegment('t', {}), new UrlSegment(tenantCode, {}), ...urlSegments];
|
urlTree.root.children[PRIMARY_OUTLET].segments = [new UrlSegment('t', {}), new UrlSegment(tenantCode, {}), ...urlSegments];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { BaseComponent } from "@common/base/base.component";
|
||||||
import { combineLatest, of } from "rxjs";
|
import { combineLatest, of } from "rxjs";
|
||||||
import { debounceTime, distinctUntilChanged, filter, map, startWith, takeUntil, tap } from "rxjs/operators";
|
import { debounceTime, distinctUntilChanged, filter, map, startWith, takeUntil, tap } from "rxjs/operators";
|
||||||
import { BreadCrumbRouteData, BreadcrumbService } from "./breadcrumb.service";
|
import { BreadCrumbRouteData, BreadcrumbService } from "./breadcrumb.service";
|
||||||
|
import { RouterUtilsService } from "@app/core/services/router/router-utils.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -25,7 +26,12 @@ export class NavigationBreadcrumbComponent extends BaseComponent {
|
||||||
protected readonly HOME_SYMBOL = Symbol('home')
|
protected readonly HOME_SYMBOL = Symbol('home')
|
||||||
|
|
||||||
|
|
||||||
constructor(private router: Router, private breadcrumbService: BreadcrumbService, private cdr: ChangeDetectorRef) {
|
constructor(
|
||||||
|
public routerUtils: RouterUtilsService,
|
||||||
|
private router: Router,
|
||||||
|
private breadcrumbService: BreadcrumbService,
|
||||||
|
private cdr: ChangeDetectorRef
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
combineLatest([
|
combineLatest([
|
||||||
this.breadcrumbService.resolvedValues().pipe(
|
this.breadcrumbService.resolvedValues().pipe(
|
||||||
|
@ -57,7 +63,7 @@ export class NavigationBreadcrumbComponent extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public computePath(index: number): string[] {
|
public computePath(index: number): string {
|
||||||
if (!this.breadCrumbs?.length) {
|
if (!this.breadCrumbs?.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -75,9 +81,11 @@ export class NavigationBreadcrumbComponent extends BaseComponent {
|
||||||
.filter(x => !!x);
|
.filter(x => !!x);
|
||||||
|
|
||||||
|
|
||||||
return this.breadcrumbService.getPathOverrideFor(
|
const computedPath = this.breadcrumbService.getPathOverrideFor(
|
||||||
path?.join('/').replace('//', '/')
|
path?.join('/').replace('//', '/')
|
||||||
)?.split('/') ?? path;
|
)?.split('/') ?? path;
|
||||||
|
|
||||||
|
return this.routerUtils.generateUrl(computedPath.filter(x => x !== '/'), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
private _buildBreadCrumbs(activatedRoute: ActivatedRouteSnapshot): BreadCrumbItem[] {
|
private _buildBreadCrumbs(activatedRoute: ActivatedRouteSnapshot): BreadCrumbItem[] {
|
||||||
|
|
Loading…
Reference in New Issue