You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

permissionedit.controller.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Created by robin on 11/4/15.
  3. */
  4. angular.module('luticate')
  5. .controller('PermissionEditController', ['$scope', 'luticateAuthPermissions', 'data', 'luticateAuthCache', '$q',
  6. function($scope, luticateAuthPermissions, data, luticateAuthCache, $q) {
  7. if (data != null) {
  8. $scope.permission = data;
  9. $scope.permission.IsNew = false;
  10. $scope.neededPermission = "LU_PERM_EDIT";
  11. }
  12. else {
  13. $scope.permission = {
  14. Name: "",
  15. Value: false,
  16. IsNew: true
  17. };
  18. $scope.neededPermission = "LU_PERM_ADD";
  19. }
  20. $scope.submitForm = function()
  21. {
  22. var perm = {
  23. permission_name: $scope.permission.Name.toUpperCase(),
  24. permission_value: $scope.permission.Value
  25. };
  26. if (!$scope.permission.IsNew) {
  27. if (luticateAuthCache.hasEffectivePermission("LU_PERM_EDIT")) {
  28. var promiseEditPermission = {
  29. id: "promiseEditPermission",
  30. loaderGroups: ["modal"]
  31. };
  32. return luticateAuthPermissions.edit(perm, promiseEditPermission);
  33. }
  34. else {
  35. var defer = $q.defer();
  36. defer.resolve();
  37. return defer.promise;
  38. }
  39. }
  40. else {
  41. var promiseAddPermission = {
  42. id: "promiseAddPermission",
  43. loaderGroups: ["modal"]
  44. };
  45. return luticateAuthPermissions.add(perm, promiseAddPermission);
  46. }
  47. }
  48. }]);