Skip to content

Commit d2850cd

Browse files
committed
[NAE-1906] Merge NAE-1882 with NAE-1904
- reimplement resolving views from left side, that have no children - synchronize async call
1 parent 6037422 commit d2850cd

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
191191
return;
192192
}
193193
this._currentNode = node;
194-
if (!node) return;
194+
if (!node) {
195+
return;
196+
}
195197
if (node.parentId && !node.parent) {
196198
if (node.parentId === this._uriService.root.id) {
197199
node.parent = this._uriService.root;
@@ -206,7 +208,13 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
206208
});
207209
}
208210
}
209-
this.resolveMenuItems(node);
211+
if (this.nodeLoading$.isActive) {
212+
this.nodeLoading$.subscribe(() => {
213+
this.resolveMenuItems(node)
214+
});
215+
} else {
216+
this.resolveMenuItems(node);
217+
}
210218
}
211219

212220
private resolveMenuItems(node: UriNodeResource) {
@@ -333,15 +341,26 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
333341
}
334342

335343
onItemClick(item: NavigationItem): void {
336-
if (this.hasItemChildren(item) && !this.leftLoading$.isActive && !this.rightLoading$.isActive) {
337-
const path = item.resource.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value
338-
this._uriService.getNodeByPath(path).subscribe(node => {
339-
this._uriService.activeNode = node
340-
}, error => {
341-
this._log.error(error);
342-
});
344+
if (item.resource === undefined) {
345+
// custom view represented only in nae.json
346+
if (item.processUri === this.currentNode.uriPath) {
347+
this._uriService.activeNode = this._currentNode;
348+
} else {
349+
this._uriService.activeNode = this._currentNode.parent;
350+
}
343351
} else {
344-
this._uriService.activeNode = this._currentNode;
352+
const path = item.resource.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value
353+
if (this.hasItemChildren(item) && !this.leftLoading$.isActive && !this.rightLoading$.isActive) {
354+
this._uriService.getNodeByPath(path).subscribe(node => {
355+
this._uriService.activeNode = node
356+
}, error => {
357+
this._log.error(error);
358+
});
359+
} else if (!path.includes(this.currentNode.uriPath)){
360+
this._uriService.activeNode = this._currentNode.parent;
361+
} else {
362+
this._uriService.activeNode = this._currentNode;
363+
}
345364
}
346365
}
347366

0 commit comments

Comments
 (0)