Skip to content

Node.js based forum software built for the modern web

Merge branch 'master' into categories_revamp

Julian Lama1621145d554
diff --cc public/less/admin/admin.less
index 867434fe46,528c9f7381..57e46db038
--- a/public/less/admin/admin.less
+++ b/public/less/admin/admin.less
@@@ -2,6 -2,8 +2,7 @@@
@import "./mixins";
@import "./general/dashboard";
+ @import "./general/navigation";
-@import "./manage/categories";
@import "./manage/groups";
@import "./manage/tags";
@import "./manage/flags";
diff --cc public/src/admin/manage/categories.js
index fd6658fe9c,52d13874ab..a5f206ec9b
--- a/public/src/admin/manage/categories.js
+++ b/public/src/admin/manage/categories.js
@@@ -56,11 -75,13 +56,13 @@@ define('admin/manage/categories', funct
name: $('#inputName').val(),
description: $('#inputDescription').val(),
icon: $('#new-category-modal i').attr('value'),
- bgColor: '#0059b2',
- color: '#fff',
- order: $('#disabled-categories').children().length + 1
- order: $('.admin-categories #entry-container').children().length + 1
++ order: $('#active-categories').children().length + 1
};
+ saveNew(category);
+ }
+
+ function saveNew(category) {
socket.emit('admin.categories.create', category, function(err, data) {
if(err) {
return app.alertError(err.message);
diff --cc src/controllers/admin.js
index 365d4fa6b8,e0912a668c..77a1ff143b
--- a/src/controllers/admin.js
+++ b/src/controllers/admin.js
@@@ -118,23 -120,22 +120,29 @@@ function getStatsForSet(set, field, cal
}, callback);
}
+ function getGlobalField(field, callback) {
+ db.getObjectField('global', field, function(err, count) {
+ callback(err, parseInt(count, 10) || 0);
+ });
+ }
+
-adminController.categories.active = function(req, res, next) {
- filterAndRenderCategories(req, res, next, true);
-};
+adminController.categories.get = function(req, res, next) {
+ categories.getCategoryData(req.params.category_id, function(err, category) {
+ if (err) {
+ return next(err);
+ }
-adminController.categories.disabled = function(req, res, next) {
- filterAndRenderCategories(req, res, next, false);
+ res.render('admin/manage/category', {
+ category: category
+ });
+ });
};
-function filterAndRenderCategories(req, res, next, active) {
- var uid = req.user ? parseInt(req.user.uid, 10) : 0;
+adminController.categories.getAll = function(req, res, next) {
+ var uid = req.user ? parseInt(req.user.uid, 10) : 0,
+ active = [],
+ disabled = [];
+
categories.getAllCategories(uid, function (err, categoryData) {
if (err) {
return next(err);
diff --cc src/routes/admin.js
index 71c3f138b8,4a7e7ef460..c84758a1cd
--- a/src/routes/admin.js
+++ b/src/routes/admin.js
@@@ -43,9 -42,12 +42,11 @@@ function addRoutes(router, middleware,
router.get('/general/dashboard', controllers.admin.home);
router.get('/general/languages', controllers.admin.languages.get);
router.get('/general/sounds', controllers.admin.sounds.get);
+ router.get('/general/navigation', controllers.admin.navigation.get);
+ router.get('/general/homepage', controllers.admin.homepage.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.getAll);
+ router.get('/manage/categories/:category_id', controllers.admin.categories.get);
router.get('/manage/tags', controllers.admin.tags.get);
diff --cc src/views/admin/manage/categories.tpl
index ebdeaad6bd,8d4367bb2e..d6b0c9c148
--- a/src/views/admin/manage/categories.tpl
+++ b/src/views/admin/manage/categories.tpl
@@@ -1,5 -1,5 +1,5 @@@
-<div class="categories">
- <div class="col-lg-9">
+<div class="row">
- <div class="col-lg-9">
++ <div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-body">
@@@ -47,53 -133,25 +47,53 @@@
</div>
</div>
- <div class="col-lg-9">
- <div class="col-lg-3 acp-sidebar">
++ <div class="col-lg-12">
<div class="panel panel-default">
- <div class="panel-heading">Categories Control Panel</div>
+ <div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-body">
- <button class="btn btn-primary" id="addNew">Create New Category</button>
- <button class="btn btn-default" id="revertChanges">Revert Changes</button>
+ <div class="row">
+ <table class="table table-striped table-hover table-reordering">
+ <thead>
+ <tr>
+ <th></th>
+ <th>Name</th>
+ <th>Description</th>
+ <th class="text-center">Topics</th>
+ <th class="text-center">Posts</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody id="disabled-categories">
+ <!-- BEGIN disabled -->
+ <tr data-cid="{disabled.cid}">
+ <td>
+ <span class="label" style="
+ <!-- IF disabled.backgroundImage -->background-image: url({disabled.backgroundImage});<!-- ENDIF disabled.backgroundImage -->
+ <!-- IF disabled.bgColor -->background-color: {disabled.bgColor};<!-- ENDIF disabled.bgColor -->
+ color: {disabled.color};
+ background-size:cover;
+ ">
+ <i data-name="icon" value="{disabled.icon}" class="fa fa-fw {disabled.icon}"></i>
+ </span>
+ </td>
+ <td>{disabled.name}</td>
+ <td>{disabled.description}</td>
+ <td class="text-center">{disabled.topic_count}</td>
+ <td class="text-center">{disabled.post_count}</td>
+ <td>
+ <div class="btn-group">
+ <a href="./categories/{disabled.cid}" class="btn btn-default btn-xs">Edit</a>
+ <button data-action="toggle" data-disabled="{disabled.disabled}" class="btn btn-default btn-xs">Enable</button>
+ </div>
+ </td>
+ </tr>
+ <!-- END disabled -->
+ </tbody>
+ </table>
+ </div>
</div>
</div>
</div>
<!-- IMPORT admin/partials/categories/new.tpl -->
- </div>
- <!-- IMPORT admin/partials/categories/permissions.tpl -->
- <!-- IMPORT admin/partials/categories/setParent.tpl -->
- <div id="icons" style="display:none;">
- <div class="icon-container">
- <div class="row fa-icons">
- <i class="fa fa-doesnt-exist"></i>
- <!-- IMPORT partials/fontawesome.tpl -->
- </div>
- </div>
- </div>
+ </div>