From dc2b3e85cc23904acde374b006b47385376936f8 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 11 Mar 2016 14:33:05 -0800 Subject: [PATCH] [Tree] Show tree with toggle --- main.js | 3 ++ .../general/res/templates/tree/node.html | 4 --- .../commonUI/general/src/ui/TreeLabelView.js | 5 ++++ .../commonUI/general/src/ui/TreeNodeView.js | 29 ++++++++++--------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/main.js b/main.js index ec8a2dcb80..8ce58e1ac1 100644 --- a/main.js +++ b/main.js @@ -45,6 +45,9 @@ requirejs.config({ }, "moment-duration-format": { "deps": [ "moment" ] + }, + "zepto": { + "exports": "Zepto" } } }); diff --git a/platform/commonUI/general/res/templates/tree/node.html b/platform/commonUI/general/res/templates/tree/node.html index 2041a39cca..d6012b5ea9 100644 --- a/platform/commonUI/general/res/templates/tree/node.html +++ b/platform/commonUI/general/res/templates/tree/node.html @@ -1,8 +1,4 @@ - - - - diff --git a/platform/commonUI/general/src/ui/TreeLabelView.js b/platform/commonUI/general/src/ui/TreeLabelView.js index 33db6115f0..512e1b49e4 100644 --- a/platform/commonUI/general/src/ui/TreeLabelView.js +++ b/platform/commonUI/general/src/ui/TreeLabelView.js @@ -36,6 +36,11 @@ define([ return type.getGlyph(); } + function isLink(domainObject) { + var location = domainObject.getCapability('location'); + return location.isLink(); + } + TreeLabelView.prototype.updateView = function (domainObject) { var titleEl = this.el.find('.t-title-label'), glyphEl = this.el.find('.t-item-icon-glyph'), diff --git a/platform/commonUI/general/src/ui/TreeNodeView.js b/platform/commonUI/general/src/ui/TreeNodeView.js index e84149834f..ede9bf2a90 100644 --- a/platform/commonUI/general/src/ui/TreeNodeView.js +++ b/platform/commonUI/general/src/ui/TreeNodeView.js @@ -24,8 +24,9 @@ define([ 'angular', 'text!../../res/templates/tree/node.html', - './ToggleView' -], function (angular, nodeTemplate, ToggleView) { + './ToggleView', + './TreeLabelView' +], function (angular, nodeTemplate, ToggleView, TreeLabelView) { 'use strict'; var $ = angular.element.bind(angular); @@ -45,13 +46,16 @@ define([ $(this.subtreeView.elements()).addClass('hidden'); } }.bind(this)); - } - TreeNodeView.prototype.populateContents = function (domainObject) { - if (this.li.children().length === 0) { - this.li.append($(nodeTemplate)); - } - }; + this.labelView = new TreeLabelView(); + + this.li.append($(nodeTemplate)); + this.li.find('span').eq(0) + .append(this.toggleView.elements()) + .append(this.labelView.elements()); + + this.model(undefined); + } TreeNodeView.prototype.model = function (domainObject) { if (this.unlisten) { @@ -60,14 +64,13 @@ define([ this.activeObject = domainObject; - if (domainObject) { - this.unlisten = domainObject.getCapability('mutation') - .listen(this.populateContents.bind(this)); - this.populateContents(domainObject); + if (domainObject && domainObject.hasCapability('composition')) { + $(this.toggleView.elements()).addClass('has-children'); } else { - this.li.empty(); + $(this.toggleView.elements()).removeClass('has-children'); } + this.labelView.model(domainObject); if (this.subtreeView) { this.subtreeView.model(domainObject); }