fix(baSidebar)-fix level 2 submenu bug
parent
1f81f3b1c1
commit
83e6944981
|
@ -21,18 +21,27 @@
|
||||||
|
|
||||||
this.getMenuItems = function() {
|
this.getMenuItems = function() {
|
||||||
var states = defineMenuItemStates();
|
var states = defineMenuItemStates();
|
||||||
var menuItems = states.filter(function(item) {
|
//result shoud like [0,1,2]
|
||||||
return item.level == 0;
|
var levels = states.map(function (e) {
|
||||||
|
return e.level;
|
||||||
|
}).filter(function (e, i, arr) {
|
||||||
|
return i === arr.indexOf(e);
|
||||||
});
|
});
|
||||||
|
//add subMenu for each level item
|
||||||
menuItems.forEach(function(item) {
|
levels.forEach(function (level) {
|
||||||
var children = states.filter(function(child) {
|
var menuItems = states.filter(function (e) {
|
||||||
return child.level == 1 && child.name.indexOf(item.name) === 0;
|
return e.level === level;
|
||||||
|
});
|
||||||
|
menuItems.forEach(function (item) {
|
||||||
|
var children = states.filter(function (child) {
|
||||||
|
return child.level - level === 1 && child.name.indexOf(item.name) === 0;
|
||||||
|
});
|
||||||
|
item.subMenu = children.length ? children : null;
|
||||||
});
|
});
|
||||||
item.subMenu = children.length ? children : null;
|
|
||||||
});
|
});
|
||||||
|
return states.filter(function (e) {
|
||||||
return menuItems.concat(staticMenuItems);
|
return e.level === 0;
|
||||||
|
}).concat(staticMenuItems);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.shouldMenuBeCollapsed = shouldMenuBeCollapsed;
|
this.shouldMenuBeCollapsed = shouldMenuBeCollapsed;
|
||||||
|
|
Loading…
Reference in New Issue