mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cui tree fix (#7680)
* [CUI] Fix for tree expansion - Prevent infinite recursion - Not sure how this has not happened before * Code cleanup
This commit is contained in:
parent
105dd7152e
commit
cb2c2203f7
@ -163,7 +163,13 @@ function generateTreeStructure(data, options) {
|
||||
const nodes = {};
|
||||
const roots = [];
|
||||
|
||||
for (let node of data) {
|
||||
if (!data || !Array.isArray(data) || data.length == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
for (let ii = 0; ii < data.length; ii++) {
|
||||
let node = data[ii];
|
||||
|
||||
nodes[node.pk] = node;
|
||||
node.selectable = false;
|
||||
|
||||
@ -173,12 +179,16 @@ function generateTreeStructure(data, options) {
|
||||
};
|
||||
|
||||
if (options.processNode) {
|
||||
data[data.indexOf(node)] = options.processNode(node);
|
||||
node = options.processNode(node);
|
||||
data[ii] = node;
|
||||
}
|
||||
}
|
||||
|
||||
for (let node of data) {
|
||||
if (node.parent != null) {
|
||||
for (let ii = 0; ii < data.length; ii++) {
|
||||
|
||||
let node = data[ii];
|
||||
|
||||
if (!!node.parent) {
|
||||
if (nodes[node.parent].nodes) {
|
||||
nodes[node.parent].nodes.push(node);
|
||||
} else {
|
||||
@ -186,9 +196,9 @@ function generateTreeStructure(data, options) {
|
||||
}
|
||||
|
||||
if (node.state.expanded) {
|
||||
while (node.parent != null) {
|
||||
while (!!node.parent) {
|
||||
nodes[node.parent].state.expanded = true;
|
||||
data[data.indexOf(node)] = nodes[node.parent];
|
||||
node = nodes[node.parent];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user