mirror of
https://github.com/nasa/openmct.git
synced 2025-01-01 10:56:41 +00:00
[Browse] Back Arrow
Refactored Back Arrow to work same as prior commit, however with less if else statements. Returns if not at root, otherwise root is set to true.
This commit is contained in:
parent
48136c2265
commit
f0c64b6b92
@ -141,16 +141,31 @@ define(
|
||||
|
||||
// Checks if the current object has a context
|
||||
if (context) {
|
||||
|
||||
// Sets the parent and the parent context
|
||||
// which is checked
|
||||
parent = context.getParent();
|
||||
parentContext = parent.getCapability('context');
|
||||
|
||||
if ((parent.getId() !== ROOT_ID) && parentContext) {
|
||||
// Gets the grandparent id
|
||||
grandparentId = parentContext.getParent().getId();
|
||||
|
||||
// Navigates to the parent
|
||||
navigateTo(parent);
|
||||
|
||||
// Checks after navigation if the user is located at the
|
||||
// root (grandparent of original selected object, after
|
||||
// navigation, user is at parent of original object and
|
||||
// child of grandparent)
|
||||
if (grandparentId && grandparentId !== ROOT_ID) {
|
||||
$scope.atRoot = false;
|
||||
} else {
|
||||
$scope.atRoot = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set at root if no grandparent exists and
|
||||
// if grandparent is ROOT, after navigation
|
||||
$scope.atRoot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,17 +182,22 @@ define(
|
||||
parentContext = parent.getCapability('context');
|
||||
if ((parent.getId() !== ROOT_ID) && parentContext) {
|
||||
grandparent = parentContext.getParent();
|
||||
if (!grandparent) {
|
||||
$scope.atRoot = true;
|
||||
} else {
|
||||
|
||||
// Checks if the grandparent exists
|
||||
// if it does not exist (for example in search),
|
||||
// than do not show the back button
|
||||
if (grandparent) {
|
||||
$scope.atRoot = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
// In any other situation where the context or parent
|
||||
// context does not exist or the user is at ROOT, than
|
||||
// hide the back arrow
|
||||
$scope.atRoot = true;
|
||||
}
|
||||
} else {
|
||||
$scope.atRoot = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Load the root object, put it in the scope.
|
||||
|
Loading…
Reference in New Issue
Block a user