requested changes
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pau 2023-02-03 12:37:55 +01:00
parent 1ce5d781c5
commit a7ec8d6e69
2 changed files with 17 additions and 14 deletions

View File

@ -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();

View File

@ -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);