From 94854e5965f425a5aa8059d478f4074b38e5bb6c Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Wed, 19 Aug 2015 11:28:58 -0700 Subject: [PATCH] [Location] can retrieve contextual location Clarify naming of method for retrieving contextual location of a domain object. Default behavior for objects that do not have a context is to return undefined. Note that default behavior is not specified and could change if needed. --- .../src/capabilities/LocationCapability.js | 17 +++++++++-------- .../entanglement/src/services/MoveService.js | 3 ++- .../test/capabilities/LocationCapabilitySpec.js | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/platform/entanglement/src/capabilities/LocationCapability.js b/platform/entanglement/src/capabilities/LocationCapability.js index c55d15787d..1bc2f8b931 100644 --- a/platform/entanglement/src/capabilities/LocationCapability.js +++ b/platform/entanglement/src/capabilities/LocationCapability.js @@ -40,16 +40,17 @@ define( }; /** - * Return the current location of the current domain object. Only + * Returns the contextual location of the current domain object. Only * valid for domain objects that have a context capability. + * + * @returns {String} the contextual location of the object; the id of + * its parent. */ - LocationCapability.prototype.getLocation = function () { - var context = this.domainObject.getCapability("context"), - pathObjects, - pathIds; + LocationCapability.prototype.getContextualLocation = function () { + var context = this.domainObject.getCapability("context"); if (!context) { - return ''; + return; } return context.getParent().getId(); @@ -65,7 +66,7 @@ define( } var model = this.domainObject.getModel(); - return model.location !== this.getLocation(); + return model.location !== this.getContextualLocation(); }; /** @@ -78,7 +79,7 @@ define( } var model = this.domainObject.getModel(); - return model.location === this.getLocation(); + return model.location === this.getContextualLocation(); }; function createLocationCapability(domainObject) { diff --git a/platform/entanglement/src/services/MoveService.js b/platform/entanglement/src/services/MoveService.js index c5406f93c6..9dc8b80169 100644 --- a/platform/entanglement/src/services/MoveService.js +++ b/platform/entanglement/src/services/MoveService.js @@ -83,7 +83,8 @@ define( if (oldLocationCapability.isOriginal()) { return newLocationCapability.setPrimaryLocation( - newLocationCapability.getLocation() + newLocationCapability + .getContextualLocation() ); } }) diff --git a/platform/entanglement/test/capabilities/LocationCapabilitySpec.js b/platform/entanglement/test/capabilities/LocationCapabilitySpec.js index 8c96500a8a..9cbfcc1bea 100644 --- a/platform/entanglement/test/capabilities/LocationCapabilitySpec.js +++ b/platform/entanglement/test/capabilities/LocationCapabilitySpec.js @@ -52,8 +52,8 @@ define( locationCapability = new LocationCapability(domainObject); }); - it("returns location", function () { - expect(locationCapability.getLocation()) + it("returns contextual location", function () { + expect(locationCapability.getContextualLocation()) .toBe('root'); });