[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

@@ -103,21 +103,13 @@ define(
mockPromise(true)
);
mockContextCapability.getPath.andReturn([
{
getId: function () { return 'root'; }
},
{
getId: function () { return 'parent'; }
}
]);
mockParentObject.getCapability.andCallFake(function (key) {
return mockCapabilities[key];
});
mockParentObject.useCapability.andCallFake(function (key, value) {
return mockCapabilities[key].invoke(value);
});
mockParentObject.getId.andReturn('parentId');
mockPersistenceCapability.persist.andReturn(
mockPromise(true)
@@ -209,16 +201,15 @@ define(
expect(mockLog.error).toHaveBeenCalled();
});
it("stores location on new domainObjects", function() {
it("stores location on new domainObjects", function () {
var model = { name: "my model" };
var objectPromise = creationService.createObject(
model,
mockParentObject
);
expect(model.location).toBeDefined();
expect(model.location.indexOf('root/parent')).toBe(0);
expect(model.location).toBe('parentId');
});
});
}
);
);