mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 07:40:43 +01:00
closes #5715
This commit is contained in:
@@ -26,11 +26,15 @@ define('admin/manage/category', [
|
||||
}
|
||||
}
|
||||
|
||||
$('.blockclass, form.category select').each(function () {
|
||||
$('#category-settings select').each(function () {
|
||||
var $this = $(this);
|
||||
$this.val($this.attr('data-value'));
|
||||
});
|
||||
|
||||
$('#category-selector').on('change', function () {
|
||||
ajaxify.go('admin/manage/categories/' + $(this).val());
|
||||
});
|
||||
|
||||
function enableColorPicker(idx, inputEl) {
|
||||
var $inputEl = $(inputEl);
|
||||
var previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
||||
@@ -47,7 +51,7 @@ define('admin/manage/category', [
|
||||
}
|
||||
|
||||
|
||||
$('form.category input, form.category select').not($('.privilege-table-container input'))
|
||||
$('#category-settings input, #category-settings select').not($('.privilege-table-container input'))
|
||||
.on('change', function (ev) {
|
||||
modified(ev.target);
|
||||
})
|
||||
|
||||
@@ -329,22 +329,23 @@ Categories.buildForSelect = function (uid, callback) {
|
||||
recursive(child, categoriesData, ' ' + level);
|
||||
});
|
||||
}
|
||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', function (err, categories) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', next);
|
||||
},
|
||||
function (categories, next) {
|
||||
var categoriesData = [];
|
||||
|
||||
var categoriesData = [];
|
||||
categories = categories.filter(function (category) {
|
||||
return category && !category.link && !parseInt(category.parentCid, 10);
|
||||
});
|
||||
|
||||
categories = categories.filter(function (category) {
|
||||
return category && !category.link && !parseInt(category.parentCid, 10);
|
||||
});
|
||||
|
||||
categories.forEach(function (category) {
|
||||
recursive(category, categoriesData, '');
|
||||
});
|
||||
callback(null, categoriesData);
|
||||
});
|
||||
categories.forEach(function (category) {
|
||||
recursive(category, categoriesData, '');
|
||||
});
|
||||
next(null, categoriesData);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
Categories.getIgnorers = function (cid, start, stop, callback) {
|
||||
|
||||
@@ -8,34 +8,47 @@ var analytics = require('../../analytics');
|
||||
var plugins = require('../../plugins');
|
||||
var translator = require('../../translator');
|
||||
|
||||
var categoriesController = module.exports;
|
||||
|
||||
var categoriesController = {};
|
||||
categoriesController.get = function (req, res, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
category: async.apply(categories.getCategories, [req.params.category_id], req.user.uid),
|
||||
privileges: async.apply(privileges.categories.list, req.params.category_id),
|
||||
allCategories: async.apply(categories.buildForSelect, req.uid),
|
||||
}, next);
|
||||
},
|
||||
function (data, next) {
|
||||
var category = data.category[0];
|
||||
|
||||
categoriesController.get = function (req, res, next) {
|
||||
async.parallel({
|
||||
category: async.apply(categories.getCategories, [req.params.category_id], req.user.uid),
|
||||
privileges: async.apply(privileges.categories.list, req.params.category_id),
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var category = data.category[0];
|
||||
|
||||
if (!category) {
|
||||
return next();
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:admin.category.get', { req: req, res: res, category: category, privileges: data.privileges }, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
if (!category) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
data.allCategories.forEach(function (category) {
|
||||
if (category) {
|
||||
category.selected = parseInt(category.cid, 10) === parseInt(req.params.category_id, 10);
|
||||
}
|
||||
});
|
||||
|
||||
plugins.fireHook('filter:admin.category.get', {
|
||||
req: req,
|
||||
res: res,
|
||||
category: category,
|
||||
privileges: data.privileges,
|
||||
allCategories: data.allCategories,
|
||||
}, next);
|
||||
},
|
||||
function (data) {
|
||||
data.category.name = translator.escape(String(data.category.name));
|
||||
res.render('admin/manage/category', {
|
||||
category: data.category,
|
||||
privileges: data.privileges,
|
||||
allCategories: data.allCategories,
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
categoriesController.getAll = function (req, res) {
|
||||
@@ -44,17 +57,15 @@ categoriesController.getAll = function (req, res) {
|
||||
};
|
||||
|
||||
categoriesController.getAnalytics = function (req, res, next) {
|
||||
async.parallel({
|
||||
name: async.apply(categories.getCategoryField, req.params.category_id, 'name'),
|
||||
analytics: async.apply(analytics.getCategoryAnalytics, req.params.category_id),
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
res.render('admin/manage/category-analytics', data);
|
||||
});
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
name: async.apply(categories.getCategoryField, req.params.category_id, 'name'),
|
||||
analytics: async.apply(analytics.getCategoryAnalytics, req.params.category_id),
|
||||
}, next);
|
||||
},
|
||||
function (data) {
|
||||
res.render('admin/manage/category-analytics', data);
|
||||
},
|
||||
], next);
|
||||
};
|
||||
|
||||
|
||||
module.exports = categoriesController;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
<div class="row">
|
||||
|
||||
<form role="form" class="category" data-cid="{category.cid}">
|
||||
<select id="category-selector" class="form-control">
|
||||
<!-- BEGIN allCategories -->
|
||||
<option value="{allCategories.value}" <!-- IF allCategories.selected -->selected<!-- ENDIF allCategories.selected -->>{allCategories.text}</option>
|
||||
<!-- END allCategories -->
|
||||
</select>
|
||||
<br/>
|
||||
<ul class="nav nav-pills">
|
||||
<li class="active"><a href="#category-settings" data-toggle="tab">
|
||||
[[admin/manage/categories:settings]]
|
||||
@@ -100,14 +107,14 @@
|
||||
<div class="btn-group btn-group-justified">
|
||||
<div class="btn-group">
|
||||
<button type="button" data-cid="{category.cid}" class="btn btn-default upload-button">
|
||||
<i class="fa fa-upload"></i>
|
||||
<i class="fa fa-upload"></i>
|
||||
[[admin/manage/categories:upload-image]]
|
||||
</button>
|
||||
</div>
|
||||
<!-- IF category.image -->
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-warning delete-image">
|
||||
<i data-name="icon" value="fa-times" class="fa fa-times"></i>
|
||||
<i data-name="icon" value="fa-times" class="fa fa-times"></i>
|
||||
[[admin/manage/categories:delete-image]]
|
||||
</button>
|
||||
</div>
|
||||
@@ -133,7 +140,7 @@
|
||||
<button type="button" class="btn btn-warning" data-action="removeParent" data-parentCid="{category.parent.cid}"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
<button type="button" class="btn btn-default btn-block <!-- IF category.parent.name -->hide<!-- ENDIF category.parent.name -->" data-action="setParent">
|
||||
<i class="fa fa-sitemap"></i>
|
||||
<i class="fa fa-sitemap"></i>
|
||||
[[admin/manage/categories:parent-category-none]]
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user