Skip to content

Commit 652a50c

Browse files
author
Pete Richards
committed
Merge remote-tracking branch 'origin/open1018-new'
2 parents 736cba7 + 2339560 commit 652a50c

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

Diff for: platform/commonUI/general/bundle.js

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ define([
204204
"implementation": TimeRangeController,
205205
"depends": [
206206
"$scope",
207+
"$timeout",
207208
"formatService",
208209
"DEFAULT_TIME_FORMAT",
209210
"now"

Diff for: platform/commonUI/general/src/controllers/TimeRangeController.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ define([
5353
* format has been otherwise specified
5454
* @param {Function} now a function to return current system time
5555
*/
56-
function TimeRangeController($scope, formatService, defaultFormat, now) {
56+
function TimeRangeController($scope, $timeout, formatService, defaultFormat, now) {
5757
this.$scope = $scope;
5858
this.formatService = formatService;
5959
this.defaultFormat = defaultFormat;
@@ -66,6 +66,7 @@ define([
6666
this.formatter = formatService.getFormat(defaultFormat);
6767
this.formStartChanged = false;
6868
this.formEndChanged = false;
69+
this.$timeout = $timeout;
6970

7071
this.$scope.ticks = [];
7172

@@ -259,18 +260,23 @@ define([
259260
};
260261

261262
TimeRangeController.prototype.updateBoundsFromForm = function () {
262-
if (this.formStartChanged) {
263-
this.$scope.ngModel.outer.start =
264-
this.$scope.ngModel.inner.start =
265-
this.$scope.formModel.start;
266-
this.formStartChanged = false;
267-
}
268-
if (this.formEndChanged) {
269-
this.$scope.ngModel.outer.end =
270-
this.$scope.ngModel.inner.end =
271-
this.$scope.formModel.end;
272-
this.formEndChanged = false;
273-
}
263+
var self = this;
264+
265+
//Allow Angular to trigger watches and determine whether values have changed.
266+
this.$timeout(function () {
267+
if (self.formStartChanged) {
268+
self.$scope.ngModel.outer.start =
269+
self.$scope.ngModel.inner.start =
270+
self.$scope.formModel.start;
271+
self.formStartChanged = false;
272+
}
273+
if (self.formEndChanged) {
274+
self.$scope.ngModel.outer.end =
275+
self.$scope.ngModel.inner.end =
276+
self.$scope.formModel.end;
277+
self.formEndChanged = false;
278+
}
279+
});
274280
};
275281

276282
TimeRangeController.prototype.onFormStartChange = function (

Diff for: platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ define(
3333
var mockScope,
3434
mockFormatService,
3535
testDefaultFormat,
36+
mockTimeout,
3637
mockNow,
3738
mockFormat,
3839
controller;
@@ -54,6 +55,10 @@ define(
5455
}
5556

5657
beforeEach(function () {
58+
mockTimeout = function (fn) {
59+
return fn();
60+
};
61+
5762
mockScope = jasmine.createSpyObj(
5863
"$scope",
5964
["$apply", "$watch", "$watchCollection"]
@@ -78,6 +83,7 @@ define(
7883

7984
controller = new TimeRangeController(
8085
mockScope,
86+
mockTimeout,
8187
mockFormatService,
8288
testDefaultFormat,
8389
mockNow

0 commit comments

Comments
 (0)