From 18348476c6800943e68a95a3b57f21290bbdf274 Mon Sep 17 00:00:00 2001 From: Shivam Dave Date: Wed, 29 Jul 2015 11:38:47 -0700 Subject: [PATCH] [Mobile] RemoveAction Tweak If you remove an object you are currently within/opened, then on removal of it you navigate to the parent of whatever you removed. --- platform/commonUI/edit/bundle.json | 2 +- platform/commonUI/edit/src/actions/RemoveAction.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/edit/bundle.json b/platform/commonUI/edit/bundle.json index 2aed41c2ee..c216a9d877 100644 --- a/platform/commonUI/edit/bundle.json +++ b/platform/commonUI/edit/bundle.json @@ -59,7 +59,7 @@ "glyph": "Z", "name": "Remove", "description": "Remove this object from its containing object.", - "depends": [ "$q" ] + "depends": [ "$q", "navigationService" ] }, { "key": "save", diff --git a/platform/commonUI/edit/src/actions/RemoveAction.js b/platform/commonUI/edit/src/actions/RemoveAction.js index fbf47d22d9..f0ed09d161 100644 --- a/platform/commonUI/edit/src/actions/RemoveAction.js +++ b/platform/commonUI/edit/src/actions/RemoveAction.js @@ -40,7 +40,7 @@ define( * @constructor * @memberof module:editor/actions/remove-action */ - function RemoveAction($q, context) { + function RemoveAction($q, navigationService, context) { var object = (context || {}).domainObject; /** @@ -69,6 +69,15 @@ define( return persistence && persistence.persist(); } + function checkCurrentObjectNavigation(parent) { + var currParent = navigationService.getNavigation().getCapability('context').getParent() + if(currParent.getId() === parent.getId()) { + navigationService.setNavigation(parent); + } else { + console.log("ALL GOOD"); + } + } + /** * Remove the object from its parent, as identified by its context * capability. @@ -77,6 +86,9 @@ define( */ function removeFromContext(contextCapability) { var parent = contextCapability.getParent(); + // Goes to parent if deleting currently + // opened object + checkCurrentObjectNavigation(parent); $q.when( parent.useCapability('mutation', doMutate) ).then(function () {