diff --git a/projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts b/projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts index b409cacbe..072b93be4 100644 --- a/projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts +++ b/projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts @@ -264,10 +264,16 @@ export abstract class AbstractDashboardComponent { return; } const itemRoute = this._doubleDrawerNavigationService.getItemRoutingPath(menuItemCase); - this._pathService.activePath = this.getFieldValue(menuItemCase, GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH); const nodePath = this.getFieldValue(menuItemCase, GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH); - if (nodePath) { + if (menuItemCase.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_HAS_CHILDREN)?.value && nodePath) { + this._doubleDrawerNavigationService.currentNavigationItem = undefined; this._pathService.activePath = nodePath; + } else if (nodePath) { + const menuItem = this._doubleDrawerNavigationService.resolveItemCaseToNavigationItem(menuItemCase); + if (menuItem) { + this._doubleDrawerNavigationService.currentNavigationItem = menuItem; + } + this._pathService.activePath = this._doubleDrawerNavigationService.extractParentPath(nodePath); } this._router.navigate([itemRoute]); } else { diff --git a/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts b/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts index f55ed340e..9a75d225f 100644 --- a/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts +++ b/projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts @@ -76,7 +76,7 @@ export class DoubleDrawerNavigationService implements OnDestroy { /** * Currently selected navigation item */ - protected _currentNavigationItem: NavigationItem; + protected _currentNavigationItem: NavigationItem | undefined; protected defaultViewIcon: string = 'filter_alt'; protected customItemsInitialized: boolean; protected hiddenCustomItemsInitialized: boolean; @@ -103,7 +103,7 @@ export class DoubleDrawerNavigationService implements OnDestroy { this._leftLoading$ = new LoadingEmitter(); this._rightLoading$ = new LoadingEmitter(); this._nodeLoading$ = new LoadingEmitter(); - this._currentNavigationItem = null; + this._currentNavigationItem = undefined; this.itemsOrder = MenuOrder.Ascending; this.customItemsInitialized = false; this.hiddenCustomItemsInitialized = false; @@ -145,6 +145,10 @@ export class DoubleDrawerNavigationService implements OnDestroy { } } + public set currentNavigationItem(item: NavigationItem | undefined) { + this._currentNavigationItem = item; + } + protected resolveMenuItems(path: string) { if (path === PathService.SEPARATOR) { this._leftItems$.next([]) @@ -242,7 +246,7 @@ export class DoubleDrawerNavigationService implements OnDestroy { if (this.leftLoading$.isActive || this.rightLoading$.isActive || this.currentPath === PathService.SEPARATOR) { return } - this._pathService.activePath = this.extractParent(this.currentPath); + this._pathService.activePath = this.extractParentPath(this.currentPath); this.itemClicked.emit({path: this._pathService.activePath, isHome: false}); } @@ -253,12 +257,12 @@ export class DoubleDrawerNavigationService implements OnDestroy { * */ public onItemClick(item: NavigationItem): void { if (item.resource === undefined) { - this._currentNavigationItem = null; + this._currentNavigationItem = undefined; // custom view represented only in nae.json if (item.processUri === this.currentPath) { this._pathService.activePath = this.currentPath; } else { - this._pathService.activePath = this.extractParent(this.currentPath); + this._pathService.activePath = this.extractParentPath(this.currentPath); } this.itemClicked.emit({path: this._pathService.activePath, isHome: false}); } else { @@ -275,7 +279,7 @@ export class DoubleDrawerNavigationService implements OnDestroy { this.openAvailableView(); }) } else if (!path.includes(this.currentPath)) { - this._pathService.activePath = this.extractParent(this.currentPath); + this._pathService.activePath = this.extractParentPath(this.currentPath); this.itemClicked.emit({path: this._pathService.activePath, isHome: false}); } else { @@ -376,7 +380,7 @@ export class DoubleDrawerNavigationService implements OnDestroy { } this.leftLoading$.on(); - this.getItemCaseByPath(this.extractParent(this.currentPath)).subscribe(page => { + this.getItemCaseByPath(this.extractParentPath(this.currentPath)).subscribe(page => { let childCases$; let targetItem; let orderedChildCaseIds; @@ -510,9 +514,9 @@ export class DoubleDrawerNavigationService implements OnDestroy { } protected resolveCustomViewsInLeftSide() { - if (!!this.extractParent(this.currentPath) && !!this._childCustomViews[this.extractParent(this.currentPath)]) { + if (!!this.extractParentPath(this.currentPath) && !!this._childCustomViews[this.extractParentPath(this.currentPath)]) { let currentLeftItems = this._leftItems$.getValue(); - currentLeftItems.push(...Object.values(this._childCustomViews[this.extractParent(this.currentPath)])); + currentLeftItems.push(...Object.values(this._childCustomViews[this.extractParentPath(this.currentPath)])); this._leftItems$.next(currentLeftItems); } } @@ -590,7 +594,7 @@ export class DoubleDrawerNavigationService implements OnDestroy { return this._caseResourceService.searchCases(SimpleFilter.fromCaseQuery(searchBody), httpParams); } - private extractParent(path: string): string { + public extractParentPath(path: string): string { if (path === '/') { return path; }