Code coverage report for app/components/sidebar/sidebar.controller.js

Statements: 100% (42 / 42)      Branches: 100% (12 / 12)      Functions: 100% (10 / 10)      Lines: 100% (17 / 17)      Ignored: 2 statements, 4 branches     

All files » app/components/sidebar/ » sidebar.controller.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                       
class SidebarController {
    constructor (RouterHelper, $scope, $rootScope) {
        Object.assign(this, {RouterHelper, $scope, $rootScope});
 
        // generate sidebar nav menus
        this.navs = this._getNavMenus();
        // tell others we have sidebar
        this.$rootScope.hasSidebar = true;
        this.$scope.$on('$destroy', () => {
            this.$rootScope.hasSidebar = false;
        });
    }
 
    hideSidebar () {
        this.$rootScope.showSidebar = false;
    }
 
    _getNavMenus () {
        const navs = [];
        const allStates = this.RouterHelper.getStates();
        allStates.forEach((state) => {
            if (state.sidebar) {
                const nav = state.sidebar;
                nav.link = state.name;
                navs.push(nav);
            }
        });
        return navs;
    }
}
 
SidebarController.$inject = ['RouterHelper', '$scope', '$rootScope'];
 
export default SidebarController;