From a7ec8d6e69f15beac3b24611e55b13634e4ac338 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 3 Feb 2023 12:37:55 +0100 Subject: [PATCH] requested changes --- front/core/directives/specs/acl.spec.js | 14 +++++++------- front/core/directives/user-acl.js | 17 ++++++++++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/front/core/directives/specs/acl.spec.js b/front/core/directives/specs/acl.spec.js index 09b9eee0b..ced1e083d 100644 --- a/front/core/directives/specs/acl.spec.js +++ b/front/core/directives/specs/acl.spec.js @@ -17,13 +17,13 @@ describe('Directive acl', () => { }); $httpBackend.whenPOST('Accounts/user/acl').respond([ { - 'id': 1, - 'model': 'ModelExample', - 'property': '*', - 'accessType': '*', - 'permission': 'ALLOW', - 'principalType': 'ROLE', - 'principalId': 'employee' + id: 1, + model: 'ModelExample', + property: '*', + accessType: '*', + permission: 'ALLOW', + principalType: 'ROLE', + principalId: 'employee' } ]); aclService.load(); diff --git a/front/core/directives/user-acl.js b/front/core/directives/user-acl.js index f66e50669..aef700d44 100644 --- a/front/core/directives/user-acl.js +++ b/front/core/directives/user-acl.js @@ -11,14 +11,17 @@ function vnUserAcl(aclService) { acls = $attrs.vnUserAcl.split(',').map(i => i.trim()); if (acls[0] == '') return; - let action = $attrs.vnAclAction || 'disable'; + const action = $attrs.vnAclAction || 'disable'; // The acls always come formatted as "Model.property/accessType" // Example: "Client.create/w" - let model = acls[0].split('.')[0]; - let property = acls[0].split('.')[1].split('/')[0]; - let accessType = acls[0].split('.')[1].split('/')[1]; + const splitAcl = acls[0].split('.'); + const splitSlash = splitAcl[1].split('/'); + + const model = splitAcl[0]; + const property = splitSlash[0]; + let accessType = splitSlash[1]; // There can be 3 cases for the acessType: Write(w), Read(r) or All(*) @@ -30,11 +33,11 @@ function vnUserAcl(aclService) { if (hasAny) return; if (action === 'disable') { - let element = $element[0]; - let elementToDisable = element.$ctrl; + const element = $element[0]; + const elementToDisable = element.$ctrl; if (!(elementToDisable instanceof FormInput)) { - let selector = 'input, textarea, button, submit'; + const selector = 'input, textarea, button, submit'; if (!element.matches(selector)) element = element.querySelector(selector);