mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 06:31:04 +00:00
Object has no children fix (#2038)
* Added files for PR 1904 * Added new lines * space fix * Implemented changes * Space fix * checkstyle fix Fixes #1826
This commit is contained in:
parent
b8f278cabf
commit
eaa9514453
@ -401,7 +401,7 @@ define([
|
|||||||
{
|
{
|
||||||
"key": "mctTree",
|
"key": "mctTree",
|
||||||
"implementation": MCTTree,
|
"implementation": MCTTree,
|
||||||
"depends": ['gestureService']
|
"depends": ['gestureService', 'openmct']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "mctPreview",
|
"key": "mctPreview",
|
||||||
|
@ -79,8 +79,8 @@ define(
|
|||||||
// a recursive step for subsequent ids in the paths,
|
// a recursive step for subsequent ids in the paths,
|
||||||
// until we exceed path length or hit a mismatch.
|
// until we exceed path length or hit a mismatch.
|
||||||
return (index >= nodePath.length) ||
|
return (index >= nodePath.length) ||
|
||||||
((navPath[index] === nodePath[index]) &&
|
((navPath[index] === nodePath[index]) &&
|
||||||
checkPath(nodePath, navPath, index + 1));
|
checkPath(nodePath, navPath, index + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consider the currently-navigated object and update
|
// Consider the currently-navigated object and update
|
||||||
@ -89,9 +89,9 @@ define(
|
|||||||
var nodeObject = $scope.domainObject,
|
var nodeObject = $scope.domainObject,
|
||||||
navObject = selectedObject,
|
navObject = selectedObject,
|
||||||
nodeContext = nodeObject &&
|
nodeContext = nodeObject &&
|
||||||
nodeObject.getCapability('context'),
|
nodeObject.getCapability('context'),
|
||||||
navContext = navObject &&
|
navContext = navObject &&
|
||||||
navObject.getCapability('context'),
|
navObject.getCapability('context'),
|
||||||
nodePath,
|
nodePath,
|
||||||
navPath;
|
navPath;
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ define(
|
|||||||
// within the navigation path; otherwise, navigation
|
// within the navigation path; otherwise, navigation
|
||||||
// has happened in some other subtree.
|
// has happened in some other subtree.
|
||||||
if (navPath.length >= nodePath.length &&
|
if (navPath.length >= nodePath.length &&
|
||||||
checkPath(nodePath, navPath)) {
|
checkPath(nodePath, navPath)) {
|
||||||
|
|
||||||
// nodePath is along the navPath; if it's
|
// nodePath is along the navPath; if it's
|
||||||
// at the end of the path, highlight;
|
// at the end of the path, highlight;
|
||||||
|
@ -24,7 +24,7 @@ define([
|
|||||||
'angular',
|
'angular',
|
||||||
'../ui/TreeView'
|
'../ui/TreeView'
|
||||||
], function (angular, TreeView) {
|
], function (angular, TreeView) {
|
||||||
function MCTTree(gestureService) {
|
function MCTTree(gestureService, openmct) {
|
||||||
function link(scope, element) {
|
function link(scope, element) {
|
||||||
if (!scope.allowSelection) {
|
if (!scope.allowSelection) {
|
||||||
scope.allowSelection = function () {
|
scope.allowSelection = function () {
|
||||||
@ -34,8 +34,9 @@ define([
|
|||||||
if (!scope.onSelection) {
|
if (!scope.onSelection) {
|
||||||
scope.onSelection = function () {};
|
scope.onSelection = function () {};
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentSelection = scope.selectedObject;
|
var currentSelection = scope.selectedObject;
|
||||||
var treeView = new TreeView(gestureService);
|
var treeView = new TreeView(gestureService, openmct);
|
||||||
|
|
||||||
function setSelection(domainObject, event) {
|
function setSelection(domainObject, event) {
|
||||||
if (currentSelection === domainObject) {
|
if (currentSelection === domainObject) {
|
||||||
|
@ -27,9 +27,9 @@ define([
|
|||||||
'./TreeLabelView'
|
'./TreeLabelView'
|
||||||
], function ($, nodeTemplate, ToggleView, TreeLabelView) {
|
], function ($, nodeTemplate, ToggleView, TreeLabelView) {
|
||||||
|
|
||||||
function TreeNodeView(gestureService, subtreeFactory, selectFn) {
|
function TreeNodeView(gestureService, subtreeFactory, selectFn, openmct) {
|
||||||
this.li = $('<li>');
|
this.li = $('<li>');
|
||||||
|
this.openmct = openmct;
|
||||||
this.statusClasses = [];
|
this.statusClasses = [];
|
||||||
|
|
||||||
this.toggleView = new ToggleView(false);
|
this.toggleView = new ToggleView(false);
|
||||||
@ -81,11 +81,14 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.activeObject = domainObject;
|
this.activeObject = domainObject;
|
||||||
|
if (domainObject && domainObject.hasCapability('adapter')) {
|
||||||
if (domainObject && domainObject.hasCapability('composition')) {
|
var obj = domainObject.useCapability('adapter');
|
||||||
$(this.toggleView.elements()).removeClass('no-children');
|
var hasComposition = this.openmct.composition.get(obj) !== undefined;
|
||||||
} else {
|
if (hasComposition) {
|
||||||
$(this.toggleView.elements()).addClass('no-children');
|
$(this.toggleView.elements()).removeClass('no-children');
|
||||||
|
} else {
|
||||||
|
$(this.toggleView.elements()).addClass('no-children');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (domainObject && domainObject.hasCapability('status')) {
|
if (domainObject && domainObject.hasCapability('status')) {
|
||||||
@ -150,6 +153,5 @@ define([
|
|||||||
return this.li;
|
return this.li;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return TreeNodeView;
|
return TreeNodeView;
|
||||||
});
|
});
|
||||||
|
@ -26,17 +26,18 @@ define([
|
|||||||
'text!../../res/templates/tree/wait-node.html'
|
'text!../../res/templates/tree/wait-node.html'
|
||||||
], function ($, TreeNodeView, spinnerTemplate) {
|
], function ($, TreeNodeView, spinnerTemplate) {
|
||||||
|
|
||||||
function TreeView(gestureService, selectFn) {
|
function TreeView(gestureService, openmct, selectFn) {
|
||||||
this.ul = $('<ul class="tree"></ul>');
|
this.ul = $('<ul class="tree"></ul>');
|
||||||
this.nodeViews = [];
|
this.nodeViews = [];
|
||||||
this.callbacks = [];
|
this.callbacks = [];
|
||||||
this.selectFn = selectFn || this.value.bind(this);
|
this.selectFn = selectFn || this.value.bind(this);
|
||||||
this.gestureService = gestureService;
|
this.gestureService = gestureService;
|
||||||
this.pending = false;
|
this.pending = false;
|
||||||
|
this.openmct = openmct;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeView.prototype.newTreeView = function () {
|
TreeView.prototype.newTreeView = function () {
|
||||||
return new TreeView(this.gestureService, this.selectFn);
|
return new TreeView(this.gestureService, this.openmct, this.selectFn);
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeView.prototype.setSize = function (sz) {
|
TreeView.prototype.setSize = function (sz) {
|
||||||
@ -46,7 +47,8 @@ define([
|
|||||||
nodeView = new TreeNodeView(
|
nodeView = new TreeNodeView(
|
||||||
this.gestureService,
|
this.gestureService,
|
||||||
this.newTreeView.bind(this),
|
this.newTreeView.bind(this),
|
||||||
this.selectFn
|
this.selectFn,
|
||||||
|
this.openmct
|
||||||
);
|
);
|
||||||
this.nodeViews.push(nodeView);
|
this.nodeViews.push(nodeView);
|
||||||
this.ul.append($(nodeView.elements()));
|
this.ul.append($(nodeView.elements()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user