@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 = (
|
|
463
|
+
const createGlobalPermissionsGuard = (fallbackRoute) => {
|
|
464
464
|
let checkedRoutes = [];
|
|
465
|
-
const permissionsGuard = (permissions) => (route
|
|
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
|
|
475
|
-
if (!
|
|
474
|
+
const currentPath = route.routeConfig?.path;
|
|
475
|
+
if (!currentPath) {
|
|
476
476
|
checkedRoutes = [];
|
|
477
477
|
return router.createUrlTree(fallbackRoute);
|
|
478
478
|
}
|
|
479
|
-
checkedRoutes.push(
|
|
480
|
-
const
|
|
481
|
-
const
|
|
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(
|
|
487
|
+
return router.createUrlTree([...parentUrl, nextRoute.path]);
|
|
484
488
|
}
|
|
485
489
|
checkedRoutes = [];
|
|
486
490
|
return router.createUrlTree(fallbackRoute);
|