Merge remote-tracking branch 'github/mobile' into open74-m-mobile

This commit is contained in:
Charles Hacskaylo 2015-08-27 11:34:14 -07:00
commit 80a91970f6
4 changed files with 75 additions and 19 deletions

View File

@ -23,6 +23,6 @@
<!-- Back Arrow Icon used on mobile--> <!-- Back Arrow Icon used on mobile-->
<a ng-controller="BrowseController" <a ng-controller="BrowseController"
class='type-icon icon ui-symbol s-back' 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> </a>

View File

@ -134,28 +134,70 @@ define(
// is not the root, then user is navigated to // is not the root, then user is navigated to
// parent // parent
function navigateToParent() { function navigateToParent() {
var parent = navigationService.getNavigation().getCapability('context').getParent(), var context = navigationService.getNavigation().getCapability('context'),
grandparent; parentContext,
if (parent.getId() !== ROOT_ID) { parent,
grandparent = parent.getCapability('context').getParent().getId(); grandparentId;
navigateTo(parent);
if (grandparent && grandparent !== ROOT_ID) { // Checks if the current object has a context
$scope.atRoot = false; if (context) {
} else {
// 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;
return;
}
// Set at root if no grandparent exists and
// if grandparent is ROOT, after navigation
$scope.atRoot = true; $scope.atRoot = true;
} }
} else {
$scope.atRoot = true;
} }
} }
function checkRoot() { function checkRoot() {
var parent = navigationService.getNavigation().getCapability('context').getParent(); var context = navigationService.getNavigation().getCapability('context'),
if (parent.getId() !== ROOT_ID) { parentContext,
$scope.atRoot = false; parent,
} else { grandparent;
$scope.atRoot = true;
// Checks if the current object has a context
if (context) {
parent = context.getParent();
parentContext = parent.getCapability('context');
if ((parent.getId() !== ROOT_ID) && parentContext) {
grandparent = parentContext.getParent();
// 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;
}
}
} }
// 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;
} }
// Load the root object, put it in the scope. // Load the root object, put it in the scope.

View File

@ -304,6 +304,19 @@ define(
); );
mockScope.checkRoot(); mockScope.checkRoot();
mockDomainObject.getCapability.andReturn(undefined);
mockNavigationService.getNavigation.andReturn(mockDomainObject);
controller = new BrowseController(
mockScope,
mockRoute,
mockLocation,
mockObjectService,
mockNavigationService
);
mockScope.checkRoot();
}); });
// Mocks the back arrow call that // Mocks the back arrow call that

View File

@ -29,8 +29,9 @@
key="'label'" key="'label'"
mct-object="domainObject" mct-object="domainObject"
ng-model="ngModel" ng-model="ngModel"
ng-click="!treeNode.checkMobile() || model.composition == undefined ? ng-click="!treeNode.checkMobile() || model.composition == undefined ||
ngModel.selectedObject = domainObject : toggle.toggle(); treeNode.trackExpansion()" model.composition.length == 0 ? treeNode.setObject(ngModel, domainObject) : toggle.toggle();
treeNode.trackExpansion()"
> >
</mct-representation> </mct-representation>
<span <span