[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.
This commit is contained in:
Shivam Dave 2015-07-29 11:38:47 -07:00
parent 7e35e55f0b
commit 18348476c6
2 changed files with 14 additions and 2 deletions

View File

@ -59,7 +59,7 @@
"glyph": "Z", "glyph": "Z",
"name": "Remove", "name": "Remove",
"description": "Remove this object from its containing object.", "description": "Remove this object from its containing object.",
"depends": [ "$q" ] "depends": [ "$q", "navigationService" ]
}, },
{ {
"key": "save", "key": "save",

View File

@ -40,7 +40,7 @@ define(
* @constructor * @constructor
* @memberof module:editor/actions/remove-action * @memberof module:editor/actions/remove-action
*/ */
function RemoveAction($q, context) { function RemoveAction($q, navigationService, context) {
var object = (context || {}).domainObject; var object = (context || {}).domainObject;
/** /**
@ -69,6 +69,15 @@ define(
return persistence && persistence.persist(); 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 * Remove the object from its parent, as identified by its context
* capability. * capability.
@ -77,6 +86,9 @@ define(
*/ */
function removeFromContext(contextCapability) { function removeFromContext(contextCapability) {
var parent = contextCapability.getParent(); var parent = contextCapability.getParent();
// Goes to parent if deleting currently
// opened object
checkCurrentObjectNavigation(parent);
$q.when( $q.when(
parent.useCapability('mutation', doMutate) parent.useCapability('mutation', doMutate)
).then(function () { ).then(function () {