move privileges to same page

This commit is contained in:
Baris Usakli
2017-12-20 14:49:20 -05:00
parent 63b9255fa1
commit 242dc41aca
12 changed files with 235 additions and 475 deletions

View File

@@ -8,17 +8,32 @@ var privileges = require('../../privileges');
var privilegesController = module.exports;
privilegesController.get = function (req, res, callback) {
var cid = req.params.cid ? req.params.cid : 0;
async.waterfall([
function (next) {
async.parallel({
privileges: async.apply(privileges.global.list),
privileges: function (next) {
if (!cid) {
privileges.global.list(next);
} else {
privileges.categories.list(cid, next);
}
},
allCategories: async.apply(categories.buildForSelect, req.uid, 'read'),
}, next);
},
function (data) {
data.allCategories.forEach(function (category) {
if (category) {
category.selected = parseInt(category.cid, 10) === parseInt(cid, 10);
}
});
res.render('admin/manage/privileges', {
privileges: data.privileges,
allCategories: data.allCategories,
cid: cid,
});
},
], callback);