@elite.framework/ng.core 2.0.26 → 2.0.27

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.
@@ -708,6 +708,12 @@ class ConfigStateService {
708
708
  return undefined;
709
709
  }, this.store.state);
710
710
  }
711
+ getNavigation() {
712
+ return this.store.state?.navigation || null;
713
+ }
714
+ getNavigation$() {
715
+ return this.store.sliceState(state => state?.navigation || null);
716
+ }
711
717
  getFeature(key) {
712
718
  return this.store.state.features?.values?.[key];
713
719
  }
@@ -2238,13 +2244,57 @@ class AbstractNavTreeService extends AbstractTreeService {
2238
2244
  this.injector = injector;
2239
2245
  // TODO Merge Dynamic Nav Too!
2240
2246
  const configState = this.injector.get(ConfigStateService);
2241
- this.subscription = configState
2242
- .createOnUpdateStream((state) => state)
2243
- .subscribe(() => this.refresh());
2247
+ // this.subscription = configState
2248
+ // .createOnUpdateStream((state:any) => state)
2249
+ // .subscribe(() => this.refresh());
2250
+ this.subscription = configState.getAll$().pipe(map$1(appState => appState?.navigation)).subscribe(navigation => {
2251
+ if (navigation?.menus) {
2252
+ // Convert NavigationMenuItem to Route format
2253
+ const dynamicRoutes = this.convertNavigationToRoutes(navigation.menus);
2254
+ // Merge with existing routes
2255
+ this.add(dynamicRoutes);
2256
+ }
2257
+ });
2244
2258
  this.permissionService = injector.get(PermissionCheckerService);
2245
2259
  this.othersGroup = injector.get(OTHERS_GROUP);
2246
2260
  this.compareFunc = injector.get(SORT_COMPARE_FUNC);
2247
2261
  }
2262
+ // Add helper method to convert NavigationMenuItem to Route
2263
+ convertNavigationToRoutes(menuItems, parentName) {
2264
+ return menuItems
2265
+ .filter(item => item.isEnabled && item.isVisible)
2266
+ .flatMap(item => {
2267
+ const route = {
2268
+ name: item.name,
2269
+ path: this.extractPathFromUrl(item.url) || item.name.toLowerCase(),
2270
+ // parentName: parentName || null,
2271
+ requiredPolicy: item.permission || undefined,
2272
+ iconClass: item.icon || undefined,
2273
+ order: item.order,
2274
+ invisible: !item.isVisible,
2275
+ // You can add other properties based on your Route interface
2276
+ };
2277
+ const routes = [route];
2278
+ // Recursively add children
2279
+ if (item.items?.length) {
2280
+ const childRoutes = this.convertNavigationToRoutes(item.items, item.name);
2281
+ routes.push(...childRoutes);
2282
+ }
2283
+ return routes;
2284
+ });
2285
+ }
2286
+ extractPathFromUrl(url) {
2287
+ if (!url)
2288
+ return null;
2289
+ try {
2290
+ // Extract path from URL, remove domain/hash/query params
2291
+ const urlObj = new URL(url, window.location.origin);
2292
+ return urlObj.pathname || null;
2293
+ }
2294
+ catch {
2295
+ return url; // Return as-is if not a valid URL
2296
+ }
2297
+ }
2248
2298
  isGranted({ requiredPolicy }) {
2249
2299
  return this.permissionService.getGrantedPolicy(requiredPolicy);
2250
2300
  }