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