diff --git a/public/less/admin/admin.less b/public/less/admin/admin.less
index 0e35f3a6df..61462cef49 100644
--- a/public/less/admin/admin.less
+++ b/public/less/admin/admin.less
@@ -296,6 +296,17 @@
}
}
+.category-settings-form {
+ h3 {
+ margin-top: 0;
+ .pointer;
+ }
+
+ h4 {
+ .pointer;
+ }
+}
+
.category-preview {
width: 100%;
height: 100px;
diff --git a/public/less/generics.less b/public/less/generics.less
new file mode 100644
index 0000000000..e44d5f0d72
--- /dev/null
+++ b/public/less/generics.less
@@ -0,0 +1,16 @@
+.category-list {
+ padding: 0;
+
+ li {
+ .inline-block;
+ .pointer;
+ padding: 0.5em;
+ margin: 0.25em;
+ .border-radius(3px);
+
+ &.disabled {
+ -webkit-filter: grayscale(30%);
+ .opacity(0.5);
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/src/admin/manage/category.js b/public/src/admin/manage/category.js
index c0344604e8..8a77c8747e 100644
--- a/public/src/admin/manage/category.js
+++ b/public/src/admin/manage/category.js
@@ -126,6 +126,23 @@ define('admin/manage/category', [
iconSelect.init($(this).find('i'), modified);
});
+ // Parent Category Selector
+ $('button[data-action="setParent"]').on('click', Category.launchParentSelector);
+ $('button[data-action="removeParent"]').on('click', function() {
+ var payload= {};
+ payload[ajaxify.variables.get('cid')] = {
+ parentCid: 0
+ };
+
+ socket.emit('admin.categories.update', payload, function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+ ajaxify.refresh();
+ });
+ });
+
+ setupEditTargets();
Category.setupPrivilegeTable();
$(function() {
@@ -152,169 +169,12 @@ define('admin/manage/category', [
// $(this).addClass('hide').hide();
// });
- setupEditTargets();
-
- // $('button[data-action="setParent"]').on('click', function() {
- // var cid = $(this).parents('[data-cid]').attr('data-cid'),
- // modal = $('#setParent');
-
- // modal.find('select').val($(this).attr('data-parentCid'));
- // modal.attr('data-cid', cid).modal();
- // });
+
- // $('button[data-action="removeParent"]').on('click', function() {
- // var cid = $(this).parents('[data-cid]').attr('data-cid');
- // var payload= {};
- // payload[cid] = {
- // parentCid: 0
- // };
- // socket.emit('admin.categories.update', payload, function(err) {
- // if (err) {
- // return app.alertError(err.message);
- // }
- // ajaxify.go('admin/manage/categories/active');
- // });
- // });
- // $('#setParent [data-cid]').on('click', function() {
- // var modalEl = $('#setParent'),
- // parentCid = $(this).attr('data-cid'),
- // payload = {};
-
- // payload[modalEl.attr('data-cid')] = {
- // parentCid: parentCid
- // };
-
- // socket.emit('admin.categories.update', payload, function(err) {
- // modalEl.one('hidden.bs.modal', function() {
- // ajaxify.go('admin/manage/categories/active');
- // });
- // modalEl.modal('hide');
- // });
- // });
});
};
- // Category.launchPermissionsModal = function(cid) {
- // var modal = $('#category-permissions-modal'),
- // searchEl = modal.find('#permission-search'),
- // resultsEl = modal.find('.search-results.users'),
- // groupsResultsEl = modal.find('.search-results.groups'),
- // searchDelay;
-
- // // Clear the search field and results
- // searchEl.val('');
- // resultsEl.html('');
-
- // searchEl.off().on('keyup', function() {
- // var searchEl = this,
- // liEl;
-
- // clearTimeout(searchDelay);
-
- // searchDelay = setTimeout(function() {
- // socket.emit('admin.categories.search', {
- // username: searchEl.value,
- // cid: cid
- // }, function(err, results) {
- // if(err) {
- // return app.alertError(err.message);
- // }
-
- // templates.parse('admin/partials/categories/users', {
- // users: results
- // }, function(html) {
- // resultsEl.html(html);
- // });
- // });
- // }, 250);
- // });
-
- // Category.refreshPrivilegeList(cid);
-
- // resultsEl.off().on('click', '[data-priv]', function(e) {
- // var anchorEl = $(this),
- // uid = anchorEl.parents('li[data-uid]').attr('data-uid'),
- // privilege = anchorEl.attr('data-priv');
- // e.preventDefault();
- // e.stopPropagation();
-
- // socket.emit('admin.categories.setPrivilege', {
- // cid: cid,
- // uid: uid,
- // privilege: privilege,
- // set: !anchorEl.hasClass('active')
- // }, function(err) {
- // if (err) {
- // return app.alertError(err.message);
- // }
- // anchorEl.toggleClass('active', !anchorEl.hasClass('active'));
- // Category.refreshPrivilegeList(cid);
- // });
- // });
-
- // modal.off().on('click', '.members li > img', function() {
- // searchEl.val($(this).attr('title'));
- // searchEl.keyup();
- // });
-
- // // User Groups and privileges
- // socket.emit('admin.categories.groupsList', cid, function(err, results) {
- // if(err) {
- // return app.alertError(err.message);
- // }
-
- // templates.parse('admin/partials/categories/groups', {
- // groups: results
- // }, function(html) {
- // groupsResultsEl.html(html);
- // });
- // });
-
- // groupsResultsEl.off().on('click', '[data-priv]', function(e) {
- // var anchorEl = $(this),
- // name = anchorEl.parents('li[data-name]').attr('data-name'),
- // privilege = anchorEl.attr('data-priv');
- // e.preventDefault();
- // e.stopPropagation();
-
- // socket.emit('admin.categories.setGroupPrivilege', {
- // cid: cid,
- // name: name,
- // privilege: privilege,
- // set: !anchorEl.hasClass('active')
- // }, function(err) {
- // if (!err) {
- // anchorEl.toggleClass('active');
- // }
- // });
- // });
-
- // modal.modal();
- // };
-
- // Category.refreshPrivilegeList = function (cid) {
- // var modalEl = $('#category-permissions-modal'),
- // memberList = $('.members');
-
- // socket.emit('admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
- // var membersLength = privilegeList.length,
- // liEl, x, userObj;
-
- // memberList.html('');
- // if (membersLength > 0) {
- // for(x = 0; x < membersLength; x++) {
- // userObj = privilegeList[x];
- // liEl = $('
').attr('data-uid', userObj.uid).html('
');
- // memberList.append(liEl);
- // }
- // } else {
- // liEl = $('').addClass('empty').html('None.');
- // memberList.append(liEl);
- // }
- // });
- // };
-
Category.setupPrivilegeTable = function() {
var searchEl = $('.privilege-search'),
searchObj = autocomplete.user(searchEl);
@@ -378,5 +238,36 @@ define('admin/manage/category', [
});
};
+ Category.launchParentSelector = function() {
+ socket.emit('categories.get', function(err, categories) {
+ templates.parse('partials/category_list', {
+ categories: categories
+ }, function(html) {
+ var modal = bootbox.dialog({
+ message: html,
+ title: 'Set Parent Category'
+ });
+
+ modal.find('li[data-cid]').on('click', function() {
+ var parentCid = $(this).attr('data-cid'),
+ payload = {};
+
+ payload[ajaxify.variables.get('cid')] = {
+ parentCid: parentCid
+ };
+
+ socket.emit('admin.categories.update', payload, function(err) {
+ if (err) {
+ return app.alertError(err.message);
+ }
+
+ modal.modal('hide');
+ ajaxify.refresh();
+ });
+ });
+ });
+ });
+ };
+
return Category;
});
\ No newline at end of file
diff --git a/src/controllers/admin.js b/src/controllers/admin.js
index 6e58915038..24332866f9 100644
--- a/src/controllers/admin.js
+++ b/src/controllers/admin.js
@@ -129,7 +129,7 @@ function getGlobalField(field, callback) {
adminController.categories.get = function(req, res, next) {
async.parallel({
- category: async.apply(categories.getCategoryData, req.params.category_id),
+ 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) {
@@ -137,7 +137,7 @@ adminController.categories.get = function(req, res, next) {
}
res.render('admin/manage/category', {
- category: data.category,
+ category: data.category[0],
privileges: data.privileges
});
});
diff --git a/src/meta/css.js b/src/meta/css.js
index a8682b1038..50369f89fb 100644
--- a/src/meta/css.js
+++ b/src/meta/css.js
@@ -68,8 +68,10 @@ module.exports = function(Meta) {
source += '\n@import (inline) "..' + path.sep + '..' + path.sep + 'public/vendor/jquery/bootstrap-tagsinput/bootstrap-tagsinput.css";';
source += '\n@import (inline) "..' + path.sep + '..' + path.sep + 'public/vendor/jquery/textcomplete/jquery.textcomplete.css";';
source += '\n@import (inline) "..' + path.sep + '..' + path.sep + 'public/vendor/colorpicker/colorpicker.css";';
+ source += '\n@import "..' + path.sep + '..' + path.sep + 'public/less/generics.less";';
var acpSource = '\n@import "..' + path.sep + 'public/less/admin/admin";\n' + source;
+ acpSource += '\n@import "..' + path.sep + 'public/less/generics.less";';
acpSource += '\n@import (inline) "..' + path.sep + 'public/vendor/colorpicker/colorpicker.css";';
source = '@import "./theme";\n' + source;
diff --git a/src/views/admin/manage/category.tpl b/src/views/admin/manage/category.tpl
index d51680bc93..4b3b01c66f 100644
--- a/src/views/admin/manage/category.tpl
+++ b/src/views/admin/manage/category.tpl
@@ -3,24 +3,29 @@
Category Settings
-
-
{category.name}
-
-
{category.description}
-
+
+
diff --git a/src/views/admin/partials/categories/privileges.tpl b/src/views/admin/partials/categories/privileges.tpl
new file mode 100644
index 0000000000..e0c65c3e1d
--- /dev/null
+++ b/src/views/admin/partials/categories/privileges.tpl
@@ -0,0 +1,32 @@
+
+
+
+ User |
+
+ {privileges.labels.users.name} |
+
+
+
+
+  |
+ {username} |
+ {function.spawnPrivilegeStates, privileges}
+
+
+
+
+
+
+ Group |
+
+ {privileges.labels.groups.name} |
+
+
+
+
+ {privileges.groups.name} |
+ {function.spawnPrivilegeStates, privileges}
+
+
+
+
\ No newline at end of file