[Context] Back Arrow

Checks the Back Arrow in both checkRoot and
navigateToParent, also checks grandparent in both.
This allows the back arrow to hide in search when
context is unavailable.
This commit is contained in:
Shivam Dave
2015-08-27 10:42:11 -07:00
parent 8c4c65241a
commit 48136c2265
2 changed files with 32 additions and 16 deletions

View File

@@ -23,6 +23,6 @@
<!-- Back Arrow Icon used on mobile-->
<a ng-controller="BrowseController"
class='type-icon icon ui-symbol s-back'
ng-click='backArrow()'
ng-class="checkRoot(); atRoot ? 'hidden' : ''">{
ng-class="checkRoot(); atRoot ? 'hidden' : ''"
ng-click='backArrow()'>{
</a>

View File

@@ -134,28 +134,44 @@ define(
// is not the root, then user is navigated to
// parent
function navigateToParent() {
var parent = navigationService.getNavigation().getCapability('context').getParent(),
grandparent;
if (parent.getId() !== ROOT_ID) {
grandparent = parent.getCapability('context').getParent().getId();
var context = navigationService.getNavigation().getCapability('context'),
parentContext,
parent,
grandparentId;
// Checks if the current object has a context
if (context) {
parent = context.getParent();
parentContext = parent.getCapability('context');
if ((parent.getId() !== ROOT_ID) && parentContext) {
grandparentId = parentContext.getParent().getId();
navigateTo(parent);
if (grandparent && grandparent !== ROOT_ID) {
if (grandparentId && grandparentId !== ROOT_ID) {
$scope.atRoot = false;
} else {
$scope.atRoot = true;
}
} else {
$scope.atRoot = true;
}
}
}
function checkRoot() {
var context = navigationService.getNavigation().getCapability('context'),
parent;
parentContext,
parent,
grandparent;
// Checks if the current object has a context
if (context) {
parent = context.getParent();
if (parent.getId() !== ROOT_ID) {
parentContext = parent.getCapability('context');
if ((parent.getId() !== ROOT_ID) && parentContext) {
grandparent = parentContext.getParent();
if (!grandparent) {
$scope.atRoot = true;
} else {
$scope.atRoot = false;
}
} else {
$scope.atRoot = true;
}