mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[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.
This commit is contained in:
@ -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.
|
* 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 () {
|
LocationCapability.prototype.getContextualLocation = function () {
|
||||||
var context = this.domainObject.getCapability("context"),
|
var context = this.domainObject.getCapability("context");
|
||||||
pathObjects,
|
|
||||||
pathIds;
|
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return '';
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.getParent().getId();
|
return context.getParent().getId();
|
||||||
@ -65,7 +66,7 @@ define(
|
|||||||
}
|
}
|
||||||
var model = this.domainObject.getModel();
|
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();
|
var model = this.domainObject.getModel();
|
||||||
|
|
||||||
return model.location === this.getLocation();
|
return model.location === this.getContextualLocation();
|
||||||
};
|
};
|
||||||
|
|
||||||
function createLocationCapability(domainObject) {
|
function createLocationCapability(domainObject) {
|
||||||
|
@ -83,7 +83,8 @@ define(
|
|||||||
|
|
||||||
if (oldLocationCapability.isOriginal()) {
|
if (oldLocationCapability.isOriginal()) {
|
||||||
return newLocationCapability.setPrimaryLocation(
|
return newLocationCapability.setPrimaryLocation(
|
||||||
newLocationCapability.getLocation()
|
newLocationCapability
|
||||||
|
.getContextualLocation()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -52,8 +52,8 @@ define(
|
|||||||
locationCapability = new LocationCapability(domainObject);
|
locationCapability = new LocationCapability(domainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns location", function () {
|
it("returns contextual location", function () {
|
||||||
expect(locationCapability.getLocation())
|
expect(locationCapability.getContextualLocation())
|
||||||
.toBe('root');
|
.toBe('root');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user