Skip to content

Commit

Permalink
Support params to state for menu items.
Browse files Browse the repository at this point in the history
  • Loading branch information
scfox committed Apr 12, 2016
1 parent f2a6bf9 commit 9ae6ad3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/core/client/services/menu.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
service.menus[menuId].items[itemIndex].items.push({
title: options.title || '',
state: options.state || '',
params: options.params || '',
roles: ((options.roles === null || typeof options.roles === 'undefined') ? service.menus[menuId].items[itemIndex].roles : options.roles),
position: options.position || 0,
shouldRender: shouldRender
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/views/header.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a ng-switch-when="dropdown" class="dropdown-toggle" uib-dropdown-toggle role="button">{{::item.title}}&nbsp;<span class="caret"></span></a>
<ul ng-switch-when="dropdown" class="dropdown-menu">
<li ng-repeat="subitem in item.items | orderBy: 'position'" ng-if="subitem.shouldRender(vm.authentication.user);">
<a ui-sref="{{subitem.state}}" ng-bind="subitem.title"></a>
<a ui-sref="{{subitem.state}}({{subitem.params}})" ng-bind="subitem.title"></a>
</li>
</ul>
<a ng-switch-default ui-sref="{{item.state}}" ng-bind="item.title"></a>
Expand Down
5 changes: 5 additions & 0 deletions modules/core/tests/client/menus.client.service.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
var subItemOptions = {
title: 'title',
state: 'sub.state',
params: { p1: 'val1' },
isPublic: false,
roles: ['a', 'b'],
position: 4
Expand Down Expand Up @@ -378,6 +379,10 @@
it('should set position to options position', function() {
expect(subItem1.position).toEqual(subItemOptions.position);
});

it('should set params to options params', function() {
expect(subItem1.params).toEqual(subItemOptions.params);
});
});

describe('without optoins set', function() {
Expand Down

0 comments on commit 9ae6ad3

Please sign in to comment.