#981 vnLeftMenu fixes

This commit is contained in:
Juan Ferrer 2019-01-24 16:04:38 +01:00
parent 6a1e1439e0
commit bfb2f7f533
4 changed files with 41 additions and 32 deletions

View File

@ -2,45 +2,52 @@ import ngModule from '../../module';
import './style.scss';
export default class LeftMenu {
constructor($state, $transitions) {
constructor($state, $transitions, aclService) {
this.$state = $state;
this.deregisterCallback = $transitions.onSuccess({},
transition => this.activateItem());
() => this.activateItem());
this._depth = 3;
let states = this.$state.router.stateRegistry.states;
let moduleIndex = this.$state.current.data.moduleIndex;
let moduleFile = window.routes[moduleIndex] || [];
let menu = moduleFile.menu;
let menu = moduleFile.menu || [];
let items = [];
for (let item of menu) {
let route = states[item.state];
let newItem = {
function addItem(items, item) {
let state = states[item.state];
if (!state) return;
state = state.self;
let acl = state.data.acl;
if (acl && !aclService.hasAny(acl))
return;
items.push({
icon: item.icon,
childs: []
};
description: state.description,
state: item.state
});
}
if (item.state && !route) continue;
if (item.state) {
newItem.description = route.self.description;
newItem.state = item.state;
} else {
for (let child of item.childs) {
let route = states[child.state];
for (let item of menu) {
if (item.state)
addItem(items, item);
else {
let childs = [];
if (!route) continue;
for (let child of item.childs)
addItem(childs, child);
newItem.description = item.description;
newItem.childs.push({
description: route.self.description,
icon: child.icon,
state: child.state
if (childs.length > 0) {
items.push({
icon: item.icon,
description: item.description,
childs: childs
});
}
}
items.push(newItem);
}
this.items = items;
@ -68,10 +75,12 @@ export default class LeftMenu {
for (let item of this.items) {
item.active = re.test(item.state);
for (let child of item.childs) {
child.active = re.test(child.state);
if (child.active)
item.active = child.active;
if (item.childs) {
for (let child of item.childs) {
child.active = re.test(child.state);
if (child.active)
item.active = child.active;
}
}
}
}
@ -86,7 +95,7 @@ export default class LeftMenu {
this.deregisterCallback();
}
}
LeftMenu.$inject = ['$state', '$transitions'];
LeftMenu.$inject = ['$state', '$transitions', 'aclService'];
ngModule.component('vnLeftMenu', {
template: require('./left-menu.html'),

View File

@ -63,7 +63,8 @@ function config($stateProvider, $urlRouterProvider) {
loader: loader(moduleName, validations)
},
data: {
moduleIndex: file
moduleIndex: file,
acl: route.acl
}
};
if (route.abstract)

View File

@ -70,7 +70,7 @@
<h4 translate>Tags</h4>
<vn-label-value
label="{{tag.priority}} {{tag.tag.name}}"
ng-repeat="tag in $ctrl.summary.tags.slice(3, 6) track by tag.id"
ng-repeat="tag in $ctrl.summary.tags track by tag.id"
value="{{tag.value}}">
</vn-label-value>
</vn-one>

View File

@ -17,6 +17,5 @@
"description": "List",
"acl": ["developer"]
}
],
"menu": []
]
}