Skip to content

Commit 14f1a1f

Browse files
author
Pete Richards
committed
Merge remote-tracking branch 'origin/open1031'
2 parents 5a6c209 + c0311be commit 14f1a1f

File tree

4 files changed

+189
-1
lines changed

4 files changed

+189
-1
lines changed

platform/commonUI/browse/bundle.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
define([
2424
"./src/BrowseController",
2525
"./src/PaneController",
26+
"./src/InspectorPaneController",
2627
"./src/BrowseObjectController",
2728
"./src/MenuArrowController",
2829
"./src/navigation/NavigationService",
@@ -44,6 +45,7 @@ define([
4445
], function (
4546
BrowseController,
4647
PaneController,
48+
InspectorPaneController,
4749
BrowseObjectController,
4850
MenuArrowController,
4951
NavigationService,
@@ -124,6 +126,17 @@ define([
124126
"depends": [
125127
"$scope"
126128
]
129+
},
130+
{
131+
"key": "InspectorPaneController",
132+
"implementation": InspectorPaneController,
133+
"priority": "preferred",
134+
"depends": [
135+
"$scope",
136+
"agentService",
137+
"$window",
138+
"navigationService"
139+
]
127140
}
128141
],
129142
"representations": [

platform/commonUI/browse/res/templates/browse.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
ng-class="{ collapsed : !modelPaneTree.visible() }"></a>
5858

5959
<div class='holder holder-object-and-inspector abs' id='content-area'
60-
ng-controller="PaneController as modelPaneInspect"
60+
ng-controller="InspectorPaneController as modelPaneInspect"
6161
ng-class="modelPaneInspect.visible() ? 'pane-inspect-showing' : 'pane-inspect-hidden'">
6262

6363
<mct-split-pane class='l-object-and-inspector contents abs' anchor='right'>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*****************************************************************************
2+
* Open MCT Web, Copyright (c) 2014-2015, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT Web includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
24+
define(
25+
["./PaneController"],
26+
function (PaneController) {
27+
28+
/**
29+
* Pane controller that reveals inspector, if hidden, when object
30+
* switches to edit mode.
31+
*
32+
* @param $scope
33+
* @param agentService
34+
* @param $window
35+
* @param navigationService
36+
* @constructor
37+
*/
38+
function InspectorPaneController($scope, agentService, $window, navigationService) {
39+
PaneController.call(this, $scope, agentService, $window);
40+
41+
var statusListener,
42+
self = this;
43+
44+
function showInspector(statuses) {
45+
if (statuses.indexOf('editing') !== -1 && !self.visible()) {
46+
self.toggle();
47+
}
48+
}
49+
50+
function attachStatusListener(domainObject) {
51+
// Remove existing status listener if existing
52+
if (statusListener) {
53+
statusListener();
54+
}
55+
56+
if (domainObject.hasCapability("status")) {
57+
statusListener = domainObject.getCapability("status").listen(showInspector);
58+
}
59+
return statusListener;
60+
}
61+
62+
var domainObject = navigationService.getNavigation();
63+
if (domainObject) {
64+
attachStatusListener(domainObject);
65+
}
66+
67+
var navigationListener = navigationService.addListener(attachStatusListener);
68+
69+
$scope.$on("$destroy", function () {
70+
statusListener();
71+
navigationListener();
72+
});
73+
}
74+
75+
InspectorPaneController.prototype = Object.create(PaneController.prototype);
76+
77+
return InspectorPaneController;
78+
}
79+
);
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*****************************************************************************
2+
* Open MCT Web, Copyright (c) 2014-2015, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT Web includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
define(
24+
["../src/InspectorPaneController"],
25+
function (InspectorPaneController) {
26+
27+
describe("The InspectorPaneController", function () {
28+
var mockScope,
29+
mockAgentService,
30+
mockDomainObject,
31+
mockWindow,
32+
mockStatusCapability,
33+
mockNavigationService,
34+
mockNavigationUnlistener,
35+
mockStatusUnlistener,
36+
controller;
37+
38+
beforeEach(function () {
39+
mockScope = jasmine.createSpyObj("$scope", ["$on"]);
40+
mockWindow = jasmine.createSpyObj("$window", ["open"]);
41+
mockAgentService = jasmine.createSpyObj(
42+
"agentService",
43+
["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"]
44+
);
45+
46+
mockNavigationUnlistener = jasmine.createSpy("navigationUnlistener");
47+
mockNavigationService = jasmine.createSpyObj(
48+
"navigationService",
49+
["getNavigation", "addListener"]
50+
);
51+
mockNavigationService.addListener.andReturn(mockNavigationUnlistener);
52+
53+
mockStatusUnlistener = jasmine.createSpy("statusUnlistener");
54+
mockStatusCapability = jasmine.createSpyObj(
55+
"statusCapability",
56+
["listen"]
57+
);
58+
mockStatusCapability.listen.andReturn(mockStatusUnlistener);
59+
60+
mockDomainObject = jasmine.createSpyObj(
61+
'domainObject',
62+
[
63+
'getId',
64+
'getModel',
65+
'getCapability',
66+
'hasCapability'
67+
]
68+
);
69+
mockDomainObject.getId.andReturn("domainObject");
70+
mockDomainObject.getModel.andReturn({});
71+
mockDomainObject.hasCapability.andReturn(true);
72+
mockDomainObject.getCapability.andReturn(mockStatusCapability);
73+
74+
controller = new InspectorPaneController(mockScope, mockAgentService, mockWindow, mockNavigationService);
75+
});
76+
77+
it("listens for changes to navigation and attaches a status" +
78+
" listener", function () {
79+
expect(mockNavigationService.addListener).toHaveBeenCalledWith(jasmine.any(Function));
80+
mockNavigationService.addListener.mostRecentCall.args[0](mockDomainObject);
81+
expect(mockStatusCapability.listen).toHaveBeenCalledWith(jasmine.any(Function));
82+
});
83+
84+
it("if hidden, shows the inspector when domain object switches to" +
85+
" edit mode", function () {
86+
controller.toggle();
87+
// test pre-condition that inspector is hidden
88+
expect(controller.visible()).toBe(false);
89+
mockNavigationService.addListener.mostRecentCall.args[0](mockDomainObject);
90+
mockStatusCapability.listen.mostRecentCall.args[0](["editing"]);
91+
expect(controller.visible()).toBe(true);
92+
});
93+
94+
});
95+
}
96+
);

0 commit comments

Comments
 (0)