mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 12:01:17 +01:00
feat: #7023
- add category selector to privileges and category create modals - allow category selector to work for multiple selectors on same page
This commit is contained in:
@@ -19,7 +19,7 @@ privilegesController.get = function (req, res, callback) {
|
||||
privileges.categories.list(cid, next);
|
||||
}
|
||||
},
|
||||
allCategories: function (next) {
|
||||
categories: function (next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
categories.getAllCidsFromSet('categories:cid', next);
|
||||
@@ -36,7 +36,12 @@ privilegesController.get = function (req, res, callback) {
|
||||
}, next);
|
||||
},
|
||||
function (data) {
|
||||
data.allCategories.forEach(function (category) {
|
||||
data.categories.unshift({
|
||||
cid: 0,
|
||||
name: '[[admin/manage/privileges:global]]',
|
||||
icon: 'fa-list',
|
||||
});
|
||||
data.categories.forEach(function (category) {
|
||||
if (category) {
|
||||
category.selected = category.cid === cid;
|
||||
|
||||
@@ -48,8 +53,8 @@ privilegesController.get = function (req, res, callback) {
|
||||
|
||||
res.render('admin/manage/privileges', {
|
||||
privileges: data.privileges,
|
||||
allCategories: data.allCategories,
|
||||
selected: data.selected ? data.selected.name : '[[admin/manage/privileges:global]]',
|
||||
categories: data.categories,
|
||||
selectedCategory: data.selected,
|
||||
cid: cid,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@ SocketCategories.get = function (socket, data, callback) {
|
||||
isAdmin: async.apply(user.isAdministrator, socket.uid),
|
||||
categories: function (next) {
|
||||
async.waterfall([
|
||||
async.apply(categories.getAllCidsFromSet, 'categories:cid'),
|
||||
async.apply(categories.getCidsByPrivilege, 'categories:cid', socket.uid, 'find'),
|
||||
async.apply(categories.getCategoriesData),
|
||||
], next);
|
||||
},
|
||||
@@ -132,23 +132,16 @@ SocketCategories.getCategoriesByPrivilege = function (socket, privilege, callbac
|
||||
};
|
||||
|
||||
SocketCategories.getMoveCategories = function (socket, data, callback) {
|
||||
SocketCategories.getSelectCategories(socket, data, callback);
|
||||
};
|
||||
|
||||
SocketCategories.getSelectCategories = function (socket, data, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
isAdmin: async.apply(user.isAdministrator, socket.uid),
|
||||
categories: function (next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
categories.getAllCidsFromSet('categories:cid', next);
|
||||
},
|
||||
function (cids, next) {
|
||||
categories.getCategories(cids, socket.uid, next);
|
||||
},
|
||||
function (categoriesData, next) {
|
||||
categoriesData = categories.getTree(categoriesData);
|
||||
categories.buildForSelectCategories(categoriesData, next);
|
||||
},
|
||||
], next);
|
||||
categories.buildForSelect(socket.uid, 'find', next);
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
|
||||
@@ -5,19 +5,10 @@
|
||||
[[admin/manage/categories:privileges.description]]
|
||||
</p>
|
||||
|
||||
<p class="lead">
|
||||
<div class="lead">
|
||||
[[admin/manage/categories:privileges.category-selector]]
|
||||
<button type="button" id="category-selector" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
|
||||
{selected} <i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
|
||||
<ul class="mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect" for="category-selector">
|
||||
<li class="mdl-menu__item mdl-menu__item--full-bleed-divider" data-cid="global">[[admin/manage/privileges:global]]</li>
|
||||
<!-- BEGIN allCategories -->
|
||||
<li class="mdl-menu__item" data-cid="{../value}">{../text}</li>
|
||||
<!-- END -->
|
||||
</ul>
|
||||
</p>
|
||||
<!-- IMPORT partials/category-selector.tpl -->
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
|
||||
@@ -3,24 +3,14 @@
|
||||
<label for="name">[[admin/manage/categories:name]]</label>
|
||||
<input type="text" class="form-control" name="name" id="name" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group" id="parentCidGroup">
|
||||
<label for="parentCid">[[admin/manage/categories:optional-parent-category]]</label>
|
||||
<select class="form-control" name="parentCid" id="parentCid">
|
||||
<option value=""></option>
|
||||
<!-- BEGIN categories -->
|
||||
<option value="{categories.cid}">{categories.name}</option>
|
||||
<!-- END categories -->
|
||||
</select>
|
||||
<!-- IMPORT partials/category-selector.tpl -->
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group" id="cloneFromCidGroup">
|
||||
<label for="cloneFromCid">[[admin/manage/categories:optional-clone-settings]]</label>
|
||||
<select class="form-control" name="cloneFromCid" id="cloneFromCid">
|
||||
<option value=""></option>
|
||||
<!-- BEGIN categories -->
|
||||
<option value="{categories.cid}">{categories.name}</option>
|
||||
<!-- END categories -->
|
||||
</select>
|
||||
<!-- IMPORT partials/category-selector.tpl -->
|
||||
<label>
|
||||
<input id="cloneChildren" name="cloneChildren" type="checkbox">
|
||||
<strong>[[admin/manage/categories:clone-children]]</strong>
|
||||
|
||||
Reference in New Issue
Block a user