1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- /**
- * Created by robin on 11/4/15.
- */
-
- angular.module('luticate')
- .controller('PermissionEditController', ['$scope', 'luticateAuthPermissions', 'data', 'luticateAuthCache', '$q',
- function($scope, luticateAuthPermissions, data, luticateAuthCache, $q) {
- if (data != null) {
- $scope.permission = data;
- $scope.permission.IsNew = false;
- $scope.neededPermission = "LU_PERM_EDIT";
- }
- else {
- $scope.permission = {
- Name: "",
- Value: false,
- IsNew: true
- };
- $scope.neededPermission = "LU_PERM_ADD";
- }
-
- $scope.submitForm = function()
- {
- var perm = {
- permission_name: $scope.permission.Name.toUpperCase(),
- permission_value: $scope.permission.Value
- };
- if (!$scope.permission.IsNew) {
- if (luticateAuthCache.hasEffectivePermission("LU_PERM_EDIT")) {
- var promiseEditPermission = {
- id: "promiseEditPermission",
- loaderGroups: ["modal"]
- };
- return luticateAuthPermissions.edit(perm, promiseEditPermission);
- }
- else {
- var defer = $q.defer();
- defer.resolve();
- return defer.promise;
- }
- }
- else {
- var promiseAddPermission = {
- id: "promiseAddPermission",
- loaderGroups: ["modal"]
- };
- return luticateAuthPermissions.add(perm, promiseAddPermission);
- }
- }
- }]);
|