mirror of
https://github.com/nasa/openmct.git
synced 2025-04-07 19:34:25 +00:00
Support deltaFormat on timeSystems
This commit is contained in:
parent
900752208f
commit
f844495cc1
@ -56,6 +56,10 @@ define([
|
||||
return this._formats;
|
||||
};
|
||||
|
||||
LocalTimeSystem.prototype.deltaFormat = function () {
|
||||
return 'duration';
|
||||
};
|
||||
|
||||
LocalTimeSystem.prototype.tickSources = function () {
|
||||
return this._tickSources;
|
||||
};
|
||||
|
@ -24,6 +24,7 @@ define([
|
||||
"./src/ui/TimeConductorService",
|
||||
"./src/ui/TimeConductorController",
|
||||
"./src/ui/MCTConductorAxis",
|
||||
"./src/ui/NumberFormat",
|
||||
"text!./res/templates/time-conductor.html",
|
||||
"text!./res/templates/mode-selector/mode-selector.html",
|
||||
"text!./res/templates/mode-selector/mode-menu.html",
|
||||
@ -32,6 +33,7 @@ define([
|
||||
TimeConductorService,
|
||||
TimeConductorController,
|
||||
MCTConductorAxis,
|
||||
NumberFormat,
|
||||
timeConductorTemplate,
|
||||
modeSelectorTemplate,
|
||||
modeMenuTemplate,
|
||||
@ -99,6 +101,12 @@ define([
|
||||
"key": "mode-menu",
|
||||
"template": modeMenuTemplate
|
||||
}
|
||||
],
|
||||
"formats": [
|
||||
{
|
||||
"key": "number",
|
||||
"implementation": NumberFormat
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
@ -31,7 +31,7 @@
|
||||
-
|
||||
<mct-control key="'datetime-field'"
|
||||
structure="{
|
||||
format: 'duration',
|
||||
format: timeSystemModel.deltaFormat,
|
||||
validate: tcController.validation.validateStartDelta
|
||||
}"
|
||||
ng-model="formModel"
|
||||
@ -62,7 +62,7 @@
|
||||
+
|
||||
<mct-control key="'datetime-field'"
|
||||
structure="{
|
||||
format: 'duration',
|
||||
format: timeSystemModel.deltaFormat,
|
||||
validate: tcController.validation.validateEndDelta
|
||||
}"
|
||||
ng-model="formModel"
|
||||
|
@ -48,6 +48,23 @@ define([], function () {
|
||||
throw new Error('Not implemented');
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef DeltaFormat
|
||||
* @property {string} type the type of MctControl used to represent this
|
||||
* field. Typically 'datetime-field' for UTC based dates, or 'textfield'
|
||||
* otherwise
|
||||
* @property {string} [format] An optional field specifying the
|
||||
* Format to use for delta fields in this time system.
|
||||
*/
|
||||
/**
|
||||
* Specifies a format for deltas in this time system.
|
||||
*
|
||||
* @returns {DeltaFormat} a delta format specifier
|
||||
*/
|
||||
TimeSystem.prototype.deltaFormat = function () {
|
||||
throw new Error('Not implemented');
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the tick sources supported by this time system. Tick sources
|
||||
* are event generators that can be used to advance the time conductor
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
'moment'
|
||||
], function (
|
||||
moment
|
||||
) {
|
||||
|
||||
/**
|
||||
* Formatter for basic numbers. Provides basic support for non-UTC
|
||||
* numbering systems
|
||||
*
|
||||
* @implements {Format}
|
||||
* @constructor
|
||||
* @memberof platform/commonUI/formats
|
||||
*/
|
||||
function NumberFormat() {
|
||||
}
|
||||
|
||||
NumberFormat.prototype.format = function (value) {
|
||||
if (isNaN(value)){
|
||||
return '';
|
||||
} else {
|
||||
return '' + value;
|
||||
}
|
||||
};
|
||||
|
||||
NumberFormat.prototype.parse = function (text) {
|
||||
return parseFloat(text);
|
||||
};
|
||||
|
||||
NumberFormat.prototype.validate = function (text) {
|
||||
return !isNaN(text);
|
||||
};
|
||||
|
||||
return NumberFormat;
|
||||
});
|
@ -163,9 +163,9 @@ define(
|
||||
var mode = this.conductorService.mode(),
|
||||
deltas = mode.deltas();
|
||||
|
||||
if (deltas !== undefined && this.validation.validateDeltas(formModel)) {
|
||||
if (deltas !== undefined && this.validation.validateDeltas(formModel.startDelta, formModel.endDelta)) {
|
||||
//Sychronize deltas between form and mode
|
||||
mode.deltas({start: formModel.startDelta, end: formModel.endDelta});
|
||||
mode.deltas({start: parseFloat(formModel.startDelta), end: parseFloat(formModel.endDelta)});
|
||||
}
|
||||
};
|
||||
|
||||
@ -270,6 +270,7 @@ define(
|
||||
if (newTimeSystem && newTimeSystem !== this.$scope.timeSystemModel.selected) {
|
||||
this.$scope.timeSystemModel.selected = newTimeSystem;
|
||||
this.$scope.timeSystemModel.format = newTimeSystem.formats()[0];
|
||||
this.$scope.timeSystemModel.deltaFormat = newTimeSystem.deltaFormat();
|
||||
var mode = this.conductorService.mode();
|
||||
mode.selectedTimeSystem(newTimeSystem);
|
||||
this.setDeltasFromTimeSystem(newTimeSystem);
|
||||
|
@ -54,11 +54,11 @@ define(
|
||||
};
|
||||
|
||||
TimeConductorValidation.prototype.validateStartDelta = function (startDelta) {
|
||||
return startDelta > 0;
|
||||
return !isNaN(startDelta) && startDelta > 0;
|
||||
};
|
||||
|
||||
TimeConductorValidation.prototype.validateEndDelta = function (endDelta) {
|
||||
return endDelta >= 0;
|
||||
return !isNaN(endDelta) && endDelta >= 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -68,10 +68,10 @@ define(
|
||||
* @param formModel
|
||||
* @returns {*}
|
||||
*/
|
||||
TimeConductorValidation.prototype.validateDeltas = function (formModel) {
|
||||
TimeConductorValidation.prototype.validateDeltas = function (startDelta, endDelta) {
|
||||
// Validate that start Delta is some non-zero value, and that end
|
||||
// delta is zero or positive (ie. 'now' or some time in the future).
|
||||
return this.validateStartDelta(formModel.startDelta) && this.validateEndDelta(formModel.endDelta);
|
||||
return this.validateStartDelta(startDelta) && this.validateEndDelta(endDelta);
|
||||
};
|
||||
|
||||
return TimeConductorValidation;
|
||||
|
@ -56,6 +56,10 @@ define([
|
||||
return this._formats;
|
||||
};
|
||||
|
||||
UTCTimeSystem.prototype.deltaFormat = function () {
|
||||
return 'duration';
|
||||
};
|
||||
|
||||
UTCTimeSystem.prototype.tickSources = function () {
|
||||
return this._tickSources;
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
<input type="text"
|
||||
ng-required="ngRequired"
|
||||
ng-model="ngModel[field]"
|
||||
ng-blur="ngBlur()"
|
||||
ng-pattern="ngPattern"
|
||||
size="{{structure.size}}"
|
||||
name="mctControl">
|
||||
|
Loading…
x
Reference in New Issue
Block a user