import {module} from '../module'; function vnAcl(aclService, $timeout) { return { restrict: 'A', priority: -1, 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]; let selector = 'input, textarea, button, submit'; if (!input.matches(selector)) input = input.querySelector(selector); if (input) { $timeout(() => { input.setAttribute("disabled", "true"); }); $element[0].querySelectorAll('i, vn-drop-down').forEach(element => { element.parentNode.removeChild(element); }); } } else { $element.remove(); } } } }; } vnAcl.$inject = ['aclService', '$timeout']; module.directive('vnAcl', vnAcl);