Skip to content

Commit

Permalink
Merge pull request ezsystems#833 from ezsystems/Fix-EZP-27144_Selecti…
Browse files Browse the repository at this point in the history
…ng_current_location_in_finder

Fix EZP-27144: Current location not viewable when content browsing
  • Loading branch information
StephaneDiot committed Apr 11, 2017
2 parents 858b5cc + a80dbe3 commit 67dfe1e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Expand Up @@ -60,6 +60,9 @@ YUI.add('ez-discoverybarviewservice', function (Y) {
startingLocationId: startingLocationId,
minDiscoverDepth: rootDepth,
confirmLabel: Y.eZ.trans('view.content.label', {}, 'bar'),
isSelectable: function (contentStruct) {
return startingLocationId !== contentStruct.location.get('id');
}
},
});
},
Expand Down
Expand Up @@ -131,11 +131,15 @@ 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");

Assert.areSame(
e.config.startingLocationId, this.locationId,
"startingLocationId should have the id of the current location of the locationViewView"
Expand All @@ -150,6 +154,40 @@ YUI.add('ez-discoverybarviewservice-tests', function (Y) {

Assert.isTrue(contentDiscoverFired, 'contentDiscover should be fired');
},

"Should NOT be able to select the current location when content discovering": function () {
var contentDiscoverFired = false;

this.service.on('contentDiscover', Y.bind(function (e) {
contentDiscoverFired = true;

Y.Assert.isFalse(
e.config.isSelectable({location: this.location}),
"isSelectable should return FALSE if location is the same"
);
}, this));
this.service.fire('browseAction');

Assert.isTrue(contentDiscoverFired, 'contentDiscover should be fired');
},

"Should be able to select any other location than the current location when content discovering": function () {
var contentDiscoverFired = false,
otherLocation = new Y.Base();

otherLocation.set('id', 'AnyOtherId');
this.service.on('contentDiscover', Y.bind(function (e) {
contentDiscoverFired = true;

Y.Assert.isTrue(
e.config.isSelectable({location: otherLocation}),
"isSelectable should return TRUE if location is not the same"
);
}, this));
this.service.fire('browseAction');

Assert.isTrue(contentDiscoverFired, 'contentDiscover should be fired');
},

"Should fire contentDiscover without starting location and minimum discover depth when current view is NOT a locationViewView": function () {
var contentDiscoverFired = false;
Expand Down

0 comments on commit 67dfe1e

Please sign in to comment.