123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- * Created by robin on 11/5/15.
- */
-
- (function()
- {
- function checkPermissions(permissions, luticateAuthCache)
- {
- var perms = permissions.split(',');
- for (var i = 0; i < perms.length; ++i) {
- if (!luticateAuthCache.hasEffectivePermission(perms[i])) {
- return false;
- }
- }
- return true;
- }
-
- angular.module('luticateUtils')
- .directive('luShowPermission', ['luticateAuthCache',
- function(luticateAuthCache) {
- return {
- restrict: 'A',
- link: function ($scope, element, attrs) {
-
- $scope.$watch(function()
- {
- return checkPermissions(attrs.luShowPermission, luticateAuthCache);
- }, function(newValue)
- {
- if (newValue == true) {
- element.show();
- }
- else {
- element.hide();
- }
- })
- }
- };
- }])
- .directive('luEnablePermission', ['luticateAuthCache',
- function(luticateAuthCache) {
- return {
- restrict: 'A',
- link: function ($scope, element, attrs) {
-
- $scope.$watch(function() {
- return checkPermissions(attrs.luEnablePermission, luticateAuthCache);
- }, function(newValue)
- {
- if (newValue == true) {
- element.removeAttr("disabled");
- }
- else {
- element.attr("disabled", "disabled");
- }
- })
- }
- };
- }]);
- })()
|