mirror of
https://github.com/nasa/openmct.git
synced 2025-06-26 19:12:02 +00:00
Compare commits
3 Commits
experiment
...
summary-wi
Author | SHA1 | Date | |
---|---|---|---|
bc72fd54e8 | |||
9569ee2b56 | |||
cea6d4978a |
@ -204,7 +204,7 @@ define([
|
|||||||
this.deleteButton.on('click', this.remove);
|
this.deleteButton.on('click', this.remove);
|
||||||
this.duplicateButton.on('click', this.duplicate);
|
this.duplicateButton.on('click', this.duplicate);
|
||||||
this.addConditionButton.on('click', function () {
|
this.addConditionButton.on('click', function () {
|
||||||
self.initCondition();
|
self.addCondition();
|
||||||
});
|
});
|
||||||
this.toggleConfigButton.on('click', toggleConfig);
|
this.toggleConfigButton.on('click', toggleConfig);
|
||||||
this.trigger.on('change', onTriggerInput);
|
this.trigger.on('change', onTriggerInput);
|
||||||
@ -350,7 +350,7 @@ define([
|
|||||||
* @param {Object} [config] The configuration to initialize this rule from,
|
* @param {Object} [config] The configuration to initialize this rule from,
|
||||||
* consisting of sourceCondition and index fields
|
* consisting of sourceCondition and index fields
|
||||||
*/
|
*/
|
||||||
Rule.prototype.initCondition = function (config) {
|
Rule.prototype.addCondition = function (config) {
|
||||||
var ruleConfigById = this.domainObject.configuration.ruleConfigById,
|
var ruleConfigById = this.domainObject.configuration.ruleConfigById,
|
||||||
newConfig,
|
newConfig,
|
||||||
sourceIndex = config && config.index,
|
sourceIndex = config && config.index,
|
||||||
@ -388,7 +388,7 @@ define([
|
|||||||
this.config.conditions.forEach(function (condition, index) {
|
this.config.conditions.forEach(function (condition, index) {
|
||||||
var newCondition = new Condition(condition, index, self.conditionManager);
|
var newCondition = new Condition(condition, index, self.conditionManager);
|
||||||
newCondition.on('remove', self.removeCondition, self);
|
newCondition.on('remove', self.removeCondition, self);
|
||||||
newCondition.on('duplicate', self.initCondition, self);
|
newCondition.on('duplicate', self.addCondition, self);
|
||||||
newCondition.on('change', self.onConditionChange, self);
|
newCondition.on('change', self.onConditionChange, self);
|
||||||
self.conditions.push(newCondition);
|
self.conditions.push(newCondition);
|
||||||
});
|
});
|
||||||
|
@ -35,9 +35,25 @@ define([
|
|||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
|
|
||||||
|
this.initializeLocalVariables();
|
||||||
|
this.addHyperlink(domainObject.url, domainObject.openNewTab);
|
||||||
|
this.watchForChanges(openmct, domainObject);
|
||||||
|
this.addToggleSectionCallbacks();
|
||||||
|
this.addEditListener();
|
||||||
|
|
||||||
|
this.watchForChanges = this.watchForChanges.bind(this);
|
||||||
|
this.show = this.show.bind(this);
|
||||||
|
this.destroy = this.destroy.bind(this);
|
||||||
|
this.addRule = this.addRule.bind(this);
|
||||||
|
this.onEdit = this.onEdit.bind(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SummaryWidget.prototype.initializeLocalVariables = function () {
|
||||||
this.domainObject.configuration = this.domainObject.configuration || {};
|
this.domainObject.configuration = this.domainObject.configuration || {};
|
||||||
this.domainObject.configuration.ruleConfigById = this.domainObject.configuration.ruleConfigById || {};
|
this.domainObject.configuration.ruleConfigById = this.domainObject.configuration.ruleConfigById || {};
|
||||||
this.domainObject.configuration.ruleOrder = this.domainObject.configuration.ruleOrder || ['default'];
|
this.domainObject.configuration.ruleOrder = this.domainObject.configuration.ruleOrder || ['default'];
|
||||||
|
|
||||||
this.domainObject.configuration.testDataConfig = this.domainObject.configuration.testDataConfig || [{
|
this.domainObject.configuration.testDataConfig = this.domainObject.configuration.testDataConfig || [{
|
||||||
object: '',
|
object: '',
|
||||||
key: '',
|
key: '',
|
||||||
@ -63,20 +79,11 @@ define([
|
|||||||
|
|
||||||
this.conditionManager = new ConditionManager(this.domainObject, this.openmct);
|
this.conditionManager = new ConditionManager(this.domainObject, this.openmct);
|
||||||
this.testDataManager = new TestDataManager(this.domainObject, this.conditionManager, this.openmct);
|
this.testDataManager = new TestDataManager(this.domainObject, this.conditionManager, this.openmct);
|
||||||
|
};
|
||||||
|
|
||||||
this.watchForChanges = this.watchForChanges.bind(this);
|
SummaryWidget.prototype.addToggleSectionCallbacks = function () {
|
||||||
this.show = this.show.bind(this);
|
|
||||||
this.destroy = this.destroy.bind(this);
|
|
||||||
this.addRule = this.addRule.bind(this);
|
|
||||||
this.onEdit = this.onEdit.bind(this);
|
|
||||||
|
|
||||||
this.addHyperlink(domainObject.url, domainObject.openNewTab);
|
var self = this;
|
||||||
this.watchForChanges(openmct, domainObject);
|
|
||||||
|
|
||||||
var id = this.domainObject.identifier.key,
|
|
||||||
self = this,
|
|
||||||
oldDomainObject,
|
|
||||||
statusCapability;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the configuration area for test data in the view
|
* Toggles the configuration area for test data in the view
|
||||||
@ -97,8 +104,15 @@ define([
|
|||||||
self.toggleRulesControl.toggleClass('expanded');
|
self.toggleRulesControl.toggleClass('expanded');
|
||||||
}
|
}
|
||||||
this.toggleRulesControl.on('click', toggleRules);
|
this.toggleRulesControl.on('click', toggleRules);
|
||||||
|
};
|
||||||
|
|
||||||
openmct.$injector.get('objectService')
|
SummaryWidget.prototype.addEditListener = function () {
|
||||||
|
var oldDomainObject,
|
||||||
|
statusCapability,
|
||||||
|
self = this,
|
||||||
|
id = this.domainObject.identifier.key;
|
||||||
|
|
||||||
|
this.openmct.$injector.get('objectService')
|
||||||
.getObjects([id])
|
.getObjects([id])
|
||||||
.then(function (objs) {
|
.then(function (objs) {
|
||||||
oldDomainObject = objs[id];
|
oldDomainObject = objs[id];
|
||||||
@ -110,7 +124,7 @@ define([
|
|||||||
self.onEdit([]);
|
self.onEdit([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds or removes href to widget button and adds or removes openInNewTab
|
* adds or removes href to widget button and adds or removes openInNewTab
|
||||||
|
@ -131,7 +131,7 @@ define(['../src/Rule', 'zepto'], function (Rule, $) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows initializing a new condition with a default configuration', function () {
|
it('allows initializing a new condition with a default configuration', function () {
|
||||||
testRule.initCondition();
|
testRule.addCondition();
|
||||||
expect(mockRuleConfig.conditions).toEqual([{
|
expect(mockRuleConfig.conditions).toEqual([{
|
||||||
object: '',
|
object: '',
|
||||||
key: '',
|
key: '',
|
||||||
@ -151,7 +151,7 @@ define(['../src/Rule', 'zepto'], function (Rule, $) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows initializing a new condition from a given configuration', function () {
|
it('allows initializing a new condition from a given configuration', function () {
|
||||||
testRule.initCondition({
|
testRule.addCondition({
|
||||||
sourceCondition: {
|
sourceCondition: {
|
||||||
object: 'object1',
|
object: 'object1',
|
||||||
key: 'key1',
|
key: 'key1',
|
||||||
|
Reference in New Issue
Block a user