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