[Mobile] Merge

Merged with master, getting the
RemoveAction changes.
This commit is contained in:
Shivam Dave 2015-08-27 12:15:48 -07:00
commit 510e7d1261
3 changed files with 35 additions and 23 deletions

View File

@ -55,9 +55,7 @@ define(
RemoveAction.prototype.perform = function () {
var $q = this.$q,
navigationService = this.navigationService,
domainObject = this.domainObject,
ROOT_ID = "ROOT";
domainObject = this.domainObject;
/*
* Check whether an object ID matches the ID of the object being
* removed (used to filter a parent's composition to handle the
@ -84,35 +82,44 @@ define(
return persistence && persistence.persist();
}
// Checks current object and ascendants of current
// object with object being removed, if the current
// object or any in the current object's path is being removed,
// navigate back to parent of removed object.
/*
* Checks current object and ascendants of current
* object with object being removed, if the current
* object or any in the current object's path is being removed,
* navigate back to parent of removed object.
*/
function checkObjectNavigation(object, parentObject) {
// Traverse object starts at current location
var traverseObject = (navigationService).getNavigation();
// Stop at ROOT of folder path
while (traverseObject.getId() !== ROOT_ID) {
// If traverse object is object being removed
// navigate to parent of removed object
// Stop when object is not defined (above ROOT)
while (traverseObject) {
// If object currently traversed to is object being removed
// navigate to parent of current object and then exit loop
if (traverseObject.getId() === object.getId()) {
navigationService.setNavigation(parentObject);
return;
}
// Traverses to parent
// Traverses to parent of current object, moving
// up the ascendant path
traverseObject = traverseObject.getCapability('context').getParent();
}
}
/*
* Remove the object from its parent, as identified by its context
* capability.
* capability. Based on object's location and selected object's location
* user may be navigated to existing parent object
*/
function removeFromContext(object) {
var contextCapability = object.getCapability('context'),
parent = contextCapability.getParent();
// If currently within path of removed object(s),
// navigates to existing object up tree
checkObjectNavigation(object, parent);
return $q.when(
parent.useCapability('mutation', doMutate)
).then(function () {

View File

@ -33,9 +33,11 @@ define(
mockParent,
mockChildObject,
mockGrandchildObject,
mockRootObject,
mockContext,
mockChildContext,
mockGrandchildContext,
mockRootContext,
mockMutation,
mockPersistence,
mockType,
@ -67,6 +69,10 @@ define(
"domainObject",
[ "getId", "getCapability" ]
);
mockRootObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
);
mockQ = { when: mockPromise };
mockParent = {
getModel: function () {
@ -82,6 +88,7 @@ define(
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
@ -155,8 +162,6 @@ define(
});
it("removes parent of object currently navigated to", function () {
var mutator, result;
// Navigates to child object
mockNavigationService.getNavigation.andReturn(mockChildObject);
@ -187,18 +192,18 @@ define(
// domainObject (grandparent) is set as ROOT, child and grandchild
// are set objects not being removed
mockDomainObject.getId.andReturn("ROOT");
mockChildObject.getId.andReturn("not test");
mockGrandchildObject.getId.andReturn("not test");
mockDomainObject.getId.andReturn("test 1");
mockRootObject.getId.andReturn("ROOT");
mockChildObject.getId.andReturn("not test 2");
mockGrandchildObject.getId.andReturn("not test 3");
// Sets context for the grandchild, child, and domainObject
mockDomainObject.getCapability.andReturn(mockContext);
mockRootObject.getCapability.andReturn(mockRootContext);
mockChildObject.getCapability.andReturn(mockChildContext);
mockGrandchildObject.getCapability.andReturn(mockGrandchildContext);
// Parents of grandchild, child, and domainObject are set
mockContext.getParent.andReturn(mockParent);
mockChildContext.getParent.andReturn(mockDomainObject);
// Parents of grandchild and child are set
mockChildContext.getParent.andReturn(mockRootObject);
mockGrandchildContext.getParent.andReturn(mockChildObject);
mockType.hasFeature.andReturn(true);

View File

@ -23,7 +23,7 @@
},
{
"key": "ELASTIC_ROOT",
"value": "/elastic",
"value": "http://localhost:9200",
"priority": "fallback"
},
{