Add support for params in menu items
 (#1305)

* 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.
This commit is contained in:
Steve Fox
2016-07-25 16:14:39 -05:00
committed by Michael Leanos
parent 6911b80446
commit 5817a484fa
3 changed files with 7 additions and 1 deletions

View File

@@ -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

View File

@@ -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>

View File

@@ -300,6 +300,7 @@
var subItemOptions = {
title: 'title',
state: 'sub.state',
params: { p1: 'val1' },
isPublic: false,
roles: ['a', 'b'],
position: 4
@@ -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() {