Skip to content

Node.js based forum software built for the modern web

drag/drop re-ordering fixed in ACP, #2463

Julian Lam6b95b28db724
diff --git a/public/less/admin/admin.less b/public/less/admin/admin.less
index b7bebd8f98..220ea5ff6d 100644
--- a/public/less/admin/admin.less
+++ b/public/less/admin/admin.less
@@ -259,4 +259,10 @@
#taskbar {
display: none; /* not sure why I have to do this, but it only seems to show up on prod */
}
+}
+
+.table-reordering {
+ tr:hover {
+ cursor: move;
+ }
}
\ No newline at end of file
diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js
index 8968549b91..4124cbf423 100644
--- a/public/src/admin/manage/categories.js
+++ b/public/src/admin/manage/categories.js
@@ -40,20 +40,23 @@ define('admin/manage/categories', [
return false;
}
- function updateCategoryOrders() {
- var categories = $('.admin-categories #entry-container').children();
- for(var i = 0; i<categories.length; ++i) {
- var input = $(categories[i]).find('input[data-name="order"]');
-
- input.val(i+1).attr('data-value', i+1);
- modified(input);
+ function updateCategoryOrders(evt, ui) {
+ var categories = $(evt.target).children(),
+ modified = {},
+ cid;
+
+ for(var i=0;i<categories.length;i++) {
+ cid = $(categories[i]).attr('data-cid');
+ modified[cid] = {
+ order: i+1
+ };
}
+
+ socket.emit('admin.categories.update', modified);
}
$('#entry-container').sortable({
- stop: function(event, ui) {
- updateCategoryOrders();
- },
+ stop: updateCategoryOrders,
distance: 10
});
diff --git a/src/controllers/admin.js b/src/controllers/admin.js
index 627614dc4d..e3c0e615a7 100644
--- a/src/controllers/admin.js
+++ b/src/controllers/admin.js
@@ -119,6 +119,10 @@ function getStatsForSet(set, field, callback) {
}
adminController.categories.get = function(req, res, next) {
+
+};
+
+adminController.categories.getAll = function(req, res, next) {
var uid = req.user ? parseInt(req.user.uid, 10) : 0,
active = [],
disabled = [];
diff --git a/src/routes/admin.js b/src/routes/admin.js
index 3c9edaa0f9..71c3f138b8 100644
--- a/src/routes/admin.js
+++ b/src/routes/admin.js
@@ -44,7 +44,8 @@ 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.get);
+ 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 --git a/src/views/admin/manage/categories.tpl b/src/views/admin/manage/categories.tpl
index 5b0c3855e3..0bec4891a7 100644
--- a/src/views/admin/manage/categories.tpl
+++ b/src/views/admin/manage/categories.tpl
@@ -4,7 +4,7 @@
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-body">
<div class="row">
- <table class="table table-striped table-hover">
+ <table class="table table-striped table-hover table-reordering">
<thead>
<tr>
<th></th>
@@ -12,6 +12,7 @@
<th>Description</th>
<th class="text-center">Topics</th>
<th class="text-center">Posts</th>
+ <th></th>
</tr>
</thead>
<tbody id="entry-container">
@@ -31,6 +32,7 @@
<td>{active.description}</td>
<td class="text-center">{active.topic_count}</td>
<td class="text-center">{active.post_count}</td>
+ <td><a href="./categories/{active.cid}" class="btn btn-default btn-block btn-xs">Edit</a></td>
</tr>
<!-- END active -->
</tbody>
@@ -55,7 +57,7 @@
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-body">
<div class="row">
- <table class="table table-striped table-hover">
+ <table class="table table-striped table-hover table-reordering">
<thead>
<tr>
<th></th>
@@ -63,6 +65,7 @@
<th>Description</th>
<th class="text-center">Topics</th>
<th class="text-center">Posts</th>
+ <th></th>
</tr>
</thead>
<tbody id="entry-container">
@@ -82,6 +85,7 @@
<td>{disabled.description}</td>
<td class="text-center">{disabled.topic_count}</td>
<td class="text-center">{disabled.post_count}</td>
+ <td><a href="./categories/{active.cid}" class="btn btn-default btn-block btn-xs">Edit</a></td>
</tr>
<!-- END disabled -->
</tbody>
diff --git a/src/views/admin/partials/categories/row.tpl b/src/views/admin/partials/categories/row.tpl
deleted file mode 100644
index 0e4c15909b..0000000000
--- a/src/views/admin/partials/categories/row.tpl
+++ /dev/null
@@ -1,16 +0,0 @@
- <tr data-cid="{cid}">
- <td>
- <span class="label" style="
- <!-- IF backgroundImage -->background-image: url({backgroundImage});<!-- ENDIF backgroundImage -->
- <!-- IF bgColor -->background-color: {bgColor};<!-- ENDIF bgColor -->
- color: {color};
- background-size:cover;
- ">
- <i data-name="icon" value="{icon}" class="fa fa-fw {icon}"></i>
- </span>
- </td>
- <td>{name}</td>
- <td>{description}</td>
- <td class="text-center">{topic_count}</td>
- <td class="text-center">{post_count}</td>
- </tr>
\ No newline at end of file