Skip to content

Commit

Permalink
revamping categories management page in ACP, #2463
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Dec 29, 2014
1 parent e0edb71 commit 42e6c93
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 283 deletions.
1 change: 0 additions & 1 deletion public/less/admin/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
@import "./mixins";

@import "./general/dashboard";
@import "./manage/categories";
@import "./manage/groups";
@import "./manage/tags";
@import "./manage/flags";
Expand Down
133 changes: 0 additions & 133 deletions public/less/admin/manage/categories.less

This file was deleted.

4 changes: 0 additions & 4 deletions public/src/admin/manage/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ define('admin/manage/categories', [
return false;
}

function update_blockclass(el) {
el.parentNode.parentNode.className = 'entry-row ' + el.value;
}

function updateCategoryOrders() {
var categories = $('.admin-categories #entry-container').children();
for(var i = 0; i<categories.length; ++i) {
Expand Down
25 changes: 9 additions & 16 deletions src/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,26 @@ function getStatsForSet(set, field, callback) {
}, callback);
}

adminController.categories.active = function(req, res, next) {
filterAndRenderCategories(req, res, next, true);
};

adminController.categories.disabled = function(req, res, next) {
filterAndRenderCategories(req, res, next, false);
};
adminController.categories.get = function(req, res, next) {
var uid = req.user ? parseInt(req.user.uid, 10) : 0,
active = [],
disabled = [];

function filterAndRenderCategories(req, res, next, active) {
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
categories.getAllCategories(uid, function (err, categoryData) {
if (err) {
return next(err);
}

categoryData = categoryData.filter(function (category) {
if (!category) {
return false;
}
return active ? !category.disabled : category.disabled;
categoryData.filter(Boolean).forEach(function(category) {
(category.disabled ? disabled : active).push(category);
});

res.render('admin/manage/categories', {
categories: categoryData
active: active,
disabled: disabled
});
});
}
};

adminController.tags.get = function(req, res, next) {
topics.getTags(0, 199, function(err, tags) {
Expand Down
4 changes: 1 addition & 3 deletions src/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function addRoutes(router, middleware, controllers) {
router.get('/general/languages', controllers.admin.languages.get);
router.get('/general/sounds', controllers.admin.sounds.get);

router.get('/manage/categories', controllers.admin.categories.active);
router.get('/manage/categories/active', controllers.admin.categories.active);
router.get('/manage/categories/disabled', controllers.admin.categories.disabled);
router.get('/manage/categories', controllers.admin.categories.get);

router.get('/manage/tags', controllers.admin.tags.get);

Expand Down

0 comments on commit 42e6c93

Please sign in to comment.