mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +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);
|
var $this = $(this);
|
||||||
$this.val($this.attr('data-value'));
|
$this.val($this.attr('data-value'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#category-selector').on('change', function () {
|
||||||
|
ajaxify.go('admin/manage/categories/' + $(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
function enableColorPicker(idx, inputEl) {
|
function enableColorPicker(idx, inputEl) {
|
||||||
var $inputEl = $(inputEl);
|
var $inputEl = $(inputEl);
|
||||||
var previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
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) {
|
.on('change', function (ev) {
|
||||||
modified(ev.target);
|
modified(ev.target);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -329,22 +329,23 @@ Categories.buildForSelect = function (uid, callback) {
|
|||||||
recursive(child, categoriesData, ' ' + level);
|
recursive(child, categoriesData, ' ' + level);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', function (err, categories) {
|
async.waterfall([
|
||||||
if (err) {
|
function (next) {
|
||||||
return callback(err);
|
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) {
|
categories.forEach(function (category) {
|
||||||
return category && !category.link && !parseInt(category.parentCid, 10);
|
recursive(category, categoriesData, '');
|
||||||
});
|
});
|
||||||
|
next(null, categoriesData);
|
||||||
categories.forEach(function (category) {
|
},
|
||||||
recursive(category, categoriesData, '');
|
], callback);
|
||||||
});
|
|
||||||
callback(null, categoriesData);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Categories.getIgnorers = function (cid, start, stop, callback) {
|
Categories.getIgnorers = function (cid, start, stop, callback) {
|
||||||
|
|||||||
@@ -8,34 +8,47 @@ var analytics = require('../../analytics');
|
|||||||
var plugins = require('../../plugins');
|
var plugins = require('../../plugins');
|
||||||
var translator = require('../../translator');
|
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) {
|
if (!category) {
|
||||||
async.parallel({
|
return callback();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
data.category.name = translator.escape(String(data.category.name));
|
||||||
res.render('admin/manage/category', {
|
res.render('admin/manage/category', {
|
||||||
category: data.category,
|
category: data.category,
|
||||||
privileges: data.privileges,
|
privileges: data.privileges,
|
||||||
|
allCategories: data.allCategories,
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
});
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
categoriesController.getAll = function (req, res) {
|
categoriesController.getAll = function (req, res) {
|
||||||
@@ -44,17 +57,15 @@ categoriesController.getAll = function (req, res) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
categoriesController.getAnalytics = function (req, res, next) {
|
categoriesController.getAnalytics = function (req, res, next) {
|
||||||
async.parallel({
|
async.waterfall([
|
||||||
name: async.apply(categories.getCategoryField, req.params.category_id, 'name'),
|
function (next) {
|
||||||
analytics: async.apply(analytics.getCategoryAnalytics, req.params.category_id),
|
async.parallel({
|
||||||
}, function (err, data) {
|
name: async.apply(categories.getCategoryField, req.params.category_id, 'name'),
|
||||||
if (err) {
|
analytics: async.apply(analytics.getCategoryAnalytics, req.params.category_id),
|
||||||
return next(err);
|
}, next);
|
||||||
}
|
},
|
||||||
|
function (data) {
|
||||||
res.render('admin/manage/category-analytics', data);
|
res.render('admin/manage/category-analytics', data);
|
||||||
});
|
},
|
||||||
|
], next);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
module.exports = categoriesController;
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<form role="form" class="category" data-cid="{category.cid}">
|
<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">
|
<ul class="nav nav-pills">
|
||||||
<li class="active"><a href="#category-settings" data-toggle="tab">
|
<li class="active"><a href="#category-settings" data-toggle="tab">
|
||||||
[[admin/manage/categories:settings]]
|
[[admin/manage/categories:settings]]
|
||||||
@@ -100,14 +107,14 @@
|
|||||||
<div class="btn-group btn-group-justified">
|
<div class="btn-group btn-group-justified">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button type="button" data-cid="{category.cid}" class="btn btn-default upload-button">
|
<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]]
|
[[admin/manage/categories:upload-image]]
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<!-- IF category.image -->
|
<!-- IF category.image -->
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn btn-warning delete-image">
|
<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]]
|
[[admin/manage/categories:delete-image]]
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
<button type="button" class="btn btn-warning" data-action="removeParent" data-parentCid="{category.parent.cid}"><i class="fa fa-times"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-default btn-block <!-- IF category.parent.name -->hide<!-- ENDIF category.parent.name -->" data-action="setParent">
|
<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]]
|
[[admin/manage/categories:parent-category-none]]
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user