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",
|
"key": "tree",
|
||||||
"templateUrl": "templates/tree.html",
|
"templateUrl": "templates/tree.html",
|
||||||
|
"type": "root",
|
||||||
|
"priority": "preferred"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "tree",
|
||||||
|
"templateUrl": "templates/subtree.html",
|
||||||
"uses": [ "composition" ]
|
"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">
|
<ul class="tree">
|
||||||
<li ng-if="!composition">
|
<li>
|
||||||
<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-representation key="'tree-node'"
|
||||||
mct-object="child"
|
mct-object="domainObject"
|
||||||
ng-model="ngModel">
|
ng-model="ngModel">
|
||||||
</mct-representation>
|
</mct-representation>
|
||||||
</li>
|
</li>
|
||||||
|
@ -28,6 +28,7 @@ define(
|
|||||||
function addRoot(models) {
|
function addRoot(models) {
|
||||||
models.ROOT = {
|
models.ROOT = {
|
||||||
name: "The root object",
|
name: "The root object",
|
||||||
|
type: "root",
|
||||||
composition: ids
|
composition: ids
|
||||||
};
|
};
|
||||||
return models;
|
return models;
|
||||||
|
@ -32,25 +32,43 @@ define(
|
|||||||
* @param {ViewDefinition[]} views an array of view extensions
|
* @param {ViewDefinition[]} views an array of view extensions
|
||||||
*/
|
*/
|
||||||
function MCTRepresentation(representations, views, representers, $q, $log) {
|
function MCTRepresentation(representations, views, representers, $q, $log) {
|
||||||
var pathMap = {},
|
var representationMap = {},
|
||||||
representationMap = {},
|
|
||||||
gestureMap = {};
|
gestureMap = {};
|
||||||
|
|
||||||
// Assemble all representations and views
|
// Assemble all representations and views
|
||||||
// The distinction between views and representations is
|
// The distinction between views and representations is
|
||||||
// not important her (view is-a representation)
|
// not important her (view is-a representation)
|
||||||
representations.concat(views).forEach(function (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.path,
|
||||||
representation.bundle.resources,
|
representation.bundle.resources,
|
||||||
representation.templateUrl
|
representation.templateUrl
|
||||||
].join("/");
|
].join("/");
|
||||||
|
}
|
||||||
|
|
||||||
// Consider allowing multiple templates with the same key
|
// Look up a matching representation for this domain object
|
||||||
pathMap[representation.key] = path;
|
function lookup(key, domainObject) {
|
||||||
representationMap[representation.key] = representation;
|
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) {
|
function link($scope, element, attrs) {
|
||||||
var activeRepresenters = representers.map(function (Representer) {
|
var activeRepresenters = representers.map(function (Representer) {
|
||||||
@ -89,8 +107,8 @@ define(
|
|||||||
// as appropriate for current representation key and
|
// as appropriate for current representation key and
|
||||||
// domain object.
|
// domain object.
|
||||||
function refresh() {
|
function refresh() {
|
||||||
var representation = representationMap[$scope.key],
|
var domainObject = $scope.domainObject,
|
||||||
domainObject = $scope.domainObject,
|
representation = lookup($scope.key, domainObject),
|
||||||
uses = ((representation || {}).uses || []),
|
uses = ((representation || {}).uses || []),
|
||||||
gestureKeys = ((representation || {}).gestures || []);
|
gestureKeys = ((representation || {}).gestures || []);
|
||||||
|
|
||||||
@ -100,7 +118,7 @@ define(
|
|||||||
|
|
||||||
// Look up the actual template path, pass it to ng-include
|
// Look up the actual template path, pass it to ng-include
|
||||||
// via the "inclusion" field
|
// via the "inclusion" field
|
||||||
$scope.inclusion = pathMap[$scope.key];
|
$scope.inclusion = representation && getPath(representation);
|
||||||
|
|
||||||
// Any existing gestures are no longer valid; release them.
|
// Any existing gestures are no longer valid; release them.
|
||||||
activeRepresenters.forEach(function (activeRepresenter) {
|
activeRepresenters.forEach(function (activeRepresenter) {
|
||||||
|
Loading…
Reference in New Issue
Block a user