|
|
|
@ -5,9 +5,8 @@ define('admin/manage/category', [
|
|
|
|
|
'uploader',
|
|
|
|
|
'iconSelect',
|
|
|
|
|
'admin/modules/colorpicker',
|
|
|
|
|
'autocomplete',
|
|
|
|
|
'Chart'
|
|
|
|
|
], function(uploader, iconSelect, colorpicker, autocomplete, Chart) {
|
|
|
|
|
'autocomplete'
|
|
|
|
|
], function(uploader, iconSelect, colorpicker, autocomplete) {
|
|
|
|
|
var Category = {};
|
|
|
|
|
|
|
|
|
|
Category.init = function() {
|
|
|
|
@ -100,46 +99,17 @@ define('admin/manage/category', [
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.copy-settings').on('click', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
socket.emit('admin.categories.getNames', function(err, categories) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
templates.parse('admin/partials/categories/select-category', {
|
|
|
|
|
categories: categories
|
|
|
|
|
}, function(html) {
|
|
|
|
|
function submit() {
|
|
|
|
|
var formData = modal.find('form').serializeObject();
|
|
|
|
|
|
|
|
|
|
socket.emit('admin.categories.copySettingsFrom', {fromCid: formData['select-cid'], toCid: ajaxify.data.category.cid}, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
app.alertSuccess('Settings Copied!');
|
|
|
|
|
ajaxify.refresh();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.modal('hide');
|
|
|
|
|
return false;
|
|
|
|
|
$('.copy-settings').on('click', function() {
|
|
|
|
|
selectCategoryModal(function(cid) {
|
|
|
|
|
socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var modal = bootbox.dialog({
|
|
|
|
|
title: 'Select a Category',
|
|
|
|
|
message: html,
|
|
|
|
|
buttons: {
|
|
|
|
|
save: {
|
|
|
|
|
label: 'Copy',
|
|
|
|
|
className: 'btn-primary',
|
|
|
|
|
callback: submit
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.find('form').on('submit', submit);
|
|
|
|
|
app.alertSuccess('Settings Copied!');
|
|
|
|
|
ajaxify.refresh();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.upload-button').on('click', function() {
|
|
|
|
@ -229,6 +199,7 @@ define('admin/manage/category', [
|
|
|
|
|
$('.privilege-table-container').on('click', '[data-action="search.user"]', Category.addUserToPrivilegeTable);
|
|
|
|
|
$('.privilege-table-container').on('click', '[data-action="search.group"]', Category.addGroupToPrivilegeTable);
|
|
|
|
|
$('.privilege-table-container').on('click', '[data-action="copyToChildren"]', Category.copyPrivilegesToChildren);
|
|
|
|
|
$('.privilege-table-container').on('click', '[data-action="copyPrivilegesFrom"]', Category.copyPrivilegesFromCategory);
|
|
|
|
|
|
|
|
|
|
Category.exposeAssumedPrivileges();
|
|
|
|
|
};
|
|
|
|
@ -397,5 +368,50 @@ define('admin/manage/category', [
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Category.copyPrivilegesFromCategory = function() {
|
|
|
|
|
selectCategoryModal(function(cid) {
|
|
|
|
|
socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
ajaxify.refresh();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function selectCategoryModal(callback) {
|
|
|
|
|
socket.emit('admin.categories.getNames', function(err, categories) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
templates.parse('admin/partials/categories/select-category', {
|
|
|
|
|
categories: categories
|
|
|
|
|
}, function(html) {
|
|
|
|
|
function submit() {
|
|
|
|
|
var formData = modal.find('form').serializeObject();
|
|
|
|
|
callback(formData['select-cid']);
|
|
|
|
|
modal.modal('hide');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var modal = bootbox.dialog({
|
|
|
|
|
title: 'Select a Category',
|
|
|
|
|
message: html,
|
|
|
|
|
buttons: {
|
|
|
|
|
save: {
|
|
|
|
|
label: 'Copy',
|
|
|
|
|
className: 'btn-primary',
|
|
|
|
|
callback: submit
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.find('form').on('submit', submit);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Category;
|
|
|
|
|
});
|