[Treeview] Open in new tab settings

When an object is opened in a new tab, the left
pane will be closed by default. Otherwise it will
be open by default. #72.
This commit is contained in:
slhale 2015-08-20 13:13:14 -07:00
parent 503c8e2f03
commit 79529e4879
3 changed files with 15 additions and 4 deletions

View File

@ -21,7 +21,7 @@
{
"key": "BrowseObjectController",
"implementation": "BrowseObjectController.js",
"depends": [ "$scope", "$location", "$route" ]
"depends": [ "$scope", "$location", "$route", "$window" ]
},
{
"key": "CreateMenuController",

View File

@ -31,7 +31,7 @@ define(
* object (the right-hand side of Browse mode.)
* @constructor
*/
function BrowseObjectController($scope, $location, $route) {
function BrowseObjectController($scope, $location, $route, $window) {
function setViewForDomainObject(domainObject) {
var locationViewKey = $location.search().view;
@ -64,7 +64,15 @@ define(
}
}
$scope.ngModel.leftPane = true;
// If there is a defined opener, assume that the window was opened
// by choosing 'Open in a new tab'
if ($window.opener) {
// The desired default for this is to have a closed left pane
$scope.ngModel.leftPane = false;
} else {
// Otherwise, start the application with an open left pane
$scope.ngModel.leftPane = true;
}
$scope.$watch('domainObject', setViewForDomainObject);
$scope.$watch('representation.selected.key', updateQueryParam);

View File

@ -31,6 +31,7 @@ define(
var mockScope,
mockLocation,
mockRoute,
mockWindow,
mockUnlisten,
controller;
@ -50,6 +51,7 @@ define(
);
mockScope.ngModel = {};
mockRoute = { current: { params: {} } };
mockWindow = {};
mockLocation = jasmine.createSpyObj(
"$location",
[ "path", "search" ]
@ -61,7 +63,8 @@ define(
controller = new BrowseObjectController(
mockScope,
mockLocation,
mockRoute
mockRoute,
mockWindow
);
});