mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-08 12:23:35 +02:00
changed a bunch of whitespace back into tabs, and fixed issue where categories without a parentCid were not showing up at all in the ACP
This commit is contained in:
@@ -11,7 +11,9 @@ div.categories {
|
||||
}
|
||||
}
|
||||
|
||||
.fa-ul {
|
||||
.stats {
|
||||
display: inline-block;
|
||||
|
||||
li {
|
||||
min-height: 0;
|
||||
display: inline;
|
||||
@@ -66,8 +68,4 @@ div.categories {
|
||||
.description {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.stats, .btn-group {
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,11 @@
|
||||
/*global define, socket, app, bootbox, templates, ajaxify, RELATIVE_PATH, Sortable */
|
||||
|
||||
define('admin/manage/categories', function() {
|
||||
var Categories = {}, newCategoryId = -1, sortables, itemTemplate;
|
||||
var Categories = {}, newCategoryId = -1, sortables;
|
||||
|
||||
Categories.init = function() {
|
||||
socket.emit('admin.categories.getAll', function(error, payload){
|
||||
console.log(payload);
|
||||
if(error){
|
||||
return app.alertError(error.message);
|
||||
}
|
||||
@@ -55,17 +56,17 @@ define('admin/manage/categories', function() {
|
||||
};
|
||||
|
||||
Categories.render = function(categories){
|
||||
var container = $('.categories');
|
||||
var container = $('.categories');
|
||||
|
||||
if(!categories || categories.length == 0){
|
||||
$('<div></div>')
|
||||
.addClass('alert alert-info text-center')
|
||||
.text('You have no active categories.')
|
||||
.appendTo(container);
|
||||
}else{
|
||||
sortables = {};
|
||||
renderList(categories, container, 0);
|
||||
}
|
||||
if (!categories || categories.length == 0) {
|
||||
$('<div></div>')
|
||||
.addClass('alert alert-info text-center')
|
||||
.text('You have no active categories.')
|
||||
.appendTo(container);
|
||||
} else {
|
||||
sortables = {};
|
||||
renderList(categories, container, 0);
|
||||
}
|
||||
};
|
||||
|
||||
Categories.toggle = function(cid, state) {
|
||||
@@ -85,40 +86,40 @@ define('admin/manage/categories', function() {
|
||||
}
|
||||
|
||||
function itemDidAdd(e){
|
||||
newCategoryId = e.to.dataset.cid;
|
||||
newCategoryId = e.to.dataset.cid;
|
||||
}
|
||||
|
||||
function itemDragDidEnd(e){
|
||||
var isCategoryUpdate = (newCategoryId != -1);
|
||||
var isCategoryUpdate = (newCategoryId != -1);
|
||||
//Update needed?
|
||||
if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate){
|
||||
var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid],
|
||||
modified = {}, i = 0, list = parentCategory.toArray(), len = list.length;
|
||||
var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid],
|
||||
modified = {}, i = 0, list = parentCategory.toArray(), len = list.length;
|
||||
|
||||
for(i; i < len; ++i) {
|
||||
modified[list[i]] = {
|
||||
order: (i + 1)
|
||||
}
|
||||
}
|
||||
for(i; i < len; ++i) {
|
||||
modified[list[i]] = {
|
||||
order: (i + 1)
|
||||
}
|
||||
}
|
||||
|
||||
if(isCategoryUpdate){
|
||||
modified[e.item.dataset.cid]['parentCid'] = newCategoryId;
|
||||
}
|
||||
if(isCategoryUpdate){
|
||||
modified[e.item.dataset.cid]['parentCid'] = newCategoryId;
|
||||
}
|
||||
|
||||
newCategoryId = -1
|
||||
socket.emit('admin.categories.update', modified);
|
||||
}
|
||||
newCategoryId = -1
|
||||
socket.emit('admin.categories.update', modified);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render categories - recursively
|
||||
*
|
||||
* @param categories {array} categories tree
|
||||
* @param level {number} current sub-level of rendering
|
||||
* @param container {object} parent jquery element for the list
|
||||
* @param parentId {number} parent category identifier
|
||||
*/
|
||||
function renderList(categories, container, parentId){
|
||||
/**
|
||||
* Render categories - recursively
|
||||
*
|
||||
* @param categories {array} categories tree
|
||||
* @param level {number} current sub-level of rendering
|
||||
* @param container {object} parent jquery element for the list
|
||||
* @param parentId {number} parent category identifier
|
||||
*/
|
||||
function renderList(categories, container, parentId){
|
||||
templates.parse('admin/partials/categories/category-rows', {
|
||||
cid: parentId,
|
||||
categories: categories
|
||||
@@ -137,13 +138,13 @@ define('admin/manage/categories', function() {
|
||||
group: 'cross-categories',
|
||||
animation: 150,
|
||||
handle: '.icon',
|
||||
dataIdAttr: 'data-cid',
|
||||
dataIdAttr: 'data-cid',
|
||||
ghostClass: "placeholder",
|
||||
onAdd: itemDidAdd,
|
||||
onEnd: itemDragDidEnd
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Categories;
|
||||
});
|
||||
@@ -319,16 +319,19 @@ var async = require('async'),
|
||||
Categories.getTree = function(categories, parentCid) {
|
||||
var tree = [], i = 0, len = categories.length, category;
|
||||
|
||||
for(i; i < len; ++i){
|
||||
category = categories[i];
|
||||
for(i; i < len; ++i) {
|
||||
category = categories[i];
|
||||
if (!category.hasOwnProperty('parentCid')) {
|
||||
category.parentCid = 0;
|
||||
}
|
||||
|
||||
if(category.parentCid == parentCid){
|
||||
tree.push(category);
|
||||
category.children = Categories.getTree(categories, category.cid);
|
||||
}
|
||||
}
|
||||
if(category.parentCid == parentCid){
|
||||
tree.push(category);
|
||||
category.children = Categories.getTree(categories, category.cid);
|
||||
}
|
||||
}
|
||||
|
||||
return tree;
|
||||
return tree;
|
||||
};
|
||||
|
||||
}(exports));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- BEGIN categories -->
|
||||
<li data-cid="{categories.cid}" <!-- IF categories.disabled -->class="disabled"<!-- ENDIF categories.disabled -->>
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-8">
|
||||
<div class="clearfix">
|
||||
<div class="icon" style="color: {categories.color}; background-color: {categories.bgColor};<!-- IF categories.backgroundImage --> background-image: url('{categories.backgroundImage}');<!-- ENDIF categories.backgroundImage -->">
|
||||
<i data-name="icon" value="{categories.icon}" class="fa {categories.icon}"></i>
|
||||
@@ -13,11 +13,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="clearfix pull-right">
|
||||
<ul class="fa-ul stats">
|
||||
<li class="fa-li"><i class="fa fa-book"></i> {categories.topic_count}</li>
|
||||
<li class="fa-li"><i class="fa fa-pencil"></i> {categories.post_count}</li>
|
||||
<div class="col-md-4">
|
||||
<div class="clearfix pull-right text-right">
|
||||
<ul class="stats">
|
||||
<li><i class="fa fa-book"></i> {categories.topic_count}</li>
|
||||
<li><i class="fa fa-pencil"></i> {categories.post_count}</li>
|
||||
</ul>
|
||||
<div class="btn-group">
|
||||
<button data-action="toggle" data-disabled="{categories.disabled}" class="btn btn-xs <!-- IF categories.disabled -->btn-primary<!-- ELSE -->btn-danger<!-- ENDIF categories.disabled -->">
|
||||
|
||||
Reference in New Issue
Block a user