Skip to content

Commit

Permalink
drag/drop re-ordering fixed in ACP, #2463
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Dec 30, 2014
1 parent 9baaa89 commit 988a502
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 29 deletions.
6 changes: 6 additions & 0 deletions public/less/admin/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
23 changes: 13 additions & 10 deletions public/src/admin/manage/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
3 changes: 2 additions & 1 deletion src/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 6 additions & 2 deletions src/views/admin/manage/categories.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<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>
<th>Name</th>
<th>Description</th>
<th class="text-center">Topics</th>
<th class="text-center">Posts</th>
<th></th>
</tr>
</thead>
<tbody id="entry-container">
Expand All @@ -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>
Expand All @@ -55,14 +57,15 @@
<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>
<th>Name</th>
<th>Description</th>
<th class="text-center">Topics</th>
<th class="text-center">Posts</th>
<th></th>
</tr>
</thead>
<tbody id="entry-container">
Expand All @@ -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>
Expand Down
16 changes: 0 additions & 16 deletions src/views/admin/partials/categories/row.tpl

This file was deleted.

0 comments on commit 988a502

Please sign in to comment.