mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 06:08:11 +00:00
reworked logic for add/remove unit detection
This commit is contained in:
@ -76,14 +76,13 @@ export default {
|
|||||||
item.key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
item.key = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
|
|
||||||
this.items.push(item);
|
this.items.push(item);
|
||||||
if(!this.hasUnits) {
|
this.checkForUnits();
|
||||||
this.checkForUnits(domainObject);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
removeItem(identifier) {
|
removeItem(identifier) {
|
||||||
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
|
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
|
||||||
|
|
||||||
this.items.splice(index, 1);
|
this.items.splice(index, 1);
|
||||||
|
this.checkForUnits();
|
||||||
},
|
},
|
||||||
reorder(reorderPlan) {
|
reorder(reorderPlan) {
|
||||||
let oldItems = this.items.slice();
|
let oldItems = this.items.slice();
|
||||||
@ -91,14 +90,20 @@ export default {
|
|||||||
this.$set(this.items, reorderEvent.newIndex, oldItems[reorderEvent.oldIndex]);
|
this.$set(this.items, reorderEvent.newIndex, oldItems[reorderEvent.oldIndex]);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
checkForUnits(domainObject) {
|
checkForUnits() {
|
||||||
let metadata = this.openmct.telemetry.getMetadata(domainObject);
|
let metadatas = [];
|
||||||
metadata.valueMetadatas.forEach((metadatum) => {
|
let hasUnits = false;
|
||||||
if(metadatum.unit) {
|
this.items.forEach((item) => {
|
||||||
this.hasUnits = true;
|
let metadata = this.openmct.telemetry.getMetadata(item.domainObject);
|
||||||
return;
|
metadatas = metadatas.concat(metadata.valueMetadatas);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
for(let metadatum of metadatas) {
|
||||||
|
if(metadatum.unit) {
|
||||||
|
hasUnits = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.hasUnits = hasUnits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,6 @@ define(['lodash'], function (_) {
|
|||||||
.valueMetadatas
|
.valueMetadatas
|
||||||
.filter((metadatum) => metadatum.unit)
|
.filter((metadatum) => metadatum.unit)
|
||||||
.length;
|
.length;
|
||||||
console.log('hasUnits', hasUnits);
|
|
||||||
return hasUnits > 0;
|
return hasUnits > 0;
|
||||||
});
|
});
|
||||||
return results;
|
return results;
|
||||||
|
Reference in New Issue
Block a user