v1.18.x
Baris Usakli 12 years ago
parent 0bd56196cf
commit ac3fe1fc6f

@ -6,15 +6,6 @@
margin-bottom: 10px; margin-bottom: 10px;
padding: 10px; padding: 10px;
cursor: move; cursor: move;
width: 800px;
}
.entry-row {
border-radius: 10px;
margin-bottom: 10px;
padding: 10px;
cursor: move;
width: 695px;
} }
input.description { input.description {

@ -74,6 +74,30 @@ jQuery('.blockclass').each(function() {
jQuery('.category_name, .category_description, .blockclass').on('change', function(ev) { jQuery('.category_name, .category_description, .blockclass').on('change', function(ev) {
modified(ev.target); modified(ev.target);
}); });
jQuery('.entry-row button').each(function(index, element) {
var disabled = $(element).attr('data-disabled');
if(disabled == "0" || disabled == "")
$(element).html('Disable');
else
$(element).html('Enable');
});
jQuery('.entry-row button').on('click', function(ev) {
var btn = jQuery(this);
var categoryRow = btn.parents('li');
var cid = categoryRow.attr('data-cid');
var disabled = btn.html() == "Disable" ? "1":"0";
categoryRow.remove();
modified_categories[cid] = modified_categories[cid] || {};
modified_categories[cid]['disabled'] = disabled;
save();
return false;
});
}); });
}()); }());

@ -27,6 +27,7 @@
<option value="category-orange">category-orange</option> <option value="category-orange">category-orange</option>
</select> </select>
<input data-name="description" placeholder="Category Description" value="{categories.description}" class="category_description input-medium description"></input> <input data-name="description" placeholder="Category Description" value="{categories.description}" class="category_description input-medium description"></input>
<button type="submit" class="btn" data-disabled="{categories.disabled}">Disable</button>
</form> </form>
</li> </li>

@ -70,7 +70,7 @@
<ul class="nav nav-list"> <ul class="nav nav-list">
<li class="nav-header">NodeBB</li> <li class="nav-header">NodeBB</li>
<li class='active'><a href='{relative_path}/admin/index'><i class='icon-home'></i> Home</a></li> <li class='active'><a href='{relative_path}/admin/index'><i class='icon-home'></i> Home</a></li>
<li class=''><a href='{relative_path}/admin/categories'><i class='icon-folder-close-alt'></i> Categories</a></li> <li class=''><a href='{relative_path}/admin/categories/active'><i class='icon-folder-close-alt'></i> Categories</a></li>
<li class=''><a href='{relative_path}/admin/users/latest'><i class='icon-user'></i> Users</a></li> <li class=''><a href='{relative_path}/admin/users/latest'><i class='icon-user'></i> Users</a></li>
<li class=''><a href='{relative_path}/admin/topics'><i class='icon-book'></i> Topics</a></li> <li class=''><a href='{relative_path}/admin/topics'><i class='icon-book'></i> Topics</a></li>
<li class=''><a href='{relative_path}/admin/themes'><i class='icon-th'></i> Themes</a></li> <li class=''><a href='{relative_path}/admin/themes'><i class='icon-th'></i> Themes</a></li>

@ -18,7 +18,8 @@ var RDB = require('./../redis.js'),
icon: data.icon, icon: data.icon,
blockclass: data.blockclass, blockclass: data.blockclass,
slug: slug, slug: slug,
topic_count: 0 topic_count: 0,
disabled: 0
}); });
RDB.set('categoryslug:' + slug + ':cid', cid); RDB.set('categoryslug:' + slug + ':cid', cid);

@ -25,7 +25,7 @@ var user = require('./../user.js'),
(function() { (function() {
var routes = [ var routes = [
'categories', 'users', 'topics', 'settings', 'themes', 'categories/active', 'categories/disabled', 'users', 'topics', 'settings', 'themes',
'twitter', 'facebook', 'gplus', 'redis', 'motd', 'twitter', 'facebook', 'gplus', 'redis', 'motd',
'users/latest', 'users/sort-posts', 'users/sort-reputation', 'users/latest', 'users/sort-posts', 'users/sort-reputation',
'users/search', 'plugins' 'users/search', 'plugins'
@ -106,8 +106,22 @@ var user = require('./../user.js'),
}); });
}); });
app.get('/api/admin/categories/active', function(req, res) {
categories.getAllCategories(function(data) {
data.categories = data.categories.filter(function(category) {
return (!category.disabled || category.disabled === "0");
});
res.json(data);
});
});
app.get('/api/admin/categories/disabled', function(req, res) { app.get('/api/admin/categories/disabled', function(req, res) {
res.json({categories: []}); categories.getAllCategories(function(data) {
data.categories = data.categories.filter(function(category) {
return category.disabled === "1";
});
res.json(data);
});
}); });
app.get('/api/admin/topics', function(req, res) { app.get('/api/admin/topics', function(req, res) {

@ -17,7 +17,11 @@ var user = require('./../user.js'),
app.get('/api/home', function(req, res) { app.get('/api/home', function(req, res) {
var uid = (req.user) ? req.user.uid : 0; var uid = (req.user) ? req.user.uid : 0;
categories.getAllCategories(function(data) { categories.getAllCategories(function(data) {
data.categories = data.categories.filter(function(category) {
return (!category.disabled || category.disabled === "0");
});
function iterator(category, callback) { function iterator(category, callback) {
categories.getRecentReplies(category.cid, 2, function(posts) { categories.getRecentReplies(category.cid, 2, function(posts) {
category["posts"] = posts; category["posts"] = posts;
@ -200,8 +204,6 @@ var user = require('./../user.js'),
topics:results[1] topics:results[1]
}); });
}); });
}); });
app.get('/api/404', function(req, res) { app.get('/api/404', function(req, res) {

Loading…
Cancel
Save