mirror of
https://github.com/nasa/openmct.git
synced 2025-06-10 19:31:42 +00:00
Merge branch 'open-master' into open1223
Merge latest from master branch into topic branch for WTD-1223
This commit is contained in:
commit
a4ea0dd047
@ -35,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="abs object-holder">
|
<div class="abs object-holder">
|
||||||
<mct-representation key="representation.selected.key"
|
<mct-representation key="representation.selected.key"
|
||||||
mct-object="domainObject">
|
mct-object="representation.selected.key && domainObject">
|
||||||
</mct-representation>
|
</mct-representation>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -90,6 +90,10 @@ define(
|
|||||||
function lookupPanels(ids) {
|
function lookupPanels(ids) {
|
||||||
var configuration = $scope.configuration || {};
|
var configuration = $scope.configuration || {};
|
||||||
|
|
||||||
|
// ids is read from model.composition and may be undefined;
|
||||||
|
// fall back to an array if that occurs
|
||||||
|
ids = ids || [];
|
||||||
|
|
||||||
// Pull panel positions from configuration
|
// Pull panel positions from configuration
|
||||||
rawPositions = shallowCopy(configuration.panels || {}, ids);
|
rawPositions = shallowCopy(configuration.panels || {}, ids);
|
||||||
|
|
||||||
|
@ -94,14 +94,17 @@ define(
|
|||||||
function link($scope, element, attrs) {
|
function link($scope, element, attrs) {
|
||||||
var activeRepresenters = representers.map(function (Representer) {
|
var activeRepresenters = representers.map(function (Representer) {
|
||||||
return new Representer($scope, element, attrs);
|
return new Representer($scope, element, attrs);
|
||||||
});
|
}),
|
||||||
|
toClear = [], // Properties to clear out of scope on change
|
||||||
|
counter = 0;
|
||||||
|
|
||||||
// Populate scope with any capabilities indicated by the
|
// Populate scope with any capabilities indicated by the
|
||||||
// representation's extension definition
|
// representation's extension definition
|
||||||
function refreshCapabilities() {
|
function refreshCapabilities() {
|
||||||
var domainObject = $scope.domainObject,
|
var domainObject = $scope.domainObject,
|
||||||
representation = lookup($scope.key, domainObject),
|
representation = lookup($scope.key, domainObject),
|
||||||
uses = ((representation || {}).uses || []);
|
uses = ((representation || {}).uses || []),
|
||||||
|
myCounter = counter;
|
||||||
|
|
||||||
if (domainObject) {
|
if (domainObject) {
|
||||||
// Update model
|
// Update model
|
||||||
@ -115,10 +118,16 @@ define(
|
|||||||
" for representation ",
|
" for representation ",
|
||||||
$scope.key
|
$scope.key
|
||||||
].join(""));
|
].join(""));
|
||||||
|
|
||||||
$q.when(
|
$q.when(
|
||||||
domainObject.useCapability(used)
|
domainObject.useCapability(used)
|
||||||
).then(function (c) {
|
).then(function (c) {
|
||||||
|
// Avoid clobbering capabilities from
|
||||||
|
// subsequent representations;
|
||||||
|
// Angular reuses scopes.
|
||||||
|
if (counter === myCounter) {
|
||||||
$scope[used] = c;
|
$scope[used] = c;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -130,8 +139,7 @@ define(
|
|||||||
function refresh() {
|
function refresh() {
|
||||||
var domainObject = $scope.domainObject,
|
var domainObject = $scope.domainObject,
|
||||||
representation = lookup($scope.key, domainObject),
|
representation = lookup($scope.key, domainObject),
|
||||||
uses = ((representation || {}).uses || []),
|
uses = ((representation || {}).uses || []);
|
||||||
gestureKeys = ((representation || {}).gestures || []);
|
|
||||||
|
|
||||||
// Create an empty object named "representation", for this
|
// Create an empty object named "representation", for this
|
||||||
// representation to store local variables into.
|
// representation to store local variables into.
|
||||||
@ -152,9 +160,19 @@ define(
|
|||||||
$log.warn("No representation found for " + $scope.key);
|
$log.warn("No representation found for " + $scope.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear out the scope from the last representation
|
||||||
|
toClear.forEach(function (property) {
|
||||||
|
delete $scope[property];
|
||||||
|
});
|
||||||
|
|
||||||
// Populate scope with fields associated with the current
|
// Populate scope with fields associated with the current
|
||||||
// domain object (if one has been passed in)
|
// domain object (if one has been passed in)
|
||||||
if (domainObject) {
|
if (domainObject) {
|
||||||
|
// Track how many representations we've made in this scope,
|
||||||
|
// to ensure that the correct representations are matched to
|
||||||
|
// the correct object/key pairs.
|
||||||
|
counter += 1;
|
||||||
|
|
||||||
// Initialize any capabilities
|
// Initialize any capabilities
|
||||||
refreshCapabilities();
|
refreshCapabilities();
|
||||||
|
|
||||||
@ -168,6 +186,10 @@ define(
|
|||||||
activeRepresenters.forEach(function (representer) {
|
activeRepresenters.forEach(function (representer) {
|
||||||
representer.represent(representation, domainObject);
|
representer.represent(representation, domainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Track which properties we want to clear from scope
|
||||||
|
// next change object/key pair changes
|
||||||
|
toClear = uses.concat(['model']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +181,25 @@ define(
|
|||||||
// Should have gotten a warning - that's an unknown key
|
// Should have gotten a warning - that's an unknown key
|
||||||
expect(mockLog.warn).toHaveBeenCalled();
|
expect(mockLog.warn).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("clears out obsolete peroperties from scope", function () {
|
||||||
|
mctRepresentation.link(mockScope, mockElement);
|
||||||
|
|
||||||
|
mockScope.key = "def";
|
||||||
|
mockScope.domainObject = mockDomainObject;
|
||||||
|
mockDomainObject.useCapability.andReturn("some value");
|
||||||
|
|
||||||
|
// Trigger the watch
|
||||||
|
mockScope.$watch.calls[0].args[1]();
|
||||||
|
expect(mockScope.testCapability).toBeDefined();
|
||||||
|
|
||||||
|
// Change the view
|
||||||
|
mockScope.key = "xyz";
|
||||||
|
|
||||||
|
// Trigger the watch again; should clear capability from scope
|
||||||
|
mockScope.$watch.calls[0].args[1]();
|
||||||
|
expect(mockScope.testCapability).toBeUndefined();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
x
Reference in New Issue
Block a user