mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 08:53:14 +00:00
feat(tag): display tags sidebar with tree (#7428)
This commit is contained in:
@@ -162,3 +162,26 @@ export const getAllSubTreeNodes = (nodeIndex, tree) => {
|
||||
}
|
||||
return subNodes;
|
||||
};
|
||||
|
||||
export const getTreeChildNodes = (parentNode, tree) => {
|
||||
const parentNodeKey = getTreeNodeKey(parentNode);
|
||||
const parentNodeIndex = tree.findIndex((node) => getTreeNodeKey(node) === parentNodeKey);
|
||||
if (parentNodeIndex < 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const parentNodeDepth = getTreeNodeDepth(parentNode);
|
||||
const childNodeDepth = parentNodeDepth + 1;
|
||||
let childNodes = [];
|
||||
for (let i = parentNodeIndex + 1, len = tree.length; i < len; i++) {
|
||||
const currentNode = tree[i];
|
||||
if (!getTreeNodeKey(currentNode).includes(parentNodeKey)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (getTreeNodeDepth(currentNode) === childNodeDepth) {
|
||||
childNodes.push({ ...currentNode });
|
||||
}
|
||||
}
|
||||
return childNodes;
|
||||
};
|
||||
|
Reference in New Issue
Block a user