diff --git a/public/css/admin.less b/public/css/admin.less
index cd322ba809..c56eeb74ce 100644
--- a/public/css/admin.less
+++ b/public/css/admin.less
@@ -6,15 +6,6 @@
margin-bottom: 10px;
padding: 10px;
cursor: move;
- width: 800px;
- }
-
- .entry-row {
- border-radius: 10px;
- margin-bottom: 10px;
- padding: 10px;
- cursor: move;
- width: 695px;
}
input.description {
diff --git a/public/src/forum/admin/categories.js b/public/src/forum/admin/categories.js
index f8e0ce65ab..b7f77c8dbb 100644
--- a/public/src/forum/admin/categories.js
+++ b/public/src/forum/admin/categories.js
@@ -74,6 +74,30 @@ jQuery('.blockclass').each(function() {
jQuery('.category_name, .category_description, .blockclass').on('change', function(ev) {
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;
+ });
+
});
}());
\ No newline at end of file
diff --git a/public/templates/admin/categories.tpl b/public/templates/admin/categories.tpl
index fac56816a2..06366a5bb3 100644
--- a/public/templates/admin/categories.tpl
+++ b/public/templates/admin/categories.tpl
@@ -27,6 +27,7 @@
+
diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl
index b6b4b7c299..381cde4a25 100644
--- a/public/templates/admin/header.tpl
+++ b/public/templates/admin/header.tpl
@@ -70,7 +70,7 @@
- Home
- - Categories
+ - Categories
- Users
- Topics
- Themes
diff --git a/src/admin/categories.js b/src/admin/categories.js
index 21d13aacac..c48fdc1a41 100644
--- a/src/admin/categories.js
+++ b/src/admin/categories.js
@@ -18,7 +18,8 @@ var RDB = require('./../redis.js'),
icon: data.icon,
blockclass: data.blockclass,
slug: slug,
- topic_count: 0
+ topic_count: 0,
+ disabled: 0
});
RDB.set('categoryslug:' + slug + ':cid', cid);
diff --git a/src/routes/admin.js b/src/routes/admin.js
index da9e92af71..75afd05c66 100644
--- a/src/routes/admin.js
+++ b/src/routes/admin.js
@@ -25,7 +25,7 @@ var user = require('./../user.js'),
(function() {
var routes = [
- 'categories', 'users', 'topics', 'settings', 'themes',
+ 'categories/active', 'categories/disabled', 'users', 'topics', 'settings', 'themes',
'twitter', 'facebook', 'gplus', 'redis', 'motd',
'users/latest', 'users/sort-posts', 'users/sort-reputation',
'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) {
- 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) {
diff --git a/src/routes/api.js b/src/routes/api.js
index 4e8182d4a6..246265b1f9 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -17,7 +17,11 @@ var user = require('./../user.js'),
app.get('/api/home', function(req, res) {
var uid = (req.user) ? req.user.uid : 0;
categories.getAllCategories(function(data) {
-
+
+ data.categories = data.categories.filter(function(category) {
+ return (!category.disabled || category.disabled === "0");
+ });
+
function iterator(category, callback) {
categories.getRecentReplies(category.cid, 2, function(posts) {
category["posts"] = posts;
@@ -200,8 +204,6 @@ var user = require('./../user.js'),
topics:results[1]
});
});
-
-
});
app.get('/api/404', function(req, res) {