@wolkabout/commons 0.0.48 → 0.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -460,9 +460,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
460
460
  }]
461
461
  }] });
462
462
 
463
- const createGlobalPermissionsGuard = (availableRoutesGetter, fallbackRoute, parentRoutes) => {
463
+ const createGlobalPermissionsGuard = (fallbackRoute) => {
464
464
  let checkedRoutes = [];
465
- const permissionsGuard = (permissions) => (route, state) => {
465
+ const permissionsGuard = (permissions) => (route) => {
466
466
  const router = inject(Router);
467
467
  const permissionService = inject(PermissionsService);
468
468
  const permissionsToCheck = Array.isArray(permissions) ? permissions : [permissions];
@@ -471,16 +471,20 @@ const createGlobalPermissionsGuard = (availableRoutesGetter, fallbackRoute, pare
471
471
  checkedRoutes = [];
472
472
  return true;
473
473
  }
474
- const currentRoute = route.routeConfig?.path;
475
- if (!currentRoute) {
474
+ const currentPath = route.routeConfig?.path;
475
+ if (!currentPath) {
476
476
  checkedRoutes = [];
477
477
  return router.createUrlTree(fallbackRoute);
478
478
  }
479
- checkedRoutes.push(currentRoute);
480
- const availableRoutes = availableRoutesGetter()?.filter(route => route.path !== '**');
481
- const nextRoute = availableRoutes?.find((route) => route.path !== currentRoute && !checkedRoutes.includes(route.path));
479
+ checkedRoutes.push(currentPath);
480
+ const siblings = route.parent?.routeConfig?.children?.filter((route) => !!route.path && route.path !== '**' && !checkedRoutes.includes(route.path)) ?? [];
481
+ const parentUrl = route.parent?.pathFromRoot
482
+ .flatMap((route) => route.url)
483
+ .map((url) => url.path)
484
+ .filter(Boolean) ?? [];
485
+ const nextRoute = siblings[0];
482
486
  if (nextRoute) {
483
- return router.createUrlTree(parentRoutes ? [...parentRoutes, nextRoute.path] : [nextRoute.path]);
487
+ return router.createUrlTree([...parentUrl, nextRoute.path]);
484
488
  }
485
489
  checkedRoutes = [];
486
490
  return router.createUrlTree(fallbackRoute);