Fix for Pane controller issue#1670
This commit is contained in:
Pete Richards
2017-08-17 16:10:20 -07:00
committed by GitHub
8 changed files with 60 additions and 16 deletions

View File

@@ -21,7 +21,7 @@
"bower": "^1.7.7", "bower": "^1.7.7",
"git-rev-sync": "^1.4.0", "git-rev-sync": "^1.4.0",
"glob": ">= 3.0.0", "glob": ">= 3.0.0",
"gulp": "^3.9.0", "gulp": "^3.9.1",
"gulp-header": "^1.8.8", "gulp-header": "^1.8.8",
"gulp-jscs": "^3.0.2", "gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.0.0", "gulp-jshint": "^2.0.0",

View File

@@ -107,7 +107,9 @@ define([
"depends": [ "depends": [
"$scope", "$scope",
"agentService", "agentService",
"$window" "$window",
"$location",
"$attrs"
] ]
}, },
{ {
@@ -134,7 +136,9 @@ define([
"$scope", "$scope",
"agentService", "agentService",
"$window", "$window",
"navigationService" "navigationService",
"$location",
"$attrs"
] ]
} }
], ],

View File

@@ -24,7 +24,7 @@
<mct-include key="'topbar-browse'"></mct-include> <mct-include key="'topbar-browse'"></mct-include>
<div class="abs holder holder-main browse-area s-browse-area browse-wrapper" <div class="abs holder holder-main browse-area s-browse-area browse-wrapper"
ng-controller="PaneController as modelPaneTree" ng-controller="PaneController as modelPaneTree"
ng-class="modelPaneTree.visible() ? 'pane-tree-showing' : 'pane-tree-hidden'"> ng-class="modelPaneTree.visible() ? 'pane-tree-showing' : 'pane-tree-hidden'" hide-parameter="hideTree">
<mct-split-pane class='abs contents' <mct-split-pane class='abs contents'
anchor='left' alias="leftSide"> anchor='left' alias="leftSide">
<div class='split-pane-component treeview pane left'> <div class='split-pane-component treeview pane left'>
@@ -58,7 +58,8 @@
<div class='holder holder-object-and-inspector abs' id='content-area' <div class='holder holder-object-and-inspector abs' id='content-area'
ng-controller="InspectorPaneController as modelPaneInspect" ng-controller="InspectorPaneController as modelPaneInspect"
ng-class="modelPaneInspect.visible() ? 'pane-inspect-showing' : 'pane-inspect-hidden'"> ng-class="modelPaneInspect.visible() ? 'pane-inspect-showing' : 'pane-inspect-hidden'"
hide-parameter="hideInspector">
<mct-split-pane class='l-object-and-inspector contents abs' anchor='right' alias="rightSide"> <mct-split-pane class='l-object-and-inspector contents abs' anchor='right' alias="rightSide">
<div class='split-pane-component t-object pane primary-pane left'> <div class='split-pane-component t-object pane primary-pane left'>

View File

@@ -35,9 +35,8 @@ define(
* @param navigationService * @param navigationService
* @constructor * @constructor
*/ */
function InspectorPaneController($scope, agentService, $window, navigationService) { function InspectorPaneController($scope, agentService, $window, navigationService, $location, $attrs) {
PaneController.call(this, $scope, agentService, $window); PaneController.call(this, $scope, agentService, $window, $location, $attrs);
var statusListener, var statusListener,
self = this; self = this;

View File

@@ -31,12 +31,17 @@ define(
* @constructor * @constructor
* @memberof platform/commonUI/browse * @memberof platform/commonUI/browse
*/ */
function PaneController($scope, agentService, $window) { function PaneController($scope, agentService, $window, $location, $attrs) {
var self = this; var self = this;
this.agentService = agentService; this.agentService = agentService;
var hideParameterPresent = $location.search().hasOwnProperty($attrs.hideParameter);
// Fast and cheap: if this has been opened in a new window, hide panes by default if ($attrs.hideParameter && hideParameterPresent) {
this.state = !$window.opener; this.state = false;
$location.search($attrs.hideParameter, undefined);
} else {
this.state = true;
}
/** /**
* Callback to invoke when any selection occurs in the tree. * Callback to invoke when any selection occurs in the tree.
@@ -70,7 +75,7 @@ define(
* @returns {boolean} true when visible * @returns {boolean} true when visible
*/ */
PaneController.prototype.visible = function () { PaneController.prototype.visible = function () {
return this.state; return !!this.state;
}; };
return PaneController; return PaneController;

View File

@@ -38,6 +38,7 @@ define(
this.urlService = urlService; this.urlService = urlService;
this.open = function () { this.open = function () {
arguments[0] += "&hideTree=true&hideInspector=true";
$window.open.apply($window, arguments); $window.open.apply($window, arguments);
}; };

View File

@@ -33,7 +33,9 @@ define(
mockNavigationService, mockNavigationService,
mockNavigationUnlistener, mockNavigationUnlistener,
mockStatusUnlistener, mockStatusUnlistener,
controller; controller,
mockLocation,
mockAttrs;
beforeEach(function () { beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", ["$on"]); mockScope = jasmine.createSpyObj("$scope", ["$on"]);
@@ -71,7 +73,12 @@ define(
mockDomainObject.hasCapability.andReturn(true); mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.getCapability.andReturn(mockStatusCapability); mockDomainObject.getCapability.andReturn(mockStatusCapability);
controller = new InspectorPaneController(mockScope, mockAgentService, mockWindow, mockNavigationService); mockLocation = jasmine.createSpyObj('location', ['search']);
mockLocation.search.andReturn({});
mockAttrs = {};
controller = new InspectorPaneController(mockScope, mockAgentService, mockWindow, mockNavigationService, mockLocation, mockAttrs);
}); });
it("listens for changes to navigation and attaches a status" + it("listens for changes to navigation and attaches a status" +

View File

@@ -29,7 +29,9 @@ define(
mockAgentService, mockAgentService,
mockDomainObjects, mockDomainObjects,
mockWindow, mockWindow,
controller; controller,
mockLocation,
mockAttrs;
// We want to reinstantiate for each test case // We want to reinstantiate for each test case
// because device state can influence constructor-time behavior // because device state can influence constructor-time behavior
@@ -37,7 +39,9 @@ define(
return new PaneController( return new PaneController(
mockScope, mockScope,
mockAgentService, mockAgentService,
mockWindow mockWindow,
mockLocation,
mockAttrs
); );
} }
@@ -59,6 +63,11 @@ define(
["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"] ["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"]
); );
mockWindow = jasmine.createSpyObj("$window", ["open"]); mockWindow = jasmine.createSpyObj("$window", ["open"]);
mockLocation = jasmine.createSpyObj('location', ['search']);
mockLocation.search.andReturn({});
mockAttrs = {};
}); });
it("is initially visible", function () { it("is initially visible", function () {
@@ -86,6 +95,24 @@ define(
// Tree should have collapsed // Tree should have collapsed
expect(controller.visible()).toBeFalsy(); expect(controller.visible()).toBeFalsy();
}); });
describe("specifying hideParameter", function () {
beforeEach(function () {
mockAttrs = {hideParameter: 'hideTree'};
});
it("sets pane state to false when in location.search", function () {
mockLocation.search.andReturn({'hideTree': true});
expect(instantiateController().visible()).toBe(false);
expect(mockLocation.search).toHaveBeenCalledWith('hideTree', undefined);
});
it("sets state to true when not found in location.search", function () {
mockLocation.search.andReturn({});
expect(instantiateController().visible()).toBe(true);
expect(mockLocation.search).not.toHaveBeenCalledWith('hideTree', undefined);
});
});
}); });
} }
); );