mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +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">
|
:href="objectLink">
|
||||||
<div class="c-tree__item__type-icon"
|
<div class="c-tree__item__type-icon"
|
||||||
:class="typeClass"></div>
|
:class="typeClass"></div>
|
||||||
<div class="c-tree__item__name">{{ domainObject.name }}</div>
|
<div class="c-tree__item__name">{{ observedObject.name }}</div>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -18,11 +18,24 @@ export default {
|
|||||||
mixins: [ContextMenu, ObjectLink],
|
mixins: [ContextMenu, ObjectLink],
|
||||||
inject: ['openmct'],
|
inject: ['openmct'],
|
||||||
props: {
|
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: {
|
computed: {
|
||||||
typeClass() {
|
typeClass() {
|
||||||
let type = this.openmct.types.get(this.domainObject.type);
|
let type = this.openmct.types.get(this.observedObject.type);
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return 'icon-object-unknown';
|
return 'icon-object-unknown';
|
||||||
}
|
}
|
||||||
@ -31,7 +44,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
dragStart(event) {
|
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: should support drag/drop composition
|
||||||
// TODO: set isAlias per tree-item
|
// TODO: set isAlias per tree-item
|
||||||
|
|
||||||
this.composition = this.openmct.composition.get(this.node.object);
|
this.domainObject = this.node.object;
|
||||||
if (this.composition) {
|
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;
|
this.hasChildren = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -68,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
this.expanded = !this.expanded;
|
this.expanded = !this.expanded;
|
||||||
if (!this.loaded && !this.isLoading) {
|
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('add', this.addChild);
|
||||||
this.composition.on('remove', this.removeChild);
|
this.composition.on('remove', this.removeChild);
|
||||||
this.composition.load().then(this.finishLoading());
|
this.composition.load().then(this.finishLoading());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user