mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
ACP setting and API return for subcats
This commit is contained in:
@@ -231,6 +231,30 @@ define('forum/admin/categories', ['uploader', 'forum/admin/iconSelect'], functio
|
||||
});
|
||||
|
||||
setupEditTargets();
|
||||
|
||||
$('button[data-action="setParent"]').on('click', function() {
|
||||
var cid = $(this).parents('[data-cid]').attr('data-cid'),
|
||||
modal = $('#setParent');
|
||||
|
||||
modal.find('select').val($(this).attr('data-parentCid'));
|
||||
modal.attr('data-cid', cid).modal();
|
||||
});
|
||||
$('#setParent [data-cid]').on('click', function() {
|
||||
var modalEl = $('#setParent'),
|
||||
parentCid = $(this).attr('data-cid'),
|
||||
payload = {};
|
||||
|
||||
payload[modalEl.attr('data-cid')] = {
|
||||
parentCid: parentCid
|
||||
};
|
||||
|
||||
socket.emit('admin.categories.update', payload, function(err) {
|
||||
modalEl.one('hidden.bs.modal', function() {
|
||||
ajaxify.go('admin/categories/active');
|
||||
});
|
||||
modalEl.modal('hide');
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -263,7 +263,13 @@ var db = require('./database'),
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getCategoriesData = function(cids, callback) {
|
||||
Categories.getCategoriesData = function(cids, expandParent, callback) {
|
||||
// expandParent is optional, default: true
|
||||
if (typeof expandParent === 'function' && !callback) {
|
||||
callback = expandParent;
|
||||
expandParent = undefined;
|
||||
}
|
||||
|
||||
var keys = cids.map(function(cid) {
|
||||
return 'category:' + cid;
|
||||
});
|
||||
@@ -285,7 +291,18 @@ var db = require('./database'),
|
||||
category.description = validator.escape(category.description);
|
||||
category.backgroundImage = category.image ? nconf.get('relative_path') + category.image : '';
|
||||
category.disabled = category.disabled ? parseInt(category.disabled, 10) !== 0 : false;
|
||||
next(null, category);
|
||||
|
||||
if (expandParent !== false && category.parentCid) {
|
||||
Categories.getCategoriesData([category.parentCid], false, function(err, categories) {
|
||||
if (!err && categories.length) {
|
||||
category.parent = categories[0];
|
||||
}
|
||||
|
||||
next(null, category);
|
||||
});
|
||||
} else {
|
||||
next(null, category);
|
||||
}
|
||||
}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ module.exports = function(Categories) {
|
||||
function updateCategory(cid, next) {
|
||||
var category = modified[cid];
|
||||
var fields = Object.keys(category);
|
||||
console.log('updating', cid, 'fields:', fields);
|
||||
|
||||
async.each(fields, function(key, next) {
|
||||
updateCategoryField(cid, key, category[key], next);
|
||||
|
||||
@@ -8,7 +8,7 @@ var categoriesController = {},
|
||||
user = require('../user'),
|
||||
categories = require('../categories'),
|
||||
topics = require('../topics'),
|
||||
meta = require('../meta');
|
||||
meta = require('../meta'),
|
||||
plugins = require('../plugins');
|
||||
|
||||
categoriesController.recent = function(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user