mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 17:57:04 +00:00
fixing implementation for telemetry view items in display layout
This commit is contained in:
parent
7f7518bb9d
commit
551364ad8c
@ -515,11 +515,14 @@ define(['lodash'], function (_) {
|
||||
|
||||
function getToggleUnitsButton(selectedParent, selection) {
|
||||
let applicableItems = getAllOfType(selection, 'telemetry-view');
|
||||
applicableItems = unitsOnly(applicableItems);
|
||||
if(!applicableItems.length) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
control: "toggle-button",
|
||||
domainObject: selectedParent,
|
||||
applicableSelectedItems: applicableItems,
|
||||
contextMethod: 'toggleUnits',
|
||||
property: function (selectionPath) {
|
||||
return getPath(selectionPath) + '.showUnits';
|
||||
},
|
||||
@ -538,6 +541,20 @@ define(['lodash'], function (_) {
|
||||
};
|
||||
}
|
||||
|
||||
function unitsOnly(items) {
|
||||
let results = items.filter((item) => {
|
||||
let currentItem = item[0];
|
||||
let metadata = this.openmct.telemetry.getMetadata(currentItem.context.item);
|
||||
let hasUnits = metadata
|
||||
.valueMetadatas
|
||||
.filter((metadatum) => metadatum.unit)
|
||||
.length;
|
||||
console.log('hasUnits', hasUnits);
|
||||
return hasUnits > 0;
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
function getViewSwitcherMenu(selectedParent, selectionPath, selection) {
|
||||
if (selection.length === 1) {
|
||||
let displayLayoutContext = selectionPath[1].context,
|
||||
@ -683,7 +700,10 @@ define(['lodash'], function (_) {
|
||||
toolbar.viewSwitcher = [getViewSwitcherMenu(selectedParent, selectionPath, selectedObjects)];
|
||||
}
|
||||
if (toolbar['unit-toggle'].length === 0) {
|
||||
toolbar['unit-toggle'] = [getToggleUnitsButton(selectedParent, selectedObjects)];
|
||||
let toggleUnitsButton = getToggleUnitsButton(selectedParent, selectedObjects);
|
||||
if(toggleUnitsButton) {
|
||||
toolbar['unit-toggle'] = [toggleUnitsButton];
|
||||
}
|
||||
}
|
||||
} else if (layoutItem.type === 'text-view') {
|
||||
if (toolbar['text-style'].length === 0) {
|
||||
|
@ -59,7 +59,7 @@
|
||||
<div class="c-telemetry-view__value-text">
|
||||
{{ telemetryValue }}
|
||||
<span
|
||||
v-if="unit && showUnits"
|
||||
v-if="unit && item.showUnits"
|
||||
class="c-telemetry-view__value-text__unit"
|
||||
>
|
||||
{{ unit }}
|
||||
@ -129,8 +129,7 @@ export default {
|
||||
datum: undefined,
|
||||
formats: undefined,
|
||||
domainObject: undefined,
|
||||
currentObjectPath: undefined,
|
||||
showUnits: true
|
||||
currentObjectPath: undefined
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -279,9 +278,6 @@ export default {
|
||||
},
|
||||
showContextMenu(event) {
|
||||
this.openmct.contextMenu._showContextMenuForObjectPath(this.currentObjectPath, event.x, event.y, CONTEXT_MENU_ACTIONS);
|
||||
},
|
||||
toggleUnits(show) {
|
||||
this.showUnits = show;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,13 +231,7 @@ export default {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(item.contextMethod) {
|
||||
let method = item.contextMethod;
|
||||
item.applicableSelectedItems.forEach(selectionPath => {
|
||||
this.mutateObject(item, value, selectionPath);
|
||||
selectionPath[0].context[method](value);
|
||||
});
|
||||
} else if (item.applicableSelectedItems) {
|
||||
if (item.applicableSelectedItems) {
|
||||
item.applicableSelectedItems.forEach(selectionPath => {
|
||||
this.mutateObject(item, value, selectionPath);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user