[Navigation Tree] Whole tree item clickable (#3632)

* passing click and context click on tree item down to object label, making the whole tree item interactive

* removed unnecessary code
This commit is contained in:
Jamie V 2021-01-08 11:55:43 -08:00 committed by GitHub
parent 2f8431905f
commit e6e07cf959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -42,6 +42,10 @@ export default {
navigateToPath: { navigateToPath: {
type: String, type: String,
default: undefined default: undefined
},
propagate: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@ -80,6 +84,10 @@ export default {
}, },
methods: { methods: {
navigateOrPreview(event) { navigateOrPreview(event) {
if (!this.propagate) {
event.stopPropagation();
}
if (this.openmct.editor.isEditing()) { if (this.openmct.editor.isEditing()) {
event.preventDefault(); event.preventDefault();
this.preview(); this.preview();

View File

@ -6,6 +6,8 @@
'position': virtualScroll ? 'absolute' : 'relative' 'position': virtualScroll ? 'absolute' : 'relative'
}" }"
class="c-tree__item-h" class="c-tree__item-h"
@click="handleClick"
@contextmenu="handleContextMenu"
> >
<div <div
class="c-tree__item" class="c-tree__item"
@ -20,9 +22,11 @@
class="c-tree__item__view-control" class="c-tree__item__view-control"
:control-class="'c-nav__up'" :control-class="'c-nav__up'"
:enabled="showUp" :enabled="showUp"
:propagate="false"
@input="resetTreeHere" @input="resetTreeHere"
/> />
<object-label <object-label
ref="objectLabel"
:domain-object="node.object" :domain-object="node.object"
:object-path="node.objectPath" :object-path="node.objectPath"
:navigate-to-path="navigationPath" :navigate-to-path="navigationPath"
@ -34,6 +38,7 @@
class="c-tree__item__view-control" class="c-tree__item__view-control"
:control-class="'c-nav__down'" :control-class="'c-nav__down'"
:enabled="hasComposition && showDown" :enabled="hasComposition && showDown"
:propagate="false"
/> />
</div> </div>
</div> </div>
@ -137,6 +142,13 @@ export default {
this.openmct.router.off('change:path', this.highlightIfNavigated); this.openmct.router.off('change:path', this.highlightIfNavigated);
}, },
methods: { methods: {
handleClick(event) {
this.$refs.objectLabel.$el.click();
},
handleContextMenu(event) {
this.$refs.objectLabel.showContextMenu(event);
event.stopPropagation();
},
isNavigated() { isNavigated() {
return this.navigationPath === this.openmct.router.currentLocation.path; return this.navigationPath === this.openmct.router.currentLocation.path;
}, },