mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 13:43:09 +00:00
Merge remote-tracking branch 'origin/open716' into open-master
This commit is contained in:
commit
bc5d657015
@ -66,9 +66,8 @@ define(
|
||||
}
|
||||
|
||||
// Compute panel positions based on the layout's object model
|
||||
function lookupPanels(model) {
|
||||
var configuration = $scope.configuration || {},
|
||||
ids = (model || {}).composition || [];
|
||||
function lookupPanels(ids) {
|
||||
var configuration = $scope.configuration || {};
|
||||
|
||||
// Pull panel positions from configuration
|
||||
rawPositions = shallowCopy(configuration.panels || {}, ids);
|
||||
@ -77,14 +76,14 @@ define(
|
||||
positions = {};
|
||||
|
||||
// Update width/height that we are tracking
|
||||
gridSize = (model || {}).layoutGrid || DEFAULT_GRID_SIZE;
|
||||
gridSize = ($scope.model || {}).layoutGrid || DEFAULT_GRID_SIZE;
|
||||
|
||||
// Compute positions and add defaults where needed
|
||||
ids.forEach(populatePosition);
|
||||
}
|
||||
|
||||
// Position panes when the model field changes
|
||||
$scope.$watch("model", lookupPanels);
|
||||
$scope.$watch("model.composition", lookupPanels);
|
||||
|
||||
return {
|
||||
/**
|
||||
|
@ -38,15 +38,15 @@ define(
|
||||
|
||||
// Model changes will indicate that panel positions
|
||||
// may have changed, for instance.
|
||||
it("watches for changes to model", function () {
|
||||
it("watches for changes to composition", function () {
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"model",
|
||||
"model.composition",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it("provides styles for frames, from configuration", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel);
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel.composition);
|
||||
expect(controller.getFrameStyle("a")).toEqual({
|
||||
top: "320px",
|
||||
left: "640px",
|
||||
@ -59,7 +59,7 @@ define(
|
||||
var styleB, styleC;
|
||||
|
||||
// b and c do not have configured positions
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel);
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel.composition);
|
||||
|
||||
styleB = controller.getFrameStyle("b");
|
||||
styleC = controller.getFrameStyle("c");
|
||||
@ -76,7 +76,7 @@ define(
|
||||
|
||||
it("allows panels to be dragged", function () {
|
||||
// Populate scope
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel);
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel.composition);
|
||||
|
||||
// Verify precondtion
|
||||
expect(testConfiguration.panels.b).not.toBeDefined();
|
||||
@ -95,7 +95,7 @@ define(
|
||||
|
||||
it("invokes commit after drag", function () {
|
||||
// Populate scope
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel);
|
||||
mockScope.$watch.mostRecentCall.args[1](testModel.composition);
|
||||
|
||||
// Add a commit method to scope
|
||||
mockScope.commit = jasmine.createSpy("commit");
|
||||
|
@ -57,6 +57,34 @@ define(
|
||||
return new Representer($scope, element, attrs);
|
||||
});
|
||||
|
||||
// Populate scope with any capabilities indicated by the
|
||||
// representation's extension definition
|
||||
function refreshCapabilities() {
|
||||
var representation = representationMap[$scope.key],
|
||||
domainObject = $scope.domainObject,
|
||||
uses = ((representation || {}).uses || []);
|
||||
|
||||
if (domainObject) {
|
||||
// Update model
|
||||
$scope.model = domainObject.getModel();
|
||||
|
||||
// Provide any of the capabilities requested
|
||||
uses.forEach(function (used) {
|
||||
$log.debug([
|
||||
"Requesting capability ",
|
||||
used,
|
||||
" for representation ",
|
||||
$scope.key
|
||||
].join(""));
|
||||
$q.when(
|
||||
domainObject.useCapability(used)
|
||||
).then(function (c) {
|
||||
$scope[used] = c;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// General-purpose refresh mechanism; should set up the scope
|
||||
// as appropriate for current representation key and
|
||||
// domain object.
|
||||
@ -88,29 +116,14 @@ define(
|
||||
// Populate scope with fields associated with the current
|
||||
// domain object (if one has been passed in)
|
||||
if (domainObject) {
|
||||
// Always provide the model, as "model"
|
||||
$scope.model = domainObject.getModel();
|
||||
// Initialize any capabilities
|
||||
refreshCapabilities();
|
||||
|
||||
// Also provide the view configuration,
|
||||
// for the specific view
|
||||
$scope.configuration =
|
||||
($scope.model.configuration || {})[$scope.key] || {};
|
||||
|
||||
// Also provide any of the capabilities requested
|
||||
uses.forEach(function (used) {
|
||||
$log.debug([
|
||||
"Requesting capability ",
|
||||
used,
|
||||
" for representation ",
|
||||
$scope.key
|
||||
].join(""));
|
||||
$q.when(
|
||||
domainObject.useCapability(used)
|
||||
).then(function (c) {
|
||||
$scope[used] = c;
|
||||
});
|
||||
});
|
||||
|
||||
// Finally, wire up any additional behavior (such as
|
||||
// gestures) associated with this representation.
|
||||
activeRepresenters.forEach(function (representer) {
|
||||
@ -130,7 +143,7 @@ define(
|
||||
// Finally, also update when there is a new version of that
|
||||
// same domain object; these changes should be tracked in the
|
||||
// model's "modified" field, by the mutation capability.
|
||||
$scope.$watch("domainObject.getModel().modified", refresh);
|
||||
$scope.$watch("domainObject.getModel().modified", refreshCapabilities);
|
||||
|
||||
// Do one initial refresh, so that we don't need another
|
||||
// digest iteration just to populate the scope. Failure to
|
||||
|
@ -115,7 +115,7 @@ define(
|
||||
mockScope.key = "abc";
|
||||
|
||||
// Trigger the watch
|
||||
mockScope.$watch.mostRecentCall.args[1]();
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
|
||||
expect(mockScope.inclusion).toEqual("a/b/c/template.html");
|
||||
});
|
||||
@ -126,7 +126,7 @@ define(
|
||||
mockScope.key = "xyz";
|
||||
|
||||
// Trigger the watch
|
||||
mockScope.$watch.mostRecentCall.args[1]();
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
|
||||
expect(mockScope.inclusion).toEqual("x/y/z/template.html");
|
||||
});
|
||||
@ -138,7 +138,7 @@ define(
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
|
||||
// Trigger the watch
|
||||
mockScope.$watch.mostRecentCall.args[1]();
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
|
||||
expect(mockDomainObject.useCapability)
|
||||
.toHaveBeenCalledWith("testCapability");
|
||||
@ -155,7 +155,7 @@ define(
|
||||
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||
|
||||
// Trigger the watch
|
||||
mockScope.$watch.mostRecentCall.args[1]();
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
|
||||
// Should have gotten a warning - that's an unknown key
|
||||
expect(mockLog.warn).toHaveBeenCalled();
|
||||
|
Loading…
Reference in New Issue
Block a user