[Time Conductor] Bounds updated when date selected from date selector. Fixes #1018

This commit is contained in:
Andrew Henry 2016-06-24 21:30:03 -07:00
parent 8bdf1e3072
commit 2339560363
3 changed files with 26 additions and 13 deletions

View File

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

View File

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

View File

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