Preview instead of navigate in edit mode + highlight navigated object (#2252)

* Preview instead of navigate when in edit mode.

* Prevent preview of navigated object

* Removed trailing comma

* Observe navigation from tree items instead of mct-tree

* Cleanup of redundant code

* .is-selected -> .is-navigated-object
This commit is contained in:
Andrew Henry
2019-01-11 11:21:52 -08:00
committed by Pete Richards
parent 4084a1ac86
commit 92b2582d0d
8 changed files with 56 additions and 10 deletions

View File

@ -2,6 +2,7 @@
<a class="c-tree__item__label"
draggable="true"
@dragstart="dragStart"
@click="navigateOrPreview"
:href="objectLink">
<div class="c-tree__item__type-icon"
:class="typeClass"></div>
@ -13,12 +14,19 @@
import ObjectLink from '../mixins/object-link';
import ContextMenuGesture from '../mixins/context-menu-gesture';
import PreviewAction from '../preview/PreviewAction.js';
export default {
mixins: [ObjectLink, ContextMenuGesture],
inject: ['openmct'],
props: {
domainObject: Object
domainObject: Object,
objectPath: {
type: Array,
default() {
return [];
}
}
},
data() {
return {
@ -32,6 +40,7 @@ export default {
});
this.$once('hook:destroyed', removeListener);
}
this.previewAction = new PreviewAction(this.openmct);
},
computed: {
typeClass() {
@ -43,6 +52,17 @@ export default {
}
},
methods: {
navigateOrPreview(event) {
if (this.openmct.editor.isEditing()){
event.preventDefault();
this.preview();
}
},
preview() {
if (this.previewAction.appliesTo(this.objectPath)){
this.previewAction.invoke(this.objectPath);
}
},
dragStart(event) {
let navigatedObject = this.openmct.router.path[0];
let serializedObject = JSON.stringify(this.observedObject);