Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
d6255bc997
|
@ -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'),
|
||||
|
|
|
@ -63,7 +63,8 @@ function config($stateProvider, $urlRouterProvider) {
|
|||
loader: loader(moduleName, validations)
|
||||
},
|
||||
data: {
|
||||
moduleIndex: file
|
||||
moduleIndex: file,
|
||||
acl: route.acl
|
||||
}
|
||||
};
|
||||
if (route.abstract)
|
||||
|
|
|
@ -71,11 +71,12 @@ function backendUnitTest() {
|
|||
];
|
||||
|
||||
const jasmine = require('gulp-jasmine');
|
||||
const reporters = require('jasmine-reporters');
|
||||
let options = {errorOnFail: false};
|
||||
|
||||
if (argv.junit || argv.j)
|
||||
if (argv.junit || argv.j) {
|
||||
const reporters = require('jasmine-reporters');
|
||||
options.reporter = new reporters.JUnitXmlReporter();
|
||||
}
|
||||
|
||||
return gulp.src(specFiles)
|
||||
.pipe(jasmine(options))
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -17,6 +17,5 @@
|
|||
"description": "List",
|
||||
"acl": ["developer"]
|
||||
}
|
||||
],
|
||||
"menu": []
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue