- 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:
Barış Soner Uşaklı
2018-12-04 14:32:43 -05:00
parent 89acb89659
commit f581c052ee
8 changed files with 82 additions and 78 deletions

View File

@@ -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,
});
},