Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit 384f7b2

Browse files
author
Miguel Jacinto
committed
EZP-26120: Expose the navigation items identifier in the navigation hub
1 parent 8254056 commit 384f7b2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Resources/public/js/views/navigation/ez-navigationitemview.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ YUI.add('ez-navigationitemview', function (Y) {
2424
*/
2525
Y.eZ.NavigationItemView = Y.Base.create('navigationItemView', Y.eZ.TemplateBasedView, [], {
2626
initializer: function () {
27-
this.containerTemplate = '<li class="' + this._generateViewClassName(this._getName()) + '"/>';
27+
var dataNavigationIdentifier = 'data-navigation-item-identifier="' + this.get('identifier') + '"';
28+
29+
this.containerTemplate = '<li class="' + this._generateViewClassName(this._getName()) + '" ' + dataNavigationIdentifier + '/>';
2830
this.after('selectedChange', this._uiSelectedChange);
2931
this.after('routeChange', function (){
3032
this.render();

Tests/js/views/navigation/assets/ez-navigationitemview-tests.js

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ YUI.add('ez-navigationitemview-tests', function (Y) {
1313

1414
setUp: function () {
1515
this.title = "Title";
16+
this.identifier = 'title';
1617
this.route = {
1718
name: "viewLocation",
1819
params: {
@@ -22,6 +23,7 @@ YUI.add('ez-navigationitemview-tests', function (Y) {
2223
};
2324
this.view = new Y.eZ.NavigationItemView({
2425
title: this.title,
26+
identifier: this.identifier,
2527
route: this.route,
2628
});
2729
},
@@ -44,6 +46,19 @@ YUI.add('ez-navigationitemview-tests', function (Y) {
4446
);
4547
},
4648

49+
"Should add the navigation identifier on the container": function () {
50+
var c = this.view.get('container');
51+
52+
Assert.isTrue(
53+
c.hasAttribute('data-navigation-item-identifier'),
54+
"The container should have the data-navigation-item-identifier"
55+
);
56+
Assert.areEqual(
57+
this.view.get('identifier'), c.getAttribute('data-navigation-item-identifier'),
58+
"The data-navigation-item-identifier should have the right identifier value"
59+
);
60+
},
61+
4762
"Test render": function () {
4863
var templateCalled = false,
4964
origTpl;

0 commit comments

Comments
 (0)