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

EZP-26120: Expose the navigation items identifier in the navigation hub #654

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ YUI.add('ez-navigationitemview', function (Y) {
*/
Y.eZ.NavigationItemView = Y.Base.create('navigationItemView', Y.eZ.TemplateBasedView, [], {
initializer: function () {
this.containerTemplate = '<li class="' + this._generateViewClassName(this._getName()) + '"/>';
var dataNavigationIdentifier = 'data-navigation-item-identifier="' + this.get('identifier') + '"';

this.containerTemplate = '<li class="' + this._generateViewClassName(this._getName()) + '" ' + dataNavigationIdentifier + '/>';
this.after('selectedChange', this._uiSelectedChange);
this.after('routeChange', function (){
this.render();
Expand Down
15 changes: 15 additions & 0 deletions Tests/js/views/navigation/assets/ez-navigationitemview-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ YUI.add('ez-navigationitemview-tests', function (Y) {

setUp: function () {
this.title = "Title";
this.identifier = 'title';
this.route = {
name: "viewLocation",
params: {
Expand All @@ -22,6 +23,7 @@ YUI.add('ez-navigationitemview-tests', function (Y) {
};
this.view = new Y.eZ.NavigationItemView({
title: this.title,
identifier: this.identifier,
route: this.route,
});
},
Expand All @@ -44,6 +46,19 @@ YUI.add('ez-navigationitemview-tests', function (Y) {
);
},

"Should add the navigation identifier on the container": function () {
var c = this.view.get('container');

Assert.isTrue(
c.hasAttribute('data-navigation-item-identifier'),
"The container should have the data-navigation-item-identifier"
);
Assert.areEqual(
this.view.get('identifier'), c.getAttribute('data-navigation-item-identifier'),
"The data-navigation-item-identifier should have the right identifier value"
);
},

"Test render": function () {
var templateCalled = false,
origTpl;
Expand Down