@elite.framework/ng.core 2.0.26 → 2.0.28
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,55 @@ 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
|
-
|
|
2243
|
-
|
|
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
|
+
.map(item => {
|
|
2267
|
+
const route = {
|
|
2268
|
+
name: item.name,
|
|
2269
|
+
parentName: parentName,
|
|
2270
|
+
path: this.extractPathFromUrl(item.url) || item.name.toLowerCase(),
|
|
2271
|
+
requiredPolicy: item.permission || undefined,
|
|
2272
|
+
order: item.order,
|
|
2273
|
+
invisible: !item.isVisible,
|
|
2274
|
+
iconClass: item.icon || undefined,
|
|
2275
|
+
children: [], // سيتم ملؤها إذا كان هناك عناصر فرعية
|
|
2276
|
+
};
|
|
2277
|
+
// Recursively convert children if exist
|
|
2278
|
+
if (item.items?.length) {
|
|
2279
|
+
route.children = this.convertNavigationToRoutes(item.items, item.name);
|
|
2280
|
+
}
|
|
2281
|
+
return route;
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
extractPathFromUrl(url) {
|
|
2285
|
+
if (!url)
|
|
2286
|
+
return null;
|
|
2287
|
+
try {
|
|
2288
|
+
// Extract path from URL, remove domain/hash/query params
|
|
2289
|
+
const urlObj = new URL(url, window.location.origin);
|
|
2290
|
+
return urlObj.pathname || null;
|
|
2291
|
+
}
|
|
2292
|
+
catch {
|
|
2293
|
+
return url; // Return as-is if not a valid URL
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2248
2296
|
isGranted({ requiredPolicy }) {
|
|
2249
2297
|
return this.permissionService.getGrantedPolicy(requiredPolicy);
|
|
2250
2298
|
}
|