|
|
@ -100,12 +100,13 @@ function getWatchedCategories(uid, selectedCid, callback) {
|
|
|
|
privileges.categories.filterCids('read', cids, uid, next);
|
|
|
|
privileges.categories.filterCids('read', cids, uid, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (cids, next) {
|
|
|
|
function (cids, next) {
|
|
|
|
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'link', 'color', 'bgColor'], next);
|
|
|
|
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'link', 'color', 'bgColor', 'parentCid'], next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (categoryData, next) {
|
|
|
|
function (categoryData, next) {
|
|
|
|
categoryData = categoryData.filter(function(category) {
|
|
|
|
categoryData = categoryData.filter(function(category) {
|
|
|
|
return category && !category.link;
|
|
|
|
return category && !category.link;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var selectedCategory;
|
|
|
|
var selectedCategory;
|
|
|
|
categoryData.forEach(function(category) {
|
|
|
|
categoryData.forEach(function(category) {
|
|
|
|
category.selected = parseInt(category.cid, 10) === parseInt(selectedCid, 10);
|
|
|
|
category.selected = parseInt(category.cid, 10) === parseInt(selectedCid, 10);
|
|
|
@ -113,11 +114,27 @@ function getWatchedCategories(uid, selectedCid, callback) {
|
|
|
|
selectedCategory = category;
|
|
|
|
selectedCategory = category;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
next(null, {categories: categoryData, selectedCategory: selectedCategory});
|
|
|
|
|
|
|
|
|
|
|
|
var categoriesData = [];
|
|
|
|
|
|
|
|
var tree = categories.getTree(categoryData, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tree.forEach(function(category) {
|
|
|
|
|
|
|
|
recursive(category, categoriesData, '');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next(null, {categories: categoriesData, selectedCategory: selectedCategory});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
], callback);
|
|
|
|
], callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function recursive(category, categoriesData, level) {
|
|
|
|
|
|
|
|
category.level = level;
|
|
|
|
|
|
|
|
categoriesData.push(category);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
category.children.forEach(function(child) {
|
|
|
|
|
|
|
|
recursive(child, categoriesData, ' ' + level);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unreadController.unreadTotal = function(req, res, next) {
|
|
|
|
unreadController.unreadTotal = function(req, res, next) {
|
|
|
|
var filter = req.params.filter || '';
|
|
|
|
var filter = req.params.filter || '';
|
|
|
|