diff --git a/platform/features/plot/bundle.js b/platform/features/plot/bundle.js
index 80e1e7fab8..341b7c76c4 100644
--- a/platform/features/plot/bundle.js
+++ b/platform/features/plot/bundle.js
@@ -78,8 +78,7 @@ define([
"key": "PlotOptionsController",
"implementation": PlotOptionsController,
"depends": [
- "$scope",
- "topic"
+ "$scope"
]
}
],
diff --git a/platform/features/plot/src/PlotOptionsController.js b/platform/features/plot/src/PlotOptionsController.js
index 4206799986..2e333cce07 100644
--- a/platform/features/plot/src/PlotOptionsController.js
+++ b/platform/features/plot/src/PlotOptionsController.js
@@ -45,13 +45,13 @@ define(
* @constructor
* @param {Scope} $scope the controller's Angular scope
*/
- function PlotOptionsController($scope, topic) {
+ function PlotOptionsController($scope) {
var self = this;
this.$scope = $scope;
this.domainObject = $scope.domainObject;
this.configuration = this.domainObject.getModel().configuration || {};
- this.plotOptionsForm = new PlotOptionsForm(topic);
+ this.plotOptionsForm = new PlotOptionsForm();
this.composition = [];
/*
@@ -64,10 +64,6 @@ define(
}
});
- this.formListener = this.plotOptionsForm.listen(function(value){
- self.updateConfiguration(value);
- });
-
/*
Set form structures on scope
*/
@@ -78,11 +74,27 @@ define(
$scope.$on("$destroy", function() {
//Clean up any listeners on destruction of controller
self.mutationListener();
- self.formListener();
});
this.defaultConfiguration();
this.updateChildren();
+
+ /**
+ * Setup a number of watches for changes to form values. On
+ * change, update the model configuration via mutation
+ */
+ $scope.$watchCollection('configuration.plot.yAxis', function(newValue, oldValue){
+ self.updateConfiguration(newValue, oldValue);
+ });
+ $scope.$watchCollection('configuration.plot.xAxis', function(newValue, oldValue){
+ self.updateConfiguration(newValue, oldValue);
+ });
+ ($scope.children || []).forEach(function(child){
+ $scope.$watchCollection('configuration.plot.series[' + child.getId() + ']', function(newValue, oldValue){
+ self.updateConfiguration(newValue, oldValue);
+ });
+ });
+
}
/*
@@ -134,6 +146,7 @@ define(
*/
PlotOptionsController.prototype.updateConfiguration = function() {
var self = this;
+ console.log('form values changed');
this.domainObject.useCapability('mutation', function(model){
model.configuration = model.configuration || {};
model.configuration.plot = self.configuration.plot;
diff --git a/platform/features/plot/src/PlotOptionsForm.js b/platform/features/plot/src/PlotOptionsForm.js
index c6c5d2b343..392085a991 100644
--- a/platform/features/plot/src/PlotOptionsForm.js
+++ b/platform/features/plot/src/PlotOptionsForm.js
@@ -33,13 +33,7 @@ define(
* @param topic
* @constructor
*/
- function PlotOptionsForm(topic) {
- var self = this;
- this.onchangeTopic = topic();
-
- function onchange(value){
- self.onchangeTopic.notify(value);
- }
+ function PlotOptionsForm() {
/*
Defined below are the form structures for the plot options.
@@ -149,10 +143,6 @@ define(
};
}
- PlotOptionsForm.prototype.listen = function (callback){
- return this.onchangeTopic.listen(callback);
- };
-
return PlotOptionsForm;
}
);
diff --git a/platform/features/plot/test/PlotOptionsControllerSpec.js b/platform/features/plot/test/PlotOptionsControllerSpec.js
index 81fafb3768..6b21771f79 100644
--- a/platform/features/plot/test/PlotOptionsControllerSpec.js
+++ b/platform/features/plot/test/PlotOptionsControllerSpec.js
@@ -28,8 +28,6 @@ define(
describe("The Plot Options controller", function () {
var plotOptionsController,
- mockTopicFunction,
- mockTopicObject,
mockDomainObject,
mockMutationCapability,
mockUseCapabilities,
@@ -79,18 +77,6 @@ define(
mockUnlisten = jasmine.createSpy('unlisten');
mockMutationCapability.listen.andReturn(mockUnlisten);
-
- mockTopicObject = jasmine.createSpyObj('Topic', [
- 'listen',
- 'notify'
- ]);
- mockFormUnlisten = jasmine.createSpy('formUnlisten');
- mockTopicObject.listen.andReturn(mockFormUnlisten);
-
- mockTopicFunction = function() {
- return mockTopicObject;
- };
-
mockDomainObject = jasmine.createSpyObj('domainObject', [
'getModel',
'useCapability',
@@ -103,11 +89,12 @@ define(
mockDomainObject.getModel.andReturn(model);
mockScope = jasmine.createSpyObj('scope', [
- '$on'
+ '$on',
+ '$watchCollection'
]);
mockScope.domainObject = mockDomainObject;
- plotOptionsController = new PlotOptionsController(mockScope, mockTopicFunction);
+ plotOptionsController = new PlotOptionsController(mockScope);
});
it("sets form definitions on scope", function () {
@@ -135,25 +122,24 @@ define(
var scopeConfiguration = mockScope.configuration,
model = mockDomainObject.getModel();
- scopeConfiguration.plot.xAxis.key = 'lst';
scopeConfiguration.plot.yAxis.autoScale = true;
scopeConfiguration.plot.yAxis.key = 'eu';
+ scopeConfiguration.plot.xAxis.key = 'lst';
- expect(mockTopicObject.listen).toHaveBeenCalled();
- mockTopicObject.listen.mostRecentCall.args[0]();
+ expect(mockScope.$watchCollection).toHaveBeenCalled();
+ mockScope.$watchCollection.calls[0].args[1]();
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
mockDomainObject.useCapability.mostRecentCall.args[1](model);
- expect(model.configuration.plot.xAxis.key).toBe('lst');
expect(model.configuration.plot.yAxis.autoScale).toBe(true);
expect(model.configuration.plot.yAxis.key).toBe('eu');
+ expect(model.configuration.plot.xAxis.key).toBe('lst');
});
it("cleans up listeners on destruction of the controller", function () {
mockScope.$on.mostRecentCall.args[1]();
expect(mockUnlisten).toHaveBeenCalled();
- expect(mockFormUnlisten).toHaveBeenCalled();
});
});
diff --git a/platform/features/plot/test/PlotOptionsFormSpec.js b/platform/features/plot/test/PlotOptionsFormSpec.js
index 3b5e1a990e..49dfc823e9 100644
--- a/platform/features/plot/test/PlotOptionsFormSpec.js
+++ b/platform/features/plot/test/PlotOptionsFormSpec.js
@@ -28,21 +28,11 @@ define(
describe("The Plot Options form", function () {
var plotOptionsForm,
- mockTopicFunction,
- mockTopicObject,
listener;
beforeEach(function () {
- mockTopicObject = jasmine.createSpyObj('Topic', [
- 'listen',
- 'notify'
- ]);
- mockTopicFunction = function() {
- return mockTopicObject;
- };
-
- plotOptionsForm = new PlotOptionsForm(mockTopicFunction);
+ plotOptionsForm = new PlotOptionsForm();
});
it("defines form specs for x-axis, y-axis, and series data", function () {
@@ -55,19 +45,6 @@ define(
expect(plotOptionsForm.plotSeriesForm).toBeDefined();
});
- it("uses a topic to register a listener and inform them when a" +
- " form value changes", function () {
- var changedValue = 'changedValue';
-
- expect(plotOptionsForm.xAxisForm.onchange).toBeDefined();
-
- plotOptionsForm.listen(listener);
- expect(mockTopicObject.listen).toHaveBeenCalledWith(listener);
-
- plotOptionsForm.xAxisForm.onchange(changedValue);
- expect(mockTopicObject.notify).toHaveBeenCalledWith(changedValue);
- });
-
});
}
);
diff --git a/platform/forms/res/templates/controls/checkbox.html b/platform/forms/res/templates/controls/checkbox.html
index c676fb85cd..b23ea7c768 100644
--- a/platform/forms/res/templates/controls/checkbox.html
+++ b/platform/forms/res/templates/controls/checkbox.html
@@ -23,7 +23,6 @@
diff --git a/platform/forms/res/templates/controls/radio.html b/platform/forms/res/templates/controls/radio.html
index d5fb7284aa..2dd55c8813 100644
--- a/platform/forms/res/templates/controls/radio.html
+++ b/platform/forms/res/templates/controls/radio.html
@@ -24,7 +24,6 @@
name="mctControl"
ng-model="ngModel[field]"
ng-disabled="ngDisabled"
- ng-change="ngChange()"
ng-value="structure.value">
diff --git a/platform/forms/res/templates/controls/select.html b/platform/forms/res/templates/controls/select.html
index 9742bfb7d0..c8688a0010 100644
--- a/platform/forms/res/templates/controls/select.html
+++ b/platform/forms/res/templates/controls/select.html
@@ -24,7 +24,6 @@
ng-model="ngModel[field]"
ng-options="opt.value as opt.name for opt in options"
ng-required="ngRequired"
- ng-change="ngChange()"
name="mctControl">
diff --git a/platform/forms/res/templates/controls/textfield.html b/platform/forms/res/templates/controls/textfield.html
index c79cc83b90..fef977be7b 100644
--- a/platform/forms/res/templates/controls/textfield.html
+++ b/platform/forms/res/templates/controls/textfield.html
@@ -25,7 +25,6 @@
ng-required="ngRequired"
ng-model="ngModel[field]"
ng-pattern="ngPattern"
- ng-change="ngChange()"
size="{{structure.size}}"
name="mctControl">
diff --git a/platform/forms/res/templates/form.html b/platform/forms/res/templates/form.html
index b2e9aa8d01..edd4f81d1c 100644
--- a/platform/forms/res/templates/form.html
+++ b/platform/forms/res/templates/form.html
@@ -41,7 +41,6 @@