sheercms
Version:
Sheer Cliff CMS is a simple and powerful content management system (CMS) for Node JS.
53 lines (41 loc) • 1.38 kB
JavaScript
var GroupSelectorDialogController = function ($scope, $modalInstance, GroupService, branch, title) {
$scope.dialog = {
title: title || "Select a Group",
message: "",
messageType: ""
};
$scope.data = {
group: null,
groups: []
};
$scope.ok = function() {
$modalInstance.close($scope.data.group);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
function init() {
branch = branch || "content,media";
//load the list of groups
GroupService.list(branch, null).then(function(result) {
if (result && result.success === true) {
//only add groups that the user has read access to
$scope.data.groups = [];
for(var i = 0; i < result.groups.length; i++) {
var g = result.groups[i];
if (g.rights && g.rights.read == true)
$scope.data.groups.push(g);
}
} else if (result) {
setMessage(result.message, 'alert-danger');
} else {
setMessage('An unknown error occurred.', 'alert-danger');
}
});
}
function setMessage(msg, type) {
$scope.dialog.messageType = type;
$scope.dialog.message = msg;
}
init();
};