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';
|
import './style.scss';
|
||||||
|
|
||||||
export default class LeftMenu {
|
export default class LeftMenu {
|
||||||
constructor($state, $transitions) {
|
constructor($state, $transitions, aclService) {
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
this.deregisterCallback = $transitions.onSuccess({},
|
this.deregisterCallback = $transitions.onSuccess({},
|
||||||
transition => this.activateItem());
|
() => this.activateItem());
|
||||||
this._depth = 3;
|
this._depth = 3;
|
||||||
|
|
||||||
let states = this.$state.router.stateRegistry.states;
|
let states = this.$state.router.stateRegistry.states;
|
||||||
let moduleIndex = this.$state.current.data.moduleIndex;
|
let moduleIndex = this.$state.current.data.moduleIndex;
|
||||||
let moduleFile = window.routes[moduleIndex] || [];
|
let moduleFile = window.routes[moduleIndex] || [];
|
||||||
let menu = moduleFile.menu;
|
let menu = moduleFile.menu || [];
|
||||||
let items = [];
|
let items = [];
|
||||||
|
|
||||||
for (let item of menu) {
|
function addItem(items, item) {
|
||||||
let route = states[item.state];
|
let state = states[item.state];
|
||||||
let newItem = {
|
if (!state) return;
|
||||||
|
|
||||||
|
state = state.self;
|
||||||
|
let acl = state.data.acl;
|
||||||
|
|
||||||
|
if (acl && !aclService.hasAny(acl))
|
||||||
|
return;
|
||||||
|
|
||||||
|
items.push({
|
||||||
icon: item.icon,
|
icon: item.icon,
|
||||||
childs: []
|
description: state.description,
|
||||||
};
|
state: item.state
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (item.state && !route) continue;
|
for (let item of menu) {
|
||||||
if (item.state) {
|
if (item.state)
|
||||||
newItem.description = route.self.description;
|
addItem(items, item);
|
||||||
newItem.state = item.state;
|
else {
|
||||||
} else {
|
let childs = [];
|
||||||
for (let child of item.childs) {
|
|
||||||
let route = states[child.state];
|
|
||||||
|
|
||||||
if (!route) continue;
|
for (let child of item.childs)
|
||||||
|
addItem(childs, child);
|
||||||
|
|
||||||
newItem.description = item.description;
|
if (childs.length > 0) {
|
||||||
newItem.childs.push({
|
items.push({
|
||||||
description: route.self.description,
|
icon: item.icon,
|
||||||
icon: child.icon,
|
description: item.description,
|
||||||
state: child.state
|
childs: childs
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
items.push(newItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.items = items;
|
this.items = items;
|
||||||
|
@ -68,6 +75,7 @@ export default class LeftMenu {
|
||||||
for (let item of this.items) {
|
for (let item of this.items) {
|
||||||
item.active = re.test(item.state);
|
item.active = re.test(item.state);
|
||||||
|
|
||||||
|
if (item.childs) {
|
||||||
for (let child of item.childs) {
|
for (let child of item.childs) {
|
||||||
child.active = re.test(child.state);
|
child.active = re.test(child.state);
|
||||||
if (child.active)
|
if (child.active)
|
||||||
|
@ -76,6 +84,7 @@ export default class LeftMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setActive(item) {
|
setActive(item) {
|
||||||
if (item.state) return;
|
if (item.state) return;
|
||||||
|
@ -86,7 +95,7 @@ export default class LeftMenu {
|
||||||
this.deregisterCallback();
|
this.deregisterCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeftMenu.$inject = ['$state', '$transitions'];
|
LeftMenu.$inject = ['$state', '$transitions', 'aclService'];
|
||||||
|
|
||||||
ngModule.component('vnLeftMenu', {
|
ngModule.component('vnLeftMenu', {
|
||||||
template: require('./left-menu.html'),
|
template: require('./left-menu.html'),
|
||||||
|
|
|
@ -63,7 +63,8 @@ function config($stateProvider, $urlRouterProvider) {
|
||||||
loader: loader(moduleName, validations)
|
loader: loader(moduleName, validations)
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
moduleIndex: file
|
moduleIndex: file,
|
||||||
|
acl: route.acl
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (route.abstract)
|
if (route.abstract)
|
||||||
|
|
|
@ -71,11 +71,12 @@ function backendUnitTest() {
|
||||||
];
|
];
|
||||||
|
|
||||||
const jasmine = require('gulp-jasmine');
|
const jasmine = require('gulp-jasmine');
|
||||||
const reporters = require('jasmine-reporters');
|
|
||||||
let options = {errorOnFail: false};
|
let options = {errorOnFail: false};
|
||||||
|
|
||||||
if (argv.junit || argv.j)
|
if (argv.junit || argv.j) {
|
||||||
|
const reporters = require('jasmine-reporters');
|
||||||
options.reporter = new reporters.JUnitXmlReporter();
|
options.reporter = new reporters.JUnitXmlReporter();
|
||||||
|
}
|
||||||
|
|
||||||
return gulp.src(specFiles)
|
return gulp.src(specFiles)
|
||||||
.pipe(jasmine(options))
|
.pipe(jasmine(options))
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
<h4 translate>Tags</h4>
|
<h4 translate>Tags</h4>
|
||||||
<vn-label-value
|
<vn-label-value
|
||||||
label="{{tag.priority}} {{tag.tag.name}}"
|
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}}">
|
value="{{tag.value}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
|
|
|
@ -17,6 +17,5 @@
|
||||||
"description": "List",
|
"description": "List",
|
||||||
"acl": ["developer"]
|
"acl": ["developer"]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"menu": []
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue