From ece8f7fded0d385c57e7ef49080939cd26b35f29 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 11 Mar 2016 11:12:43 -0800 Subject: [PATCH] [Tree] Begin separating out TreeView --- .../general/res/templates/tree/node.html | 32 ++++++ .../general/src/directives/MCTTree.js | 37 ++----- .../commonUI/general/src/ui/TreeNodeView.js | 0 platform/commonUI/general/src/ui/TreeView.js | 98 +++++++++++++++++++ 4 files changed, 139 insertions(+), 28 deletions(-) create mode 100644 platform/commonUI/general/res/templates/tree/node.html create mode 100644 platform/commonUI/general/src/ui/TreeNodeView.js create mode 100644 platform/commonUI/general/src/ui/TreeView.js diff --git a/platform/commonUI/general/res/templates/tree/node.html b/platform/commonUI/general/res/templates/tree/node.html new file mode 100644 index 0000000000..ea5e2b3786 --- /dev/null +++ b/platform/commonUI/general/res/templates/tree/node.html @@ -0,0 +1,32 @@ +
  • + + + + + + + + + + +
  • \ No newline at end of file diff --git a/platform/commonUI/general/src/directives/MCTTree.js b/platform/commonUI/general/src/directives/MCTTree.js index 4a6e684fcd..74eb840f51 100644 --- a/platform/commonUI/general/src/directives/MCTTree.js +++ b/platform/commonUI/general/src/directives/MCTTree.js @@ -22,39 +22,19 @@ /*global define*/ define([ - 'text!../../res/templates/subtree.html' -], function (subtreeTemplate) { - function MCTTreeController($scope, $element) { - var ul = elem.filter('ul'), + 'text!../../res/templates/subtree.html', + 'text!../../res/templates/tree/node.html' +], function (subtreeTemplate, nodeTemplate) { + function MCTTreeController($scope, $element, $compile) { + var ul = $element.filter('ul'), + makeNode = $compile(nodeTemplate), activeObject, unlisten; - function addNodes(domainObjects) { - domainObjects.forEach(function (addNode)); - } - function loadComposition(domainObject) { - activeObject = domainObject; - ul.empty(); - if (domainObject.hasCapability('composition')) { - // TODO: Add pending indicator - domainObject.useCapability('composition') - .then(addNodes); - } - } - function changeObject(domainObject) { - if (unlisten) { - unlisten(); - } - unlisten = domainObject.getCapability('mutation') - .listen(loadComposition); - - loadComposition(domainObject); - } - - scope.$watch('mctObject', changeObject); + $scope.$watch('mctObject', changeObject); } function MCTTree() { @@ -63,11 +43,12 @@ define([ controller: [ '$scope', '$element', + '$compile', MCTTreeController ], require: [ "mctTree" ], scope: { mctObject: "=" }, - template: subtreeTemplate + template: "" }; } diff --git a/platform/commonUI/general/src/ui/TreeNodeView.js b/platform/commonUI/general/src/ui/TreeNodeView.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/platform/commonUI/general/src/ui/TreeView.js b/platform/commonUI/general/src/ui/TreeView.js new file mode 100644 index 0000000000..4032711321 --- /dev/null +++ b/platform/commonUI/general/src/ui/TreeView.js @@ -0,0 +1,98 @@ +/***************************************************************************** + * Open MCT Web, Copyright (c) 2014-2015, United States Government + * as represented by the Administrator of the National Aeronautics and Space + * Administration. All rights reserved. + * + * Open MCT Web is licensed under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * Open MCT Web includes source code licensed under additional open source + * licenses. See the Open Source Licenses file (LICENSES.md) included with + * this source code distribution or the Licensing information page available + * at runtime from the About dialog for additional information. + *****************************************************************************/ +/*global define*/ + +define([ + 'angular' +], function (angular, TreeNodeView) { + 'use strict'; + + var $ = angular.element.bind(angular); + + function TreeView() { + this.ul = $('