|
|
@ -158,26 +158,6 @@ define('admin/manage/category', [
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Category.setupPrivilegeTable = function() {
|
|
|
|
Category.setupPrivilegeTable = function() {
|
|
|
|
var searchEl = $('.privilege-search'),
|
|
|
|
|
|
|
|
searchObj = autocomplete.user(searchEl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// User search + addition to table
|
|
|
|
|
|
|
|
searchObj.on('autocompleteselect', function(ev, ui) {
|
|
|
|
|
|
|
|
socket.emit('admin.categories.setPrivilege', {
|
|
|
|
|
|
|
|
cid: ajaxify.variables.get('cid'),
|
|
|
|
|
|
|
|
privilege: 'read',
|
|
|
|
|
|
|
|
set: true,
|
|
|
|
|
|
|
|
member: ui.item.user.uid
|
|
|
|
|
|
|
|
}, function(err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Category.refreshPrivilegeTable();
|
|
|
|
|
|
|
|
searchEl.val('');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Checkbox event capture
|
|
|
|
// Checkbox event capture
|
|
|
|
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function() {
|
|
|
|
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function() {
|
|
|
|
var checkboxEl = $(this),
|
|
|
|
var checkboxEl = $(this),
|
|
|
@ -205,6 +185,9 @@ 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);
|
|
|
|
|
|
|
|
|
|
|
|
Category.exposeAssumedPrivileges();
|
|
|
|
Category.exposeAssumedPrivileges();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -292,5 +275,65 @@ define('admin/manage/category', [
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Category.addUserToPrivilegeTable = function() {
|
|
|
|
|
|
|
|
var modal = bootbox.dialog({
|
|
|
|
|
|
|
|
title: 'Find a User',
|
|
|
|
|
|
|
|
message: '<input class="form-control input-lg" placeholder="Search for a user here..." />',
|
|
|
|
|
|
|
|
show: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modal.on('shown.bs.modal', function() {
|
|
|
|
|
|
|
|
var inputEl = modal.find('input'),
|
|
|
|
|
|
|
|
searchObj = autocomplete.user(inputEl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
searchObj.on('autocompleteselect', function(ev, ui) {
|
|
|
|
|
|
|
|
socket.emit('admin.categories.setPrivilege', {
|
|
|
|
|
|
|
|
cid: ajaxify.variables.get('cid'),
|
|
|
|
|
|
|
|
privilege: ['find', 'read'],
|
|
|
|
|
|
|
|
set: true,
|
|
|
|
|
|
|
|
member: ui.item.user.uid
|
|
|
|
|
|
|
|
}, function(err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Category.refreshPrivilegeTable();
|
|
|
|
|
|
|
|
modal.modal('hide');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Category.addGroupToPrivilegeTable = function() {
|
|
|
|
|
|
|
|
var modal = bootbox.dialog({
|
|
|
|
|
|
|
|
title: 'Find a Group',
|
|
|
|
|
|
|
|
message: '<input class="form-control input-lg" placeholder="Search for a group here..." />',
|
|
|
|
|
|
|
|
show: true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modal.on('shown.bs.modal', function() {
|
|
|
|
|
|
|
|
var inputEl = modal.find('input'),
|
|
|
|
|
|
|
|
searchObj = autocomplete.group(inputEl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
searchObj.on('autocompleteselect', function(ev, ui) {
|
|
|
|
|
|
|
|
console.log(ui);
|
|
|
|
|
|
|
|
socket.emit('admin.categories.setPrivilege', {
|
|
|
|
|
|
|
|
cid: ajaxify.variables.get('cid'),
|
|
|
|
|
|
|
|
privilege: ['groups:find', 'groups:read'],
|
|
|
|
|
|
|
|
set: true,
|
|
|
|
|
|
|
|
member: ui.item.group.name
|
|
|
|
|
|
|
|
}, function(err) {
|
|
|
|
|
|
|
|
console.log(arguments);
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Category.refreshPrivilegeTable();
|
|
|
|
|
|
|
|
modal.modal('hide');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return Category;
|
|
|
|
return Category;
|
|
|
|
});
|
|
|
|
});
|