1
0
mirror of https://github.com/ascribe/onion.git synced 2024-07-01 06:02:12 +02:00
onion/js/utils/acl_utils.js

23 lines
690 B
JavaScript
Raw Normal View History

'use strict';
export function getAvailableAcls(editions) {
let availableAcls = [];
// If no edition has been selected, availableActions is empty
// If only one edition has been selected, their actions are available
// If more than one editions have been selected, their acl properties are intersected
if(editions.length >= 1) {
availableAcls = editions[0].acl;
}
if(editions.length >= 2) {
for(let i = 1; i < editions.length; i++) {
availableAcls = intersectAcls(availableAcls, editions[i].acl);
}
}
return availableAcls;
}
export function intersectAcls(a, b) {
return a.filter((val) => b.indexOf(val) > -1);
}