refactor(sidebar): static items configuration moved to provider config

pull/217/head
Vladimir Lugovsky 9 years ago
parent 6f6e11904a
commit d849b044f5

@ -43,7 +43,7 @@
"moment": "~2.10.6",
"slimScroll": "jquery-slimscroll#~1.3.6",
"angular-progress-button-styles": "~0.1.0",
"angular-ui-router": "~0.2.15",
"angular-ui-router": "~0.2.16",
"angular-chart.js": "~0.8.8",
"angular-chartist.js": "~3.3.12",
"chartist": "0.9.5",

@ -20,8 +20,43 @@
.config(routeConfig);
/** @ngInject */
function routeConfig($urlRouterProvider) {
function routeConfig($urlRouterProvider, baSidebarServiceProvider) {
$urlRouterProvider.otherwise('/dashboard');
baSidebarServiceProvider.addStaticItem({
title: 'Pages',
icon: 'ion-document',
subMenu: [{
title: 'Sign In',
fixedHref: 'auth.html',
blank: true
}, {
title: 'Sign Up',
fixedHref: 'reg.html',
blank: true
}, {
title: 'User Profile',
stateRef: 'profile'
}, {
title: '404 Page',
fixedHref: '404.html',
blank: true
}]
});
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
}]
}]
});
}
})();

@ -4,7 +4,7 @@
<li ng-repeat="item in ::menuItems" class="al-sidebar-list-item"
ng-class="::{'with-sub-menu': item.subMenu}" ui-sref-active="selected">
<a ng-mouseenter="hoverItem($event, item)" ui-sref="{{ ::(item.stateRef || defaultSidebarState) }}" ng-if="::!item.subMenu" class="al-sidebar-list-link">
<a ng-mouseenter="hoverItem($event, item)" ui-state="item.stateRef || ''" ng-href="{{::(item.fixedHref ? item.fixedHref: '')}}" ng-if="::!item.subMenu" class="al-sidebar-list-link">
<i class="{{ ::item.icon }}"></i><span>{{ ::item.title }}</span>
</a>
@ -28,11 +28,13 @@
ng-class="{expanded: subitem.expanded, 'slide-right': subitem.slideRight}"
ba-ui-sref-toggling-submenu="subitem.stateRef">
<li ng-mouseenter="hoverItem($event, item)" ng-repeat="subSubitem in ::subitem.subMenu" ui-sref-active="selected">
<a ng-mouseenter="hoverItem($event, item)" ui-sref="{{ ::(subSubitem.stateRef || defaultSidebarState) }}">{{
<a ng-mouseenter="hoverItem($event, item)" ui-state="subSubitem.stateRef || ''" ng-href="{{::(subSubitem.fixedHref ? subSubitem.fixedHref: '')}}">{{
::subSubitem.title }}</a>
</li>
</ul>
<a ng-mouseenter="hoverItem($event, item)" target="{{::(subitem.blank ? '_blank' : '_self')}}" ng-if="::!subitem.subMenu" ui-sref="{{ ::(subitem.stateRef || defaultSidebarState) }}">{{ ::subitem.title}}</a>
<a ng-mouseenter="hoverItem($event, item)" target="{{::(subitem.blank ? '_blank' : '_self')}}" ng-if="::!subitem.subMenu"
ui-state="subitem.stateRef || ''"
ng-href="{{::(subitem.fixedHref ? subitem.fixedHref: '')}}">{{ ::subitem.title}}</a>
</li>
</ul>
</li>

@ -2,48 +2,22 @@
'use strict';
angular.module('BlurAdmin.theme.components')
.service('baSidebarService', baSidebarService);
.provider('baSidebarService', baSidebarServiceProvider);
/** @ngInject */
function baSidebarService($state, layoutSizes) {
function baSidebarServiceProvider() {
var staticMenuItems = [];
var isMenuCollapsed = shouldMenuBeCollapsed();
this.addStaticItem = function() {
staticMenuItems.push.apply(staticMenuItems, arguments);
};
var staticMenuItems = [ {
title: 'Pages',
icon: 'ion-document',
subMenu: [{
title: 'Sign In',
root: 'auth.html',
blank: true
}, {
title: 'Sign Up',
root: 'reg.html',
blank: true
}, {
title: 'User Profile',
root: '#/profile'
}, {
title: '404 Page',
root: '404.html',
blank: true
}]
}, {
title: 'Menu Level 1',
icon: 'ion-ios-more',
subMenu: [{
title: 'Menu Level 1.1',
root: '#',
disabled: true
}, {
title: 'Menu Level 1.2',
subMenu: [{
title: 'Menu Level 1.2.1',
root: '#',
disabled: true
}]
}]
}];
/** @ngInject */
this.$get = function($state, layoutSizes) {
return new _factory();
function _factory() {
var isMenuCollapsed = shouldMenuBeCollapsed();
this.getMenuItems = function() {
var states = defineMenuItemStates();
@ -105,4 +79,8 @@
return window.innerWidth <= layoutSizes.resWidthHideSidebar;
}
}
};
}
})();

Loading…
Cancel
Save