[Mobile/Bug] RemoveAction

When removing object you have
openned, now compares the currentObj
id with the removed obj id, resulting
in navigating to parent if they are the
same.
This commit is contained in:
Shivam Dave 2015-07-30 13:27:56 -07:00
parent 2d1aa65d63
commit 1624866656

View File

@ -69,10 +69,10 @@ define(
return persistence && persistence.persist(); return persistence && persistence.persist();
} }
function checkCurrentObjectNavigation(parent) { // Checks current object with object being removed
var currentParent = navigationService.getNavigation() function checkCurrentObjectNavigation(object, parent) {
.getCapability('context').getParent(); var currentObj = navigationService.getNavigation();
if (currentParent.getId() === parent.getId()) { if (currentObj.getId() === object.getId()) {
navigationService.setNavigation(parent); navigationService.setNavigation(parent);
} }
} }
@ -80,14 +80,14 @@ define(
/** /**
* Remove the object from its parent, as identified by its context * Remove the object from its parent, as identified by its context
* capability. * capability.
* @param {ContextCapability} contextCapability the "context" capability * @param {object} domain object being removed contextCapability
* of the domain object being removed. gotten from the "context" capability of this object
*/ */
function removeFromContext(contextCapability) { function removeFromContext(object) {
var parent = contextCapability.getParent(); var contextCapability = object.getCapability('context'),
// Goes to parent if deleting currently parent = contextCapability.getParent();
// opened object // Navigates to parent if deleting current object
checkCurrentObjectNavigation(parent); checkCurrentObjectNavigation(object, parent);
$q.when( $q.when(
parent.useCapability('mutation', doMutate) parent.useCapability('mutation', doMutate)
).then(function () { ).then(function () {
@ -102,7 +102,7 @@ define(
* fulfilled when the action has completed. * fulfilled when the action has completed.
*/ */
perform: function () { perform: function () {
return $q.when(object.getCapability('context')) return $q.when(object)
.then(removeFromContext); .then(removeFromContext);
} }
}; };