[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:
Pete Richards
2015-08-06 14:41:32 -07:00
parent f083d019a3
commit f72f88adfa
6 changed files with 112 additions and 360 deletions

View File

@ -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;
}