diff --git a/src/app/shared/services/menu-item.service.ts b/src/app/shared/services/menu-item.service.ts index cd13069d..22d31bd8 100644 --- a/src/app/shared/services/menu-item.service.ts +++ b/src/app/shared/services/menu-item.service.ts @@ -55,21 +55,20 @@ export class MenuItemService { } private expandCurrentMfeMenuItems(items: MenuItem[], currentMfePath: string): boolean { + let expanded = false for (const item of items) { - if (this.stripPath(item.routerLink) === currentMfePath) return true - else if (item.items && this.expandCurrentMfeMenuItems(item.items, currentMfePath)) { - item.expanded = true - return true - } + if (!expanded) + if (this.stripPath(item.routerLink) === currentMfePath) expanded = true + else if (item.items && this.expandCurrentMfeMenuItems(item.items, currentMfePath)) { + item.expanded = true + expanded = true + } } - return false + return expanded } private replaceUrlVariables(url: string | undefined): string | undefined { - if (!url) { - return - } - return url.replaceAll( + return url?.replaceAll( /\[\[(.+?)\]\]/g, //NOSONAR (_match, $1) => { return sessionStorage.getItem($1) ?? localStorage.getItem($1) ?? '' diff --git a/src/app/workspace/workspace-menu/menu.component.html b/src/app/workspace/workspace-menu/menu.component.html index 8b7b30bc..282ff6e9 100644 --- a/src/app/workspace/workspace-menu/menu.component.html +++ b/src/app/workspace/workspace-menu/menu.component.html @@ -14,23 +14,16 @@ - -
- - -
+ - + +
diff --git a/src/app/workspace/workspace-menu/menu.component.ts b/src/app/workspace/workspace-menu/menu.component.ts index c4e17a4c..1311e956 100644 --- a/src/app/workspace/workspace-menu/menu.component.ts +++ b/src/app/workspace/workspace-menu/menu.component.ts @@ -167,6 +167,8 @@ export class MenuComponent implements OnInit, OnDestroy { .get([ 'ACTIONS.NAVIGATION.BACK', 'ACTIONS.NAVIGATION.BACK.TOOLTIP', + 'ACTIONS.CREATE.LABEL', + 'ACTIONS.CREATE.MENU', 'ACTIONS.EXPORT.LABEL', 'ACTIONS.EXPORT.MENU', 'ACTIONS.IMPORT.LABEL', @@ -182,6 +184,14 @@ export class MenuComponent implements OnInit, OnDestroy { icon: 'pi pi-arrow-left', show: 'always' }, + { + label: data['ACTIONS.CREATE.LABEL'], + title: data['ACTIONS.CREATE.MENU'], + actionCallback: () => this.onCreateMenu(), + icon: 'pi pi-plus', + show: 'always', + permission: 'MENU#CREATE' + }, { label: data['ACTIONS.EXPORT.LABEL'], title: data['ACTIONS.EXPORT.MENU'], @@ -212,6 +222,7 @@ export class MenuComponent implements OnInit, OnDestroy { this.location.back() } public onReload(): void { + if (this.loading) return this.wRoles = [] this.wAssignments = [] this.loadMenu(true) @@ -320,8 +331,7 @@ export class MenuComponent implements OnInit, OnDestroy { this.menuItem = item this.displayMenuDetail = true } - public onCreateMenu($event: MouseEvent, parent?: WorkspaceMenuItem): void { - $event.stopPropagation() + public onCreateMenu(parent?: WorkspaceMenuItem): void { this.changeMode = 'CREATE' this.menuItem = parent this.displayMenuDetail = true diff --git a/src/app/workspace/workspace-menu/services/menu-tree.service.ts b/src/app/workspace/workspace-menu/services/menu-tree.service.ts index 2fc8cf12..fbfb9f03 100644 --- a/src/app/workspace/workspace-menu/services/menu-tree.service.ts +++ b/src/app/workspace/workspace-menu/services/menu-tree.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core' import { TreeNode } from 'primeng/api' + import { WorkspaceMenuItem } from 'src/app/shared/generated' export interface NewPosition {