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

Add support for params in menu items
 #1305

Merged
merged 4 commits into from
Jul 25, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 || '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set this to an empty object, for consistency.

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