salix/client/core/src/directives/acl.js

24 lines
726 B
JavaScript
Raw Normal View History

import {module} from '../module';
function vnAcl(aclService, $compile) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
let acls = attrs.vnAcl.split(',');
let action = attrs.vnAclAction || 'disabled';
if (!aclService.aclPermission(acls)) {
if (action === 'disabled') {
let input = element[0].querySelector('input');
input.setAttribute("ng-disabled", "true");
$compile(input)(scope);
} else {
element.remove();
}
}
}
};
}
vnAcl.$inject = ['aclService', '$compile'];
module.directive('vnAcl', vnAcl);