From 11b86143c2798be9b583f55f658a94560cc00e67 Mon Sep 17 00:00:00 2001 From: stephaneDiot Date: Tue, 4 Apr 2017 14:53:26 +0200 Subject: [PATCH] Fix EZP-27144: Current location not viewable when content browsing --- .../views/services/ez-discoverybarviewservice.js | 6 ++++++ .../assets/ez-discoverybarviewservice-tests.js | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Resources/public/js/views/services/ez-discoverybarviewservice.js b/Resources/public/js/views/services/ez-discoverybarviewservice.js index ca33c92ab..0b8bc33e9 100644 --- a/Resources/public/js/views/services/ez-discoverybarviewservice.js +++ b/Resources/public/js/views/services/ez-discoverybarviewservice.js @@ -60,6 +60,12 @@ YUI.add('ez-discoverybarviewservice', function (Y) { startingLocationId: startingLocationId, minDiscoverDepth: rootDepth, confirmLabel: Y.eZ.trans('view.content.label', {}, 'bar'), + isSelectable: function(contentStruct) { + if (startingLocationId === contentStruct.location.get('id')) { + return false; + } + return true; + } }, }); }, diff --git a/Tests/js/views/services/assets/ez-discoverybarviewservice-tests.js b/Tests/js/views/services/assets/ez-discoverybarviewservice-tests.js index 6ae7890ca..490be1b1f 100644 --- a/Tests/js/views/services/assets/ez-discoverybarviewservice-tests.js +++ b/Tests/js/views/services/assets/ez-discoverybarviewservice-tests.js @@ -131,11 +131,24 @@ YUI.add('ez-discoverybarviewservice-tests', function (Y) { }, "Should fire contentDiscover with a starting location on browseAction event": function () { - var contentDiscoverFired = false; + var contentDiscoverFired = false, + otherLocation = new Y.Base(); + otherLocation.set('id', 'AnyOtherId'); this.service.on('contentDiscover', Y.bind(function (e) { contentDiscoverFired = true; + Assert.isFunction(e.config.isSelectable, "config should have a function named isSelectable"); + + Y.Assert.isTrue( + e.config.isSelectable({location: otherLocation}), + "isSelectable should return TRUE if selected content is container" + ); + Y.Assert.isFalse( + e.config.isSelectable({location: this.location}), + "isSelectable should return FALSE if selected content is container" + ); + Assert.areSame( e.config.startingLocationId, this.locationId, "startingLocationId should have the id of the current location of the locationViewView"