mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 04:38:15 +00:00
[Location] Use parent id as location
Use the parent id as the location for a model. This greatly reduces the recursive work that must be done during move operations to keep the location accurate. Additionally, the locationService now implements a method `persistLocation` which can be used to persist the current object location as it's original location.
This commit is contained in:
@ -121,25 +121,8 @@ define(
|
||||
|
||||
// Store the location of an object relative to it's parent.
|
||||
function addLocationToModel(modelId, model, parent) {
|
||||
var context = parent.getCapability("context"),
|
||||
pathObjects,
|
||||
pathIds;
|
||||
model.location = parent.getId();
|
||||
|
||||
if (!context) {
|
||||
$log.warn('No parent context, location will not be set.');
|
||||
return model;
|
||||
}
|
||||
|
||||
pathObjects = context.getPath();
|
||||
if (!pathObjects || !pathObjects.length) {
|
||||
pathObjects = [];
|
||||
}
|
||||
pathIds = pathObjects.map(function (object) {
|
||||
return object.getId();
|
||||
});
|
||||
pathIds.push(modelId);
|
||||
|
||||
model.location = pathIds.join('/');
|
||||
return model;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user