Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Add support for params in menu items
 (#1305)
Browse files Browse the repository at this point in the history
* Support params to state for menu items.

* feat(core): Add support for params in menu items

Proposed by @scfox

Fixes #1304

* Removed trailing space on test.

* Changed default params to be empty object instead of empty string.
  • Loading branch information
scfox authored and mleanos committed Jul 25, 2016
1 parent 6911b80 commit 5817a48
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 5817a48

Please sign in to comment.