mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
closes #962
This commit is contained in:
@@ -22,9 +22,11 @@
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="alert alert-warning hide {no_topics_message}" id="category-no-topics">
|
||||
<!-- IF !topics.length -->
|
||||
<div class="alert alert-warning" id="category-no-topics">
|
||||
[[category:no_topics]]
|
||||
</div>
|
||||
<!-- ENDIF !topics.length -->
|
||||
|
||||
<div class="category row">
|
||||
<div class="{topic_row_size}">
|
||||
@@ -94,7 +96,8 @@
|
||||
<!-- ENDIF usePagination -->
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 col-xs-12 {show_sidebar} category-sidebar">
|
||||
<!-- IF topics.length -->
|
||||
<div class="col-md-3 col-xs-12 category-sidebar">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">[[category:sidebar.recent_replies]]</div>
|
||||
<div class="panel-body recent-replies">
|
||||
@@ -129,6 +132,7 @@
|
||||
</div>
|
||||
<!-- END sidebars -->
|
||||
</div>
|
||||
<!-- ENDIF topics.length -->
|
||||
</div>
|
||||
|
||||
<input type="hidden" template-variable="category_id" value="{category_id}" />
|
||||
|
||||
@@ -48,9 +48,9 @@ var db = require('./database'),
|
||||
};
|
||||
|
||||
Categories.getCategoryById = function(category_id, start, end, current_user, callback) {
|
||||
Categories.getCategoryData(category_id, function(err, categoryData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
||||
function getCategoryData(next) {
|
||||
Categories.getCategoryData(category_id, next);
|
||||
}
|
||||
|
||||
function getTopics(next) {
|
||||
@@ -58,7 +58,16 @@ var db = require('./database'),
|
||||
}
|
||||
|
||||
function getActiveUsers(next) {
|
||||
Categories.getActiveUsers(category_id, next);
|
||||
Categories.getActiveUsers(category_id, function(err, uids) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
|
||||
});
|
||||
}
|
||||
|
||||
function getModerators(next) {
|
||||
Categories.getModerators(category_id, next);
|
||||
}
|
||||
|
||||
function getSidebars(next) {
|
||||
@@ -71,59 +80,37 @@ var db = require('./database'),
|
||||
Categories.getPageCount(category_id, next);
|
||||
}
|
||||
|
||||
async.parallel([getTopics, getActiveUsers, getSidebars, getPageCount], function(err, results) {
|
||||
async.parallel({
|
||||
'category': getCategoryData,
|
||||
'topics': getTopics,
|
||||
'active_users': getActiveUsers,
|
||||
'moderators': getModerators,
|
||||
'sidebars': getSidebars,
|
||||
'pageCount': getPageCount
|
||||
}, function(err, results) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var active_users = results[1],
|
||||
sidebars = results[2],
|
||||
pageCount = results[3];
|
||||
|
||||
var category = {
|
||||
'category_name': categoryData.name,
|
||||
'category_description': categoryData.description,
|
||||
'link': categoryData.link,
|
||||
'disabled': categoryData.disabled || '0',
|
||||
'show_sidebar': 'show',
|
||||
'category_name': results.category.name,
|
||||
'category_description': results.category.description,
|
||||
'link': results.category.link,
|
||||
'disabled': results.category.disabled || '0',
|
||||
'show_topic_button': 'inline-block',
|
||||
'no_topics_message': 'hidden',
|
||||
'topic_row_size': 'col-md-9',
|
||||
'category_id': category_id,
|
||||
'active_users': [],
|
||||
'topics': results[0].topics,
|
||||
'nextStart': results[0].nextStart,
|
||||
'pageCount': pageCount,
|
||||
'active_users': results.active_users,
|
||||
'moderators': results.moderators,
|
||||
'topics': results.topics.topics,
|
||||
'nextStart': results.topics.nextStart,
|
||||
'pageCount': results.pageCount,
|
||||
'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false,
|
||||
'sidebars': sidebars
|
||||
'sidebars': results.sidebars
|
||||
};
|
||||
|
||||
function getModerators(next) {
|
||||
Categories.getModerators(category_id, next);
|
||||
}
|
||||
|
||||
function getActiveUsers(next) {
|
||||
user.getMultipleUserFields(active_users, ['uid', 'username', 'userslug', 'picture'], next);
|
||||
}
|
||||
|
||||
if (!category.topics.length) {
|
||||
getModerators(function(err, moderators) {
|
||||
category.moderators = moderators;
|
||||
category.show_sidebar = 'hidden';
|
||||
category.no_topics_message = 'show';
|
||||
callback(null, category);
|
||||
});
|
||||
} else {
|
||||
async.parallel([getModerators, getActiveUsers], function(err, results) {
|
||||
category.moderators = results[0];
|
||||
category.active_users = results[1];
|
||||
category.show_sidebar = category.topics.length > 0 ? 'show' : 'hidden';
|
||||
callback(null, category);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getCategoryTopics = function(cid, start, stop, uid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user