@ngx-smz/core 21.1.6 → 21.1.10
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.
|
@@ -34423,8 +34423,9 @@ class MenuHelperService {
|
|
|
34423
34423
|
profileCreationCallback;
|
|
34424
34424
|
menuCreationData;
|
|
34425
34425
|
profileCreationData;
|
|
34426
|
-
accessMenuBehavior;
|
|
34427
|
-
accessProfileBehavior;
|
|
34426
|
+
accessMenuBehavior = 'hide';
|
|
34427
|
+
accessProfileBehavior = 'hide';
|
|
34428
|
+
sidebarNavigationTargets = [];
|
|
34428
34429
|
constructor(actions$, store) {
|
|
34429
34430
|
this.actions$ = actions$;
|
|
34430
34431
|
this.store = store;
|
|
@@ -34452,6 +34453,7 @@ class MenuHelperService {
|
|
|
34452
34453
|
else {
|
|
34453
34454
|
this.setupProfile();
|
|
34454
34455
|
}
|
|
34456
|
+
this.refreshSidebarNavigationBindings();
|
|
34455
34457
|
}
|
|
34456
34458
|
setMenuBuild(callback) {
|
|
34457
34459
|
this.menuCreationCallback = () => sortMenuItemsByLabel(callback());
|
|
@@ -34475,29 +34477,91 @@ class MenuHelperService {
|
|
|
34475
34477
|
clearNotifications() {
|
|
34476
34478
|
this.notifications = [];
|
|
34477
34479
|
}
|
|
34478
|
-
|
|
34479
|
-
|
|
34480
|
-
|
|
34481
|
-
|
|
34482
|
-
this.
|
|
34483
|
-
|
|
34484
|
-
|
|
34485
|
-
|
|
34486
|
-
const
|
|
34487
|
-
|
|
34488
|
-
|
|
34489
|
-
|
|
34490
|
-
|
|
34480
|
+
bindNavigationMenuToSidebar(sidebar) {
|
|
34481
|
+
const without = this.sidebarNavigationTargets.filter((s) => s !== sidebar);
|
|
34482
|
+
this.sidebarNavigationTargets.length = 0;
|
|
34483
|
+
this.sidebarNavigationTargets.push(...without, sidebar);
|
|
34484
|
+
this.refreshSidebarNavigationBindings();
|
|
34485
|
+
}
|
|
34486
|
+
refreshSidebarNavigationBindings() {
|
|
34487
|
+
for (const target of this.sidebarNavigationTargets) {
|
|
34488
|
+
const stripped = this.stripAuthorizationNavigationMenuFromMenuItems(cloneDeep(target()));
|
|
34489
|
+
target.set(this.mergeNavigationMenuIntoMenuItems(stripped));
|
|
34490
|
+
}
|
|
34491
|
+
}
|
|
34492
|
+
stripAuthorizationNavigationMenuFromMenuItems(sidebarItems) {
|
|
34493
|
+
const items = cloneDeep(sidebarItems ?? []);
|
|
34494
|
+
if (GlobalInjector?.config?.rbkUtils?.authorization?.navigationMenu == null) {
|
|
34495
|
+
return items;
|
|
34496
|
+
}
|
|
34497
|
+
const navigationMenu = GlobalInjector.config.rbkUtils.authorization.navigationMenu;
|
|
34498
|
+
const navigationRootChildLabels = new Set((navigationMenu.items ?? [])
|
|
34499
|
+
.map((c) => c.label)
|
|
34500
|
+
.filter((label) => label != null));
|
|
34501
|
+
const sameLabelNode = items.find((x) => x.label === navigationMenu.label);
|
|
34502
|
+
if (sameLabelNode != null) {
|
|
34503
|
+
if (sameLabelNode.items?.length) {
|
|
34504
|
+
sameLabelNode.items = sameLabelNode.items.filter((child) => !navigationRootChildLabels.has(child.label));
|
|
34505
|
+
}
|
|
34506
|
+
return items;
|
|
34507
|
+
}
|
|
34508
|
+
return items.filter((x) => x.label !== navigationMenu.label);
|
|
34509
|
+
}
|
|
34510
|
+
mergeNavigationMenuIntoMenuItems(sidebarItems) {
|
|
34511
|
+
const items = cloneDeep(sidebarItems ?? []);
|
|
34512
|
+
if (GlobalInjector?.config?.rbkUtils?.authorization?.navigationMenu == null) {
|
|
34513
|
+
return items;
|
|
34514
|
+
}
|
|
34515
|
+
const navigationMenu = GlobalInjector.config.rbkUtils.authorization.navigationMenu;
|
|
34516
|
+
const navigationChildCreations = navigationMenu.items ?? [];
|
|
34517
|
+
const withSameLabel = items.find(x => x.label === navigationMenu.label);
|
|
34518
|
+
if (withSameLabel != null) {
|
|
34519
|
+
if (withSameLabel.items == null) {
|
|
34520
|
+
withSameLabel.items = [];
|
|
34521
|
+
}
|
|
34522
|
+
const mergedFromNavigation = [];
|
|
34523
|
+
for (const creation of navigationChildCreations) {
|
|
34524
|
+
const subItem = this.addMenuItemRecursive(creation, this.accessMenuBehavior);
|
|
34525
|
+
if (subItem != null) {
|
|
34526
|
+
mergedFromNavigation.push(subItem);
|
|
34491
34527
|
}
|
|
34492
|
-
// Merge dos itens desse menu
|
|
34493
|
-
withSameLabel.items = sortArrayOfObjects([...withSameLabel.items, ...navigationMenu.items], 'label', 1);
|
|
34494
34528
|
}
|
|
34495
|
-
|
|
34496
|
-
|
|
34497
|
-
|
|
34498
|
-
|
|
34529
|
+
withSameLabel.items = sortArrayOfObjects([...withSameLabel.items, ...mergedFromNavigation], 'label', 1);
|
|
34530
|
+
}
|
|
34531
|
+
else {
|
|
34532
|
+
const item = this.addMenuItemRecursive(navigationMenu, this.accessMenuBehavior);
|
|
34533
|
+
if (item?.items?.length > 0 || item?.command != null || item?.routerLink != null) {
|
|
34534
|
+
items.push(item);
|
|
34535
|
+
}
|
|
34536
|
+
}
|
|
34537
|
+
return items;
|
|
34538
|
+
}
|
|
34539
|
+
applyAuthorizationNavigationMenuToMenuCreations(creationData) {
|
|
34540
|
+
const extras = [];
|
|
34541
|
+
if (GlobalInjector.config.rbkUtils.authorization.navigationMenu == null) {
|
|
34542
|
+
return extras;
|
|
34543
|
+
}
|
|
34544
|
+
const navigationMenu = GlobalInjector.config.rbkUtils.authorization.navigationMenu;
|
|
34545
|
+
const navigationItems = navigationMenu.items ?? [];
|
|
34546
|
+
const withSameLabel = creationData.find(x => x.label === navigationMenu.label);
|
|
34547
|
+
if (withSameLabel != null) {
|
|
34548
|
+
if (withSameLabel.items == null) {
|
|
34549
|
+
withSameLabel.items = [];
|
|
34499
34550
|
}
|
|
34551
|
+
withSameLabel.items = sortArrayOfObjects([...withSameLabel.items, ...navigationItems], 'label', 1);
|
|
34500
34552
|
}
|
|
34553
|
+
else {
|
|
34554
|
+
extras.push(navigationMenu);
|
|
34555
|
+
}
|
|
34556
|
+
return extras;
|
|
34557
|
+
}
|
|
34558
|
+
setupMenu() {
|
|
34559
|
+
if (this.menuCreationData == null) {
|
|
34560
|
+
return;
|
|
34561
|
+
}
|
|
34562
|
+
const creationData = this.menuCreationData;
|
|
34563
|
+
this.menu = [];
|
|
34564
|
+
const extras = this.applyAuthorizationNavigationMenuToMenuCreations(creationData);
|
|
34501
34565
|
for (const creation of creationData) {
|
|
34502
34566
|
const item = this.addMenuItemRecursive(creation, this.accessMenuBehavior);
|
|
34503
34567
|
if (item?.items?.length > 0 || (item?.command != null || item?.routerLink != null)) {
|