mirror of
https://github.com/nasa/openmct.git
synced 2025-02-22 02:06:49 +00:00
Merge pull request #754 from nasa/tree-status-styling-749
[Tree] Add status classes during editing
This commit is contained in:
commit
4a1ca25e17
@ -32,6 +32,8 @@ define([
|
|||||||
function TreeNodeView(gestureService, subtreeFactory, selectFn) {
|
function TreeNodeView(gestureService, subtreeFactory, selectFn) {
|
||||||
this.li = $('<li>');
|
this.li = $('<li>');
|
||||||
|
|
||||||
|
this.statusClasses = [];
|
||||||
|
|
||||||
this.toggleView = new ToggleView(false);
|
this.toggleView = new ToggleView(false);
|
||||||
this.toggleView.observe(function (state) {
|
this.toggleView.observe(function (state) {
|
||||||
if (state) {
|
if (state) {
|
||||||
@ -61,6 +63,20 @@ define([
|
|||||||
this.model(undefined);
|
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) {
|
TreeNodeView.prototype.model = function (domainObject) {
|
||||||
if (this.unlisten) {
|
if (this.unlisten) {
|
||||||
this.unlisten();
|
this.unlisten();
|
||||||
@ -74,6 +90,14 @@ define([
|
|||||||
$(this.toggleView.elements()).removeClass('has-children');
|
$(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);
|
this.labelView.model(domainObject);
|
||||||
if (this.subtreeView) {
|
if (this.subtreeView) {
|
||||||
this.subtreeView.model(domainObject);
|
this.subtreeView.model(domainObject);
|
||||||
|
@ -107,12 +107,18 @@ define([
|
|||||||
mockLocation =
|
mockLocation =
|
||||||
jasmine.createSpyObj('location', [ 'isLink' ]),
|
jasmine.createSpyObj('location', [ 'isLink' ]),
|
||||||
mockMutation =
|
mockMutation =
|
||||||
jasmine.createSpyObj('mutation', [ 'listen' ]);
|
jasmine.createSpyObj('mutation', [ 'listen' ]),
|
||||||
|
mockStatus =
|
||||||
|
jasmine.createSpyObj('status', [ 'listen', 'list' ]);
|
||||||
|
|
||||||
|
mockStatus.list.andReturn([]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: mockContext,
|
context: mockContext,
|
||||||
type: mockType,
|
type: mockType,
|
||||||
mutation: mockMutation,
|
mutation: mockMutation,
|
||||||
location: mockLocation
|
location: mockLocation,
|
||||||
|
status: mockStatus
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +253,24 @@ define([
|
|||||||
.toEqual(1);
|
.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 () {
|
describe("observe", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user