|
|
@ -307,21 +307,19 @@ Categories.flattenCategories = function (allCategories, categoryData) {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Categories.getTree = function (categories, parentCid) {
|
|
|
|
Categories.getTree = function (categories, parentCid) {
|
|
|
|
var tree = [];
|
|
|
|
var tree = [];
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
var len = categories.length;
|
|
|
|
|
|
|
|
var category;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i; i < len; i += 1) {
|
|
|
|
categories.forEach(function (category) {
|
|
|
|
category = categories[i];
|
|
|
|
if (category) {
|
|
|
|
if (!category.hasOwnProperty('parentCid') || category.parentCid === null) {
|
|
|
|
if (!category.hasOwnProperty('parentCid') || category.parentCid === null) {
|
|
|
|
category.parentCid = 0;
|
|
|
|
category.parentCid = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)) {
|
|
|
|
if (parseInt(category.parentCid, 10) === parseInt(parentCid, 10)) {
|
|
|
|
tree.push(category);
|
|
|
|
tree.push(category);
|
|
|
|
category.children = Categories.getTree(categories, category.cid);
|
|
|
|
category.children = Categories.getTree(categories, category.cid);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return tree;
|
|
|
|
return tree;
|
|
|
|
};
|
|
|
|
};
|
|
|
|