diff --git a/platform/commonUI/general/res/templates/tree/tree-label.html b/platform/commonUI/general/res/templates/tree/tree-label.html index ae1db92951..8c6dcb2e86 100644 --- a/platform/commonUI/general/res/templates/tree/tree-label.html +++ b/platform/commonUI/general/res/templates/tree/tree-label.html @@ -1,8 +1,8 @@
-
-
{{type.getGlyph()}}
+
+
-
{{model.name}}
+
diff --git a/platform/commonUI/general/src/ui/TreeLabelView.js b/platform/commonUI/general/src/ui/TreeLabelView.js index 239125a706..f60aad5369 100644 --- a/platform/commonUI/general/src/ui/TreeLabelView.js +++ b/platform/commonUI/general/src/ui/TreeLabelView.js @@ -22,19 +22,47 @@ /*global define*/ define([ - 'angular', + 'zepto', 'text!../../res/templates/ui/tree-label.html' -], function (angular, labelTemplate) { +], function ($, labelTemplate) { 'use strict'; - var $ = angular.element.bind(angular); - function TreeLabelView() { this.el = $(labelTemplate); } + function getGlyph(domainObject) { + var type = domainObject.getCapability('type'); + return type.getGlyph(); + } + + TreeLabelView.prototype.updateView = function (domainObject) { + var titleEl = this.el.find('.t-title-label'), + glyphEl = this.el.find('.t-item-icon-glyph'), + iconEl = this.el.find('.t-item-icon'); + + titleEl.text(domainObject ? domainObject.getModel().name : ""); + glyphEl.text(domainObject ? getGlyph(domainObject) : ""); + + if (domainObject && isLink(domainObject)) { + iconEl.addClass('l-icon-link'); + } else { + iconEl.removeClass('l-icon-link'); + } + }; + TreeLabelView.prototype.model = function (domainObject) { - + if (this.unlisten) { + this.unlisten(); + delete this.unlisten; + } + + this.updateView(domainObject); + + if (domainObject) { + this.unlisten = domainObject.getCapability('mutation') + .listen(this.updateView.bind(this)); + } }; TreeLabelView.prototype.elements = function () {