mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
Ensure labels and tree items stay in sync
This commit is contained in:
parent
bc512f3766
commit
e05dbadea2
@ -5,7 +5,7 @@
|
||||
:href="objectLink">
|
||||
<div class="c-tree__item__type-icon"
|
||||
:class="typeClass"></div>
|
||||
<div class="c-tree__item__name">{{ domainObject.name }}</div>
|
||||
<div class="c-tree__item__name">{{ observedObject.name }}</div>
|
||||
</a>
|
||||
</template>
|
||||
|
||||
@ -18,11 +18,24 @@ export default {
|
||||
mixins: [ContextMenu, ObjectLink],
|
||||
inject: ['openmct'],
|
||||
props: {
|
||||
'domainObject': Object,
|
||||
domainObject: Object
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
observedObject: this.domainObject
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
if (this.observedObject) {
|
||||
let removeListener = this.openmct.objects.observe(this.observedObject, '*', (newObject) => {
|
||||
this.observedObject = newObject;
|
||||
});
|
||||
this.$once('hook:destroyed', removeListener);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
typeClass() {
|
||||
let type = this.openmct.types.get(this.domainObject.type);
|
||||
let type = this.openmct.types.get(this.observedObject.type);
|
||||
if (!type) {
|
||||
return 'icon-object-unknown';
|
||||
}
|
||||
@ -31,7 +44,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
dragStart(event) {
|
||||
event.dataTransfer.setData("domainObject", JSON.stringify(this.domainObject));
|
||||
event.dataTransfer.setData("domainObject", JSON.stringify(this.observedObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +49,12 @@
|
||||
// TODO: should support drag/drop composition
|
||||
// TODO: set isAlias per tree-item
|
||||
|
||||
this.composition = this.openmct.composition.get(this.node.object);
|
||||
if (this.composition) {
|
||||
this.domainObject = this.node.object;
|
||||
let removeListener = this.openmct.objects.observe(this.domainObject, '*', (newObject) => {
|
||||
this.domainObject = newObject;
|
||||
});
|
||||
this.$once('hook:destroyed', removeListener);
|
||||
if (this.openmct.composition.get(this.node.object)) {
|
||||
this.hasChildren = true;
|
||||
}
|
||||
},
|
||||
@ -68,7 +72,7 @@
|
||||
}
|
||||
this.expanded = !this.expanded;
|
||||
if (!this.loaded && !this.isLoading) {
|
||||
this.composition = this.openmct.composition.get(this.node.object);
|
||||
this.composition = this.openmct.composition.get(this.domainObject);
|
||||
this.composition.on('add', this.addChild);
|
||||
this.composition.on('remove', this.removeChild);
|
||||
this.composition.load().then(this.finishLoading());
|
||||
|
Loading…
Reference in New Issue
Block a user