From c6df7cebe5674d1b49f0a6e103937b33a9461966 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 9 Sep 2015 17:25:02 -0700 Subject: [PATCH] [Angular] Check for context capability Check for existence of context capability from Remove action during navigation check. This avoids an exception that appears to have been swallowed in earlier versions of Angular. --- .../commonUI/edit/src/actions/RemoveAction.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/platform/commonUI/edit/src/actions/RemoveAction.js b/platform/commonUI/edit/src/actions/RemoveAction.js index 2d8e224491..092964651c 100644 --- a/platform/commonUI/edit/src/actions/RemoveAction.js +++ b/platform/commonUI/edit/src/actions/RemoveAction.js @@ -81,7 +81,7 @@ define( var persistence = domainObject.getCapability('persistence'); return persistence && persistence.persist(); } - + /* * Checks current object and ascendants of current * object with object being removed, if the current @@ -90,11 +90,12 @@ define( */ function checkObjectNavigation(object, parentObject) { // Traverse object starts at current location - var traverseObject = (navigationService).getNavigation(); - + var traverseObject = (navigationService).getNavigation(), + context; + // 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()) { @@ -103,7 +104,8 @@ define( } // Traverses to parent of current object, moving // up the ascendant path - traverseObject = traverseObject.getCapability('context').getParent(); + context = traverseObject.getCapability('context'); + traverseObject = context && context.getParent(); } } @@ -115,11 +117,11 @@ define( 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 () {