mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 21:28:12 +00:00
[Conductor] Update inner bound on blur
The time conductor updates the inner and outer bounds when the input is blurred, which results in the query updating without dragging. Also allows time conductor to be utilized on mobile devices by entering dates directly. https://github.com/nasa/openmct/issues/318 User request: https://github.jpl.nasa.gov/MissionControl/vista/issues/175
This commit is contained in:
@ -66,6 +66,8 @@ define([
|
|||||||
this.outerMinimumSpan = 1000; // 1 second
|
this.outerMinimumSpan = 1000; // 1 second
|
||||||
this.initialDragValue = undefined;
|
this.initialDragValue = undefined;
|
||||||
this.formatter = formatService.getFormat(defaultFormat);
|
this.formatter = formatService.getFormat(defaultFormat);
|
||||||
|
this.formStartChanged = false;
|
||||||
|
this.formEndChanged = false;
|
||||||
|
|
||||||
this.$scope.ticks = [];
|
this.$scope.ticks = [];
|
||||||
|
|
||||||
@ -79,7 +81,9 @@ define([
|
|||||||
'updateOuterEnd',
|
'updateOuterEnd',
|
||||||
'updateFormat',
|
'updateFormat',
|
||||||
'validateStart',
|
'validateStart',
|
||||||
'validateEnd'
|
'validateEnd',
|
||||||
|
'onFormStartChange',
|
||||||
|
'onFormEndChange'
|
||||||
].forEach(function (boundFn) {
|
].forEach(function (boundFn) {
|
||||||
this[boundFn] = this[boundFn].bind(this);
|
this[boundFn] = this[boundFn].bind(this);
|
||||||
}, this);
|
}, this);
|
||||||
@ -89,6 +93,8 @@ define([
|
|||||||
this.$scope.$watch("ngModel.outer.start", this.updateOuterStart);
|
this.$scope.$watch("ngModel.outer.start", this.updateOuterStart);
|
||||||
this.$scope.$watch("ngModel.outer.end", this.updateOuterEnd);
|
this.$scope.$watch("ngModel.outer.end", this.updateOuterEnd);
|
||||||
this.$scope.$watch("parameters.format", this.updateFormat);
|
this.$scope.$watch("parameters.format", this.updateFormat);
|
||||||
|
this.$scope.$watch("formModel.start", this.onFormStartChange);
|
||||||
|
this.$scope.$watch("formModel.end", this.onFormEndChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeRangeController.prototype.formatTimestamp = function (ts) {
|
TimeRangeController.prototype.formatTimestamp = function (ts) {
|
||||||
@ -255,11 +261,35 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
TimeRangeController.prototype.updateBoundsFromForm = function () {
|
TimeRangeController.prototype.updateBoundsFromForm = function () {
|
||||||
var start = this.$scope.formModel.start,
|
if (this.formStartChanged) {
|
||||||
end = this.$scope.formModel.end;
|
this.$scope.ngModel.outer.start =
|
||||||
if (end >= start + this.outerMinimumSpan) {
|
this.$scope.ngModel.inner.start =
|
||||||
this.$scope.ngModel = this.$scope.ngModel || {};
|
this.$scope.formModel.start;
|
||||||
this.$scope.ngModel.outer = { start: start, end: end };
|
this.formStartChanged = false;
|
||||||
|
}
|
||||||
|
if (this.formEndChanged) {
|
||||||
|
this.$scope.ngModel.outer.end =
|
||||||
|
this.$scope.ngModel.inner.end =
|
||||||
|
this.$scope.formModel.end;
|
||||||
|
this.formEndChanged = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TimeRangeController.prototype.onFormStartChange = function (
|
||||||
|
newValue,
|
||||||
|
oldValue
|
||||||
|
) {
|
||||||
|
if (!this.formStartChanged && newValue !== oldValue) {
|
||||||
|
this.formStartChanged = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TimeRangeController.prototype.onFormEndChange = function (
|
||||||
|
newValue,
|
||||||
|
oldValue
|
||||||
|
) {
|
||||||
|
if (!this.formEndChanged && newValue !== oldValue) {
|
||||||
|
this.formEndChanged = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,25 +119,87 @@ define(
|
|||||||
start: DAY * 10000,
|
start: DAY * 10000,
|
||||||
end: DAY * 11000
|
end: DAY * 11000
|
||||||
};
|
};
|
||||||
// These watches may not exist, but Angular would fire
|
});
|
||||||
// them if they did.
|
|
||||||
|
it('updates all changed bounds when requested', function () {
|
||||||
fireWatchCollection("formModel", mockScope.formModel);
|
fireWatchCollection("formModel", mockScope.formModel);
|
||||||
fireWatch("formModel.start", mockScope.formModel.start);
|
fireWatch("formModel.start", mockScope.formModel.start);
|
||||||
fireWatch("formModel.end", mockScope.formModel.end);
|
fireWatch("formModel.end", mockScope.formModel.end);
|
||||||
});
|
|
||||||
|
|
||||||
it("does not immediately make changes to the model", function () {
|
|
||||||
expect(mockScope.ngModel.outer.start)
|
expect(mockScope.ngModel.outer.start)
|
||||||
.not.toEqual(mockScope.formModel.start);
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
|
||||||
expect(mockScope.ngModel.outer.end)
|
expect(mockScope.ngModel.outer.end)
|
||||||
.not.toEqual(mockScope.formModel.end);
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
|
||||||
|
controller.updateBoundsFromForm();
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.start)
|
||||||
|
.toEqual(mockScope.formModel.start);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.toEqual(mockScope.formModel.start);
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.end)
|
||||||
|
.toEqual(mockScope.formModel.end);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
|
.toEqual(mockScope.formModel.end);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates changed start bound when requested', function () {
|
||||||
|
fireWatchCollection("formModel", mockScope.formModel);
|
||||||
|
fireWatch("formModel.start", mockScope.formModel.start);
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.start)
|
||||||
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
|
||||||
|
controller.updateBoundsFromForm();
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.start)
|
||||||
|
.toEqual(mockScope.formModel.start);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.toEqual(mockScope.formModel.start);
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updates model bounds on request", function () {
|
it('updates changed end bound when requested', function () {
|
||||||
controller.updateBoundsFromForm();
|
fireWatchCollection("formModel", mockScope.formModel);
|
||||||
|
fireWatch("formModel.end", mockScope.formModel.end);
|
||||||
|
|
||||||
expect(mockScope.ngModel.outer.start)
|
expect(mockScope.ngModel.outer.start)
|
||||||
.toEqual(mockScope.formModel.start);
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
|
||||||
expect(mockScope.ngModel.outer.end)
|
expect(mockScope.ngModel.outer.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
|
.not.toEqual(mockScope.formModel.end);
|
||||||
|
|
||||||
|
controller.updateBoundsFromForm();
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.start)
|
||||||
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
expect(mockScope.ngModel.inner.start)
|
||||||
|
.not.toEqual(mockScope.formModel.start);
|
||||||
|
|
||||||
|
expect(mockScope.ngModel.outer.end)
|
||||||
|
.toEqual(mockScope.formModel.end);
|
||||||
|
expect(mockScope.ngModel.inner.end)
|
||||||
.toEqual(mockScope.formModel.end);
|
.toEqual(mockScope.formModel.end);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user