mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 16:36:13 +00:00
[Representation] Check full ID path
...when determining if a representation needs to be refreshed. Avoids representations becoming stale when switching or navigating among linked instances of the same domain object. https://github.com/nasa/openmctweb/issues/302
This commit is contained in:
parent
3fd4304de1
commit
2514e44083
@ -96,7 +96,7 @@ define(
|
||||
toClear = [], // Properties to clear out of scope on change
|
||||
counter = 0,
|
||||
couldRepresent = false,
|
||||
lastId,
|
||||
lastIdPath = [],
|
||||
lastKey,
|
||||
changeTemplate = templateLinker.link($scope, element);
|
||||
|
||||
@ -143,11 +143,24 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
function unchanged(canRepresent, id, key) {
|
||||
function unchanged(canRepresent, idPath, key) {
|
||||
return canRepresent &&
|
||||
couldRepresent &&
|
||||
id === lastId &&
|
||||
key === lastKey;
|
||||
key === lastKey &&
|
||||
idPath.length === lastIdPath.length &&
|
||||
idPath.every(function (id, i) {
|
||||
return id === lastIdPath[i];
|
||||
});
|
||||
}
|
||||
|
||||
function getIdPath(domainObject) {
|
||||
if (!domainObject) {
|
||||
return [];
|
||||
}
|
||||
return domainObject.getCapability('context')
|
||||
.getPath().map(function (pathObject) {
|
||||
return pathObject.getId();
|
||||
});
|
||||
}
|
||||
|
||||
// General-purpose refresh mechanism; should set up the scope
|
||||
@ -159,10 +172,10 @@ define(
|
||||
path = representation && getPath(representation),
|
||||
uses = ((representation || {}).uses || []),
|
||||
canRepresent = !!(path && domainObject),
|
||||
id = domainObject && domainObject.getId(),
|
||||
idPath = getIdPath(domainObject),
|
||||
key = $scope.key;
|
||||
|
||||
if (unchanged(canRepresent, id, key)) {
|
||||
if (unchanged(canRepresent, idPath, key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -190,7 +203,7 @@ define(
|
||||
|
||||
// To allow simplified change detection next time around
|
||||
couldRepresent = canRepresent;
|
||||
lastId = id;
|
||||
lastIdPath = idPath;
|
||||
lastKey = key;
|
||||
|
||||
// Populate scope with fields associated with the current
|
||||
|
Loading…
x
Reference in New Issue
Block a user