[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();
}
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);
}
};