|
|
@ -387,17 +387,18 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
BI.extend(BI.Tree, { |
|
|
|
BI.extend(BI.Tree, { |
|
|
|
transformToArrayFormat: function (nodes, pId) { |
|
|
|
transformToArrayFormat: function (nodes, pId, childKey) { |
|
|
|
if (!nodes) return []; |
|
|
|
if (!nodes) return []; |
|
|
|
var r = []; |
|
|
|
var r = []; |
|
|
|
|
|
|
|
childKey = childKey || "children"; |
|
|
|
if (BI.isArray(nodes)) { |
|
|
|
if (BI.isArray(nodes)) { |
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) { |
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) { |
|
|
|
var node = BI.clone(nodes[i]); |
|
|
|
var node = BI.clone(nodes[i]); |
|
|
|
node.pId = node.pId == null ? pId : node.pId; |
|
|
|
node.pId = node.pId == null ? pId : node.pId; |
|
|
|
delete node.children; |
|
|
|
delete node.children; |
|
|
|
r.push(node); |
|
|
|
r.push(node); |
|
|
|
if (nodes[i]["children"]) { |
|
|
|
if (nodes[i][childKey]) { |
|
|
|
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id)); |
|
|
|
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i][childKey], node.id)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -405,8 +406,8 @@ |
|
|
|
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId; |
|
|
|
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId; |
|
|
|
delete newNodes.children; |
|
|
|
delete newNodes.children; |
|
|
|
r.push(newNodes); |
|
|
|
r.push(newNodes); |
|
|
|
if (nodes["children"]) { |
|
|
|
if (nodes[childKey]) { |
|
|
|
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id)); |
|
|
|
r = r.concat(BI.Tree.transformToArrayFormat(nodes[childKey], newNodes.id)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return r; |
|
|
|
return r; |
|
|
|