mirror of
https://github.com/nasa/openmct.git
synced 2025-06-23 01:18:57 +00:00
Basic sprintf support (#1965)
Implement optional format strings for valueMetadata which allows developers to use c-style sprintf formatters as desired. Fixes #1562
This commit is contained in:
committed by
Andrew Henry
parent
29de11167f
commit
013eba744d
@ -21,9 +21,11 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
'lodash'
|
||||
'lodash',
|
||||
'printj'
|
||||
], function (
|
||||
_
|
||||
_,
|
||||
printj
|
||||
) {
|
||||
|
||||
// TODO: needs reference to formatService;
|
||||
@ -71,6 +73,14 @@ define([
|
||||
return Number(string);
|
||||
}.bind(this);
|
||||
}
|
||||
// Check for formatString support once instead of per format call.
|
||||
if (valueMetadata.formatString) {
|
||||
var baseFormat = this.formatter.format;
|
||||
var formatString = valueMetadata.formatString;
|
||||
this.formatter.format = function (value) {
|
||||
return printj.sprintf(formatString, baseFormat.call(this, value));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
TelemetryValueFormatter.prototype.parse = function (datum) {
|
||||
|
Reference in New Issue
Block a user