Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about how to make level 2 sub menu using route congifuration #127

Open
rayeteu opened this issue Jul 22, 2016 · 11 comments
Open

question about how to make level 2 sub menu using route congifuration #127

rayeteu opened this issue Jul 22, 2016 · 11 comments

Comments

@rayeteu
Copy link

rayeteu commented Jul 22, 2016

Hello

I am working on the sidebar.

I succeeded in making level 2 sub menu using manual configuration explained on http://akveo.github.io/blur-admin/articles/051-sidebar/
But I could not make level 2 sub menu using router configuration even though level 1 sub menu was created.

Please, help me and let's me know how to make level 2 sub menu suing router configuration.

@vazh
Copy link

vazh commented Jul 24, 2016

images of the problem and expected result please. to avoid different view of what sub and level is.

@rayeteu
Copy link
Author

rayeteu commented Jul 25, 2016

barSidebarService example:

baSidebarServiceProvider.addStaticItem({
title: 'Menu Level 1',
icon: 'ion-ios-more',
subMenu: [{
title: 'Menu Level 1.1',
disabled: true
}, {
title: 'Menu Level 1.2',
subMenu: [{
title: 'Menu Level 1.2.1',
disabled: true
}]
}]
});

Result :
image

I can see level 2 menu.

Route configuration example:
-----------------------------------sidebar menu(componenet)------------------------------------
(function () {
'use strict';

angular.module('BlurAdmin.pages.components', [
'BlurAdmin.pages.components.mail',
])
.config(routeConfig);

/** @ngInject */
function routeConfig($stateProvider) {
$stateProvider
.state('components', {
url: '/components',
template : '',
abstract: true,
title: 'Components',
sidebarMeta: {
icon: 'ion-gear-a',
order: 100,
},
});
}
})();
--------------------------------componenet submenu(level 1)----------------------------------------

angular.module('BlurAdmin.pages.components.mail', [
'BlurAdmin.pages.components.mail.menu'
])
.config(routeConfig);

/** @ngInject */
function routeConfig($stateProvider) {
$stateProvider
.state('components.mail', {
url: '/mail',
abstract: true,
templateUrl: 'app/pages/components/mail/mail.html',
controller: "MailTabCtrl",
controllerAs: "tabCtrl",
title: 'Mail',
sidebarMeta: {
order: 0,
},
})();
---------------------------componenet submenu-submenu(level 2)--------------------------------

angular.module('BlurAdmin.pages.components.mail.menu', [])
.config(routeConfig);

/** @ngInject */
function routeConfig($stateProvider) {
$stateProvider
.state('components.mail.menu', {
url: '/menu',
templateUrl: 'app/pages/components/mail/menu.html',
title: 'Menu',
sidebarMeta: {
order: 10,
},
})();

Result :

image

I can't see level 2 menu.

@vazh
Copy link

vazh commented Jul 29, 2016

try using parent instead of writing route name with components.mail.menu

.state('mail.menu', {
  parent: 'components'
});

try like that,

@NanFengCheong
Copy link

@vazh still not working, tried
.state('mail.menu', { parent: 'components' });
.state('menu', { parent: 'components.mail' });
.state('menu', { parent: 'mail' });

@vazh
Copy link

vazh commented Sep 7, 2016

@DJPeace

  • Components
    • Mail
      • Menu

is that how you wanted it ?
which means you need to make mail into abstract i think. didn't try, but since components was an abstract state too. so it's possible.

@heshamelmasry77
Copy link

i still have the same problem

@Davidmq96
Copy link

@heshamelmasry77 @DJPeace Did you could resolve the problem?

@rayeteu
Copy link
Author

rayeteu commented Jul 28, 2017

@Davidmq96 I did not solve it.

@NanFengCheong
Copy link

NanFengCheong commented Sep 7, 2017

#337 try and replace getMenuItems in blur-admin/src/app/theme/components/baSidebar/baSidebar.service.js

@l7wahn
Copy link

l7wahn commented Oct 15, 2017

change the this.getMenuItems function body on src/app/theme/components/baSidebar/baSidebar.service.js to this:

`

     var states = defineMenuItemStates();
      var menuItems = states.filter(function(item) {
        return item.level == 0;
      });

      menuItems.forEach(function(item) {
        var children = states.filter(function(child) {
          return child.level == 1 && child.name.indexOf(item.name) === 0;
        });

        children.forEach(function(item) {
            var children = states.filter(function(child) {
                return child.level == 2 && child.name.indexOf(item.name) === 0;
            });
            item.subMenu = children.length ? children : null;
        });

        item.subMenu = children.length ? children : null;
      });

      return menuItems.concat(staticMenuItems);

`

Good luck, it worked for me

@RenatoAlves0
Copy link

You should go to "src/app/theme/components/baSidebar/baSidebar.service.js" and add this code.
With it you can go to level 3.

          //Menu level 0
            this.getMenuItems = function () {
                var states = defineMenuItemStates();
                var children0 = states.filter(function (child0) {
                    return child0.level == 0;
                });

                //Menu level 1
                children0.forEach(function (item1) {
                    var children1 = states.filter(function (child1) {
                        return child1.level == 1 && child1.name.indexOf(item1.name) === 0;
                    });

                    //Menu level 2
                    children1.forEach(function (item2) {
                        var children2 = states.filter(function (child2) {
                            return child2.level == 2 && child2.name.indexOf(item2.name) === 0;

                        });

                        //Menu level 3
                        children2.forEach(function (item3) {
                            var children3 = states.filter(function (child3) {
                                return child3.level == 3 && child3.name.indexOf(item3.name) === 0;
                            });

                            item3.subMenu = children3.length ? children3 : null;
                        });

                        item2.subMenu = children2.length ? children2 : null;
                    });

                    item1.subMenu = children1.length ? children1 : null;
                });

                return children0.concat(staticMenuItems);
            };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants