mirror of
https://github.com/nasa/openmct.git
synced 2025-06-20 08:03:49 +00:00
[Code Style] Use prototypes in Plot bundle
WTD-1482.
This commit is contained in:
@ -28,39 +28,38 @@ define(
|
||||
/**
|
||||
* Policy preventing the Plot view from being made available for
|
||||
* domain objects which have non-numeric telemetry.
|
||||
* @implements {Policy}
|
||||
* @implements {Policy.<View, DomainObject>}
|
||||
* @constructor
|
||||
* @memberof platform/features/plot
|
||||
*/
|
||||
function PlotViewPolicy() {
|
||||
function hasImageTelemetry(domainObject) {
|
||||
var telemetry = domainObject &&
|
||||
domainObject.getCapability('telemetry'),
|
||||
metadata = telemetry ? telemetry.getMetadata() : {},
|
||||
ranges = metadata.ranges || [];
|
||||
}
|
||||
|
||||
// Generally, we want to allow Plot for telemetry-providing
|
||||
// objects (most telemetry is plottable.) We only want to
|
||||
// suppress this for telemetry which only has explicitly
|
||||
// non-numeric values.
|
||||
return ranges.length === 0 || ranges.some(function (range) {
|
||||
function hasNumericTelemetry(domainObject) {
|
||||
var telemetry = domainObject &&
|
||||
domainObject.getCapability('telemetry'),
|
||||
metadata = telemetry ? telemetry.getMetadata() : {},
|
||||
ranges = metadata.ranges || [];
|
||||
|
||||
// Generally, we want to allow Plot for telemetry-providing
|
||||
// objects (most telemetry is plottable.) We only want to
|
||||
// suppress this for telemetry which only has explicitly
|
||||
// non-numeric values.
|
||||
return ranges.length === 0 || ranges.some(function (range) {
|
||||
// Assume format is numeric if it is undefined
|
||||
// (numeric telemetry is the common case)
|
||||
return range.format === undefined ||
|
||||
range.format === 'number';
|
||||
range.format === 'number';
|
||||
});
|
||||
}
|
||||
|
||||
PlotViewPolicy.prototype.allow = function (view, domainObject) {
|
||||
if (view.key === 'plot') {
|
||||
return hasNumericTelemetry(domainObject);
|
||||
}
|
||||
|
||||
return {
|
||||
allow: function (view, domainObject) {
|
||||
if (view.key === 'plot') {
|
||||
return hasImageTelemetry(domainObject);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
return PlotViewPolicy;
|
||||
}
|
||||
|
Reference in New Issue
Block a user