mirror of
https://github.com/nasa/openmct.git
synced 2025-03-23 12:35:48 +00:00
[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:
parent
7e35e55f0b
commit
18348476c6
@ -59,7 +59,7 @@
|
||||
"glyph": "Z",
|
||||
"name": "Remove",
|
||||
"description": "Remove this object from its containing object.",
|
||||
"depends": [ "$q" ]
|
||||
"depends": [ "$q", "navigationService" ]
|
||||
},
|
||||
{
|
||||
"key": "save",
|
||||
|
@ -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 () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user