diff --git a/platform/commonUI/general/src/ui/TreeNodeView.js b/platform/commonUI/general/src/ui/TreeNodeView.js
index 2b02a2c1f9..3dfef187e7 100644
--- a/platform/commonUI/general/src/ui/TreeNodeView.js
+++ b/platform/commonUI/general/src/ui/TreeNodeView.js
@@ -32,6 +32,8 @@ define([
function TreeNodeView(gestureService, subtreeFactory, selectFn) {
this.li = $('
');
+ this.statusClasses = [];
+
this.toggleView = new ToggleView(false);
this.toggleView.observe(function (state) {
if (state) {
@@ -61,6 +63,20 @@ define([
this.model(undefined);
}
+ TreeNodeView.prototype.updateStatusClasses = function (statuses) {
+ this.statusClasses.forEach(function (statusClass) {
+ this.li.removeClass(statusClass);
+ }.bind(this));
+
+ this.statusClasses = statuses.map(function (status) {
+ return 's-status-' + status;
+ });
+
+ this.statusClasses.forEach(function (statusClass) {
+ this.li.addClass(statusClass);
+ }.bind(this));
+ };
+
TreeNodeView.prototype.model = function (domainObject) {
if (this.unlisten) {
this.unlisten();
@@ -74,6 +90,14 @@ define([
$(this.toggleView.elements()).removeClass('has-children');
}
+ if (domainObject && domainObject.hasCapability('status')) {
+ this.unlisten = domainObject.getCapability('status')
+ .listen(this.updateStatusClasses.bind(this));
+ this.updateStatusClasses(
+ domainObject.getCapability('status').list()
+ );
+ }
+
this.labelView.model(domainObject);
if (this.subtreeView) {
this.subtreeView.model(domainObject);
diff --git a/platform/commonUI/general/test/ui/TreeViewSpec.js b/platform/commonUI/general/test/ui/TreeViewSpec.js
index 370e5c8e10..c196890782 100644
--- a/platform/commonUI/general/test/ui/TreeViewSpec.js
+++ b/platform/commonUI/general/test/ui/TreeViewSpec.js
@@ -107,12 +107,18 @@ define([
mockLocation =
jasmine.createSpyObj('location', [ 'isLink' ]),
mockMutation =
- jasmine.createSpyObj('mutation', [ 'listen' ]);
+ jasmine.createSpyObj('mutation', [ 'listen' ]),
+ mockStatus =
+ jasmine.createSpyObj('status', [ 'listen', 'list' ]);
+
+ mockStatus.list.andReturn([]);
+
return {
context: mockContext,
type: mockType,
mutation: mockMutation,
- location: mockLocation
+ location: mockLocation,
+ status: mockStatus
};
}
@@ -247,6 +253,24 @@ define([
.toEqual(1);
});
});
+
+ describe("when status changes", function () {
+ var testStatuses;
+
+ beforeEach(function () {
+ var mockStatus = mockComposition[1].getCapability('status');
+
+ testStatuses = [ 'foo' ];
+
+ mockStatus.list.andReturn(testStatuses);
+ mockStatus.listen.mostRecentCall.args[0](testStatuses);
+ });
+
+ it("reflects the status change in the tree", function () {
+ expect($(treeView.elements()).find('.s-status-foo').length)
+ .toEqual(1);
+ });
+ });
});
describe("observe", function () {