fix(core-app): CB-986 parents getting for unloaded node

This commit is contained in:
Wroud
2021-05-25 20:08:52 +03:00
parent cdef4553cf
commit 41e96bb127
2 changed files with 23 additions and 0 deletions
@@ -284,6 +284,10 @@ export class NavNodeManagerService extends Bootstrap {
const parents: string[] = [];
let parent = this.getNode(nodeId);
if (!parent) {
return NodeManagerUtils.parentsFromPath(nodeId);
}
while (parent && parent.parentId !== ROOT_NODE_PATH && parent.id !== parent.parentId) {
parents.unshift(parent.parentId);
parent = this.getNode(parent.parentId);
@@ -16,6 +16,25 @@ export const NodeManagerUtils = {
return connectionNodeId.replace('database://', '');
},
parentsFromPath(nodeId: string): string[] {
const parts = nodeId
.replace('//', '\\')
.split('/');
let lastPath = '';
const parents: string[] = [];
for (const part of parts) {
if (lastPath !== '') {
lastPath += '/';
}
lastPath += part.replace('\\', '//');
parents.push(lastPath);
}
return parents;
},
connectionIdToConnectionNodeId(connectionId: string): string {
return `database://${connectionId}`;
},