we implemented such an operator into cat-main-menu.js , but because of the new way the visibility is evaluated, we have to add this operator somewhere again.
with the new visiblity service, we also can implement this for buttons and actions.
This is the old code of cat-main-menu.js
angular.module('cat.directives.menu')
.directive('catMainMenu', ['$mainMenu', '$rootScope', '$location', function CatMainMenuDirective($mainMenu, $rootScope, $location) {
return {
restrict: 'E',
scope: {},
link: function CatMainMenuLink(scope) {
scope.menus = $mainMenu.getMenus();
scope.isVisible = function (entry) {
var visible = false;
if (entry.isMenu() || entry.isGroup()) {
_.forEach(entry.getEntries(), function (subEntry) {
visible = visible || scope.isVisible(subEntry);
});
if (entry.isMenu()) {
_.forEach(entry.getGroups(), function (groups) {
visible = visible || scope.isVisible(groups);
});
}
} else {
return scope.isAllowed(entry);
}
return visible;
};
scope.isAllowed = function (entry) {
var rights = entry.getOptions().rights;
var rightsOperator = entry.getOptions().rightsOperator || 'all';
if (!!rights) {
if (_.isArray(rights)) {
var allowed = true;
if ('all' === rightsOperator) {
for (var i = 0; i < rights.length; i++) {
allowed = allowed && $rootScope.isAllowed(rights[i]);
}
} else if ('any' === rightsOperator) {
allowed = false;
for (var j = 0; j < rights.length; j++) {
allowed = allowed || $rootScope.isAllowed(rights[j]);
}
}
return allowed;
}
return $rootScope.isAllowed(rights);
}
return true;
};
scope.isActive = function (path) {
return $location.path().substr(0, path.length) === path;
};
},
templateUrl: 'template/cat-main-menu.tpl.html'
};
}]);
we implemented such an operator into
cat-main-menu.js
, but because of the new way the visibility is evaluated, we have to add this operator somewhere again.with the new visiblity service, we also can implement this for buttons and actions.
This is the old code of
cat-main-menu.js