mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
[Tree] Show root for most trees
Modify tree so that it includes its root in most cases, for WTD-922.
This commit is contained in:
parent
bb4ea2d4ae
commit
d863c2843c
@ -151,6 +151,12 @@
|
||||
{
|
||||
"key": "tree",
|
||||
"templateUrl": "templates/tree.html",
|
||||
"type": "root",
|
||||
"priority": "preferred"
|
||||
},
|
||||
{
|
||||
"key": "tree",
|
||||
"templateUrl": "templates/subtree.html",
|
||||
"uses": [ "composition" ]
|
||||
},
|
||||
{
|
||||
|
14
platform/commonUI/general/res/templates/subtree.html
Normal file
14
platform/commonUI/general/res/templates/subtree.html
Normal file
@ -0,0 +1,14 @@
|
||||
<ul class="tree">
|
||||
<li ng-if="!composition">
|
||||
<span class="tree-item">
|
||||
<span class="icon wait-spinner"></span>
|
||||
<span class="title-label">Loading...</span>
|
||||
</span>
|
||||
</li>
|
||||
<li ng-repeat="child in composition">
|
||||
<mct-representation key="'tree-node'"
|
||||
mct-object="child"
|
||||
ng-model="ngModel">
|
||||
</mct-representation>
|
||||
</li>
|
||||
</ul>
|
@ -1,13 +1,7 @@
|
||||
<ul class="tree">
|
||||
<li ng-if="!composition">
|
||||
<span class="tree-item">
|
||||
<span class="icon wait-spinner"></span>
|
||||
<span class="title-label">Loading...</span>
|
||||
</span>
|
||||
</li>
|
||||
<li ng-repeat="child in composition">
|
||||
<li>
|
||||
<mct-representation key="'tree-node'"
|
||||
mct-object="child"
|
||||
mct-object="domainObject"
|
||||
ng-model="ngModel">
|
||||
</mct-representation>
|
||||
</li>
|
||||
|
@ -28,6 +28,7 @@ define(
|
||||
function addRoot(models) {
|
||||
models.ROOT = {
|
||||
name: "The root object",
|
||||
type: "root",
|
||||
composition: ids
|
||||
};
|
||||
return models;
|
||||
|
@ -32,25 +32,43 @@ define(
|
||||
* @param {ViewDefinition[]} views an array of view extensions
|
||||
*/
|
||||
function MCTRepresentation(representations, views, representers, $q, $log) {
|
||||
var pathMap = {},
|
||||
representationMap = {},
|
||||
var representationMap = {},
|
||||
gestureMap = {};
|
||||
|
||||
// Assemble all representations and views
|
||||
// The distinction between views and representations is
|
||||
// not important her (view is-a representation)
|
||||
representations.concat(views).forEach(function (representation) {
|
||||
var path = [
|
||||
var key = representation.key;
|
||||
|
||||
// Store the representation
|
||||
representationMap[key] = representationMap[key] || [];
|
||||
representationMap[representation.key].push(representation);
|
||||
});
|
||||
|
||||
// Get a path to a representation
|
||||
function getPath(representation) {
|
||||
return [
|
||||
representation.bundle.path,
|
||||
representation.bundle.resources,
|
||||
representation.templateUrl
|
||||
].join("/");
|
||||
}
|
||||
|
||||
// Consider allowing multiple templates with the same key
|
||||
pathMap[representation.key] = path;
|
||||
representationMap[representation.key] = representation;
|
||||
});
|
||||
|
||||
// Look up a matching representation for this domain object
|
||||
function lookup(key, domainObject) {
|
||||
var candidates = representationMap[key] || [],
|
||||
type,
|
||||
i;
|
||||
// Filter candidates by object type
|
||||
for (i = 0; i < candidates.length; i += 1) {
|
||||
type = candidates[i].type;
|
||||
if (!type || !domainObject ||
|
||||
domainObject.getCapability('type').instanceOf(type)) {
|
||||
return candidates[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function link($scope, element, attrs) {
|
||||
var activeRepresenters = representers.map(function (Representer) {
|
||||
@ -89,8 +107,8 @@ define(
|
||||
// as appropriate for current representation key and
|
||||
// domain object.
|
||||
function refresh() {
|
||||
var representation = representationMap[$scope.key],
|
||||
domainObject = $scope.domainObject,
|
||||
var domainObject = $scope.domainObject,
|
||||
representation = lookup($scope.key, domainObject),
|
||||
uses = ((representation || {}).uses || []),
|
||||
gestureKeys = ((representation || {}).gestures || []);
|
||||
|
||||
@ -100,7 +118,7 @@ define(
|
||||
|
||||
// Look up the actual template path, pass it to ng-include
|
||||
// via the "inclusion" field
|
||||
$scope.inclusion = pathMap[$scope.key];
|
||||
$scope.inclusion = representation && getPath(representation);
|
||||
|
||||
// Any existing gestures are no longer valid; release them.
|
||||
activeRepresenters.forEach(function (activeRepresenter) {
|
||||
|
Loading…
Reference in New Issue
Block a user