Merge remote-tracking branch 'origin/open1018-new'

This commit is contained in:
Pete Richards 2016-06-27 09:13:03 -07:00
commit 652a50c700
3 changed files with 26 additions and 13 deletions

View File

@ -204,6 +204,7 @@ define([
"implementation": TimeRangeController, "implementation": TimeRangeController,
"depends": [ "depends": [
"$scope", "$scope",
"$timeout",
"formatService", "formatService",
"DEFAULT_TIME_FORMAT", "DEFAULT_TIME_FORMAT",
"now" "now"

View File

@ -53,7 +53,7 @@ define([
* format has been otherwise specified * format has been otherwise specified
* @param {Function} now a function to return current system time * @param {Function} now a function to return current system time
*/ */
function TimeRangeController($scope, formatService, defaultFormat, now) { function TimeRangeController($scope, $timeout, formatService, defaultFormat, now) {
this.$scope = $scope; this.$scope = $scope;
this.formatService = formatService; this.formatService = formatService;
this.defaultFormat = defaultFormat; this.defaultFormat = defaultFormat;
@ -66,6 +66,7 @@ define([
this.formatter = formatService.getFormat(defaultFormat); this.formatter = formatService.getFormat(defaultFormat);
this.formStartChanged = false; this.formStartChanged = false;
this.formEndChanged = false; this.formEndChanged = false;
this.$timeout = $timeout;
this.$scope.ticks = []; this.$scope.ticks = [];
@ -259,18 +260,23 @@ define([
}; };
TimeRangeController.prototype.updateBoundsFromForm = function () { TimeRangeController.prototype.updateBoundsFromForm = function () {
if (this.formStartChanged) { var self = this;
this.$scope.ngModel.outer.start =
this.$scope.ngModel.inner.start = //Allow Angular to trigger watches and determine whether values have changed.
this.$scope.formModel.start; this.$timeout(function () {
this.formStartChanged = false; if (self.formStartChanged) {
self.$scope.ngModel.outer.start =
self.$scope.ngModel.inner.start =
self.$scope.formModel.start;
self.formStartChanged = false;
} }
if (this.formEndChanged) { if (self.formEndChanged) {
this.$scope.ngModel.outer.end = self.$scope.ngModel.outer.end =
this.$scope.ngModel.inner.end = self.$scope.ngModel.inner.end =
this.$scope.formModel.end; self.$scope.formModel.end;
this.formEndChanged = false; self.formEndChanged = false;
} }
});
}; };
TimeRangeController.prototype.onFormStartChange = function ( TimeRangeController.prototype.onFormStartChange = function (

View File

@ -33,6 +33,7 @@ define(
var mockScope, var mockScope,
mockFormatService, mockFormatService,
testDefaultFormat, testDefaultFormat,
mockTimeout,
mockNow, mockNow,
mockFormat, mockFormat,
controller; controller;
@ -54,6 +55,10 @@ define(
} }
beforeEach(function () { beforeEach(function () {
mockTimeout = function (fn) {
return fn();
};
mockScope = jasmine.createSpyObj( mockScope = jasmine.createSpyObj(
"$scope", "$scope",
["$apply", "$watch", "$watchCollection"] ["$apply", "$watch", "$watchCollection"]
@ -78,6 +83,7 @@ define(
controller = new TimeRangeController( controller = new TimeRangeController(
mockScope, mockScope,
mockTimeout,
mockFormatService, mockFormatService,
testDefaultFormat, testDefaultFormat,
mockNow mockNow