12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /**
- * Created by robin on 11/4/15.
- */
-
- angular.module('luticate')
- .controller('GroupEditController', ['$scope', 'luticateAuthGroups', 'data', 'dialogs', '$q', 'luticateAuthCache',
- function($scope, luticateAuthGroups, data, dialogs, $q, luticateAuthCache) {
- if (data != null) {
- $scope.group = data;
- $scope.permission = "LU_GROUP_EDIT";
- }
- else {
- $scope.group = {
- Name: ""
- };
- $scope.permission = "LU_GROUP_ADD";
- }
-
- $scope.submitForm = function()
- {
- if (luticateAuthCache.hasEffectivePermission($scope.permission)) {
- if ($scope.group.Id != null) {
- var promiseEditGroup = {
- id: "promiseEditGroup",
- loaderGroups: ["modal"]
- };
- return luticateAuthGroups.edit({
- group_id: $scope.group.Id,
- group_name: $scope.group.Name
- }, promiseEditGroup);
- }
- else {
- var promiseAddGroup = {
- id: "promiseAddGroup",
- loaderGroups: ["modal"]
- };
- return luticateAuthGroups.add({
- group_name: $scope.group.Name
- }, promiseAddGroup);
- }
- }
- else {
- var defer = $q.defer();
- defer.resolve();
- return defer.promise;
- }
- };
-
- $scope.canEditUsers = function()
- {
- return $scope.group.Id != null &&
- (luticateAuthCache.hasEffectivePermission('LU_GROUP_USER_DEL') ||
- luticateAuthCache.hasAllEffectivePermissions(['LU_GROUP_USER_ADD', 'LU_USER_GET']));
- };
-
- $scope.canEditPermissions = function()
- {
- return $scope.group.Id != null && luticateAuthCache.hasEffectivePermission('LU_PERM_GROUP_GET');
- };
-
- $scope.editPermissions = function(group)
- {
- dialogs.create('views/modals/grouppermissions.html', 'GroupPermissionsController', group);
- };
-
- $scope.editUsers = function(group)
- {
- dialogs.create('views/modals/groupusers.html', 'GroupUsersController', group);
- };
- }]);
|