Summary Widgets (#1668)

* [ViewAPI] Update view API with more support

Update view provider to allow metadata definitions and to play
nicely with old style views.

Spec out some updates to ViewProviders and ViewRegistry to
support further use of views.

* [Summary Widgets] Add summary widgets

Add a summary widget domain object type

Implement basic interface and style configuration for rules

* [Summary Widgets] Implementation for Rules

Add rule configuration inputs, populated with domain objects, metadata,
and appropriate operations for a given type

* [Inputs] Add implementation for icon palette

Issue #1644

Wire up icon palette inputs to widget, and make icon class a persistable
property of a rule

* [Summary Widgets] Implementation for conditions

Support configuring and persisting multiple conditions per rule

Issue #1644

* [Summary Widgets] Generate Rule Descriptions

Dynamically update the rule description based on the current state
of the rules' conditions

* [Summary Widgets] 'Any/All Telemetry' in conditions

Add UI and implemenetion for evaluating any telemetry or all telemetry
in an individual condition. Add related unit tests.

* [Summary Widgets] Rule Reorders

Implement drag and drop rule reorders using the native HTML5 API

* [Summary Widget] Test Data

Issue #1644

Add user-configurable mock data to test rules. Modify evaluator to
gracefully handle uninitialzed test data points.

* [Summary Widgets] Edit Mode

Enable edit mode for summary widgets, and make configuration interface
visible only when the user has entered edit mode

Fix collision between widget palettes and other interfaces where
palettes would permanently hide other menus

* [Summary Widgets] UI for scripted conditions

* [Sumamry Widgets] Destroy
Implement destroy

* [Summary Widgets] Cleanup
Remove unnecessary persist calls in Rule.js.
Remove generateDescription from refreshConditions and add it after refreshConditions to initCondition and deleteCondition
Throw error when unsupported callback is passed in condition.js, return summary widget instance in plugin.js instead of wrapping in new object for view
Add request properties to telemetry request for providers that support it
Remove check for editing when persisting, in SummaryWidget.js
This commit is contained in:
Aaron Doubek-Kraft
2017-11-28 13:23:15 -08:00
committed by Andrew Henry
parent 5a49ac16b1
commit 4b07930305
66 changed files with 6275 additions and 184 deletions

View File

@ -0,0 +1,109 @@
define(['../../src/input/ObjectSelect'], function (ObjectSelect) {
describe('A select for choosing composition objects', function () {
var mockConfig, mockBadConfig, mockManager, objectSelect, mockComposition;
beforeEach(function () {
mockConfig = {
object: 'key1'
};
mockBadConfig = {
object: 'someNonexistentObject'
};
mockComposition = {
key1: {
identifier: {
key: 'key1'
},
name: 'Object 1'
},
key2: {
identifier: {
key: 'key2'
},
name: 'Object 2'
}
};
mockManager = jasmine.createSpyObj('mockManager', [
'on',
'loadCompleted',
'triggerCallback',
'getComposition'
]);
mockManager.on.andCallFake(function (event, callback) {
this.callbacks = this.callbacks || {};
this.callbacks[event] = callback;
});
mockManager.triggerCallback.andCallFake(function (event, newObj) {
if (event === 'add') {
this.callbacks.add(newObj);
} else {
this.callbacks[event]();
}
});
mockManager.getComposition.andCallFake(function () {
return mockComposition;
});
});
it('allows setting special keyword options', function () {
mockManager.loadCompleted.andReturn(true);
objectSelect = new ObjectSelect(mockConfig, mockManager, [
['keyword1', 'A special option'],
['keyword2', 'A special option']
]);
objectSelect.setSelected('keyword1');
expect(objectSelect.getSelected()).toEqual('keyword1');
});
it('waits until the composition fully loads to populate itself', function () {
mockManager.loadCompleted.andReturn(false);
objectSelect = new ObjectSelect(mockConfig, mockManager);
expect(objectSelect.getSelected()).toEqual('');
});
it('populates itself with composition objects on a composition load', function () {
mockManager.loadCompleted.andReturn(false);
objectSelect = new ObjectSelect(mockConfig, mockManager);
mockManager.triggerCallback('load');
expect(objectSelect.getSelected()).toEqual('key1');
});
it('populates itself with composition objects if load is already complete', function () {
mockManager.loadCompleted.andReturn(true);
objectSelect = new ObjectSelect(mockConfig, mockManager);
expect(objectSelect.getSelected()).toEqual('key1');
});
it('clears its selection state if the object in its config is not in the composition', function () {
mockManager.loadCompleted.andReturn(true);
objectSelect = new ObjectSelect(mockBadConfig, mockManager);
expect(objectSelect.getSelected()).toEqual('');
});
it('adds a new option on a composition add', function () {
mockManager.loadCompleted.andReturn(true);
objectSelect = new ObjectSelect(mockConfig, mockManager);
mockManager.triggerCallback('add', {
identifier: {
key: 'key3'
},
name: 'Object 3'
});
objectSelect.setSelected('key3');
expect(objectSelect.getSelected()).toEqual('key3');
});
it('removes an option on a composition remove', function () {
mockManager.loadCompleted.andReturn(true);
objectSelect = new ObjectSelect(mockConfig, mockManager);
delete mockComposition.key1;
mockManager.triggerCallback('remove');
expect(objectSelect.getSelected()).not.toEqual('key1');
});
});
});