mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 15:02:23 +00:00
[Navigation Tree] Whole tree item clickable (#3638)
* passing click and context click on tree item down to object label, making the whole tree item interactive * removed unnecessary code * WIP: removing propagation prop from view control and just stopping all propagation * capturing click on tree item and then calling the click handler on objectLabel, this prevents multiple events and handles all clicks in the tree-item * removing unnecessary ref * ignoring clicks for view control so it can handle them itself * made view control class a constant * replaced class-based checks with ref-based checks * removing old leftover code
This commit is contained in:
parent
6f51de85db
commit
3e9b567fce
@ -31,7 +31,6 @@
|
|||||||
v-model="expanded"
|
v-model="expanded"
|
||||||
class="c-tree__item__view-control"
|
class="c-tree__item__view-control"
|
||||||
:enabled="hasChildren"
|
:enabled="hasChildren"
|
||||||
:propagate="false"
|
|
||||||
/>
|
/>
|
||||||
<div class="c-tree__item__label c-object-label">
|
<div class="c-tree__item__label c-object-label">
|
||||||
<div
|
<div
|
||||||
|
@ -22,10 +22,6 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
propagate: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
controlClass: {
|
controlClass: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'c-disclosure-triangle'
|
default: 'c-disclosure-triangle'
|
||||||
@ -33,10 +29,8 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClick(event) {
|
handleClick(event) {
|
||||||
|
event.stopPropagation();
|
||||||
this.$emit('input', !this.value);
|
this.$emit('input', !this.value);
|
||||||
if (!this.propagate) {
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
ref="me"
|
|
||||||
:style="{
|
:style="{
|
||||||
'top': virtualScroll ? itemTop : 'auto',
|
'top': virtualScroll ? itemTop : 'auto',
|
||||||
'position': virtualScroll ? 'absolute' : 'relative'
|
'position': virtualScroll ? 'absolute' : 'relative'
|
||||||
@ -14,8 +13,11 @@
|
|||||||
'is-navigated-object': navigated,
|
'is-navigated-object': navigated,
|
||||||
'is-context-clicked': contextClickActive
|
'is-context-clicked': contextClickActive
|
||||||
}"
|
}"
|
||||||
|
@click.capture="handleClick"
|
||||||
|
@contextmenu.capture="handleContextMenu"
|
||||||
>
|
>
|
||||||
<view-control
|
<view-control
|
||||||
|
ref="navUp"
|
||||||
v-model="expanded"
|
v-model="expanded"
|
||||||
class="c-tree__item__view-control"
|
class="c-tree__item__view-control"
|
||||||
:control-class="'c-nav__up'"
|
:control-class="'c-nav__up'"
|
||||||
@ -23,6 +25,7 @@
|
|||||||
@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"
|
||||||
@ -30,6 +33,7 @@
|
|||||||
@context-click-active="setContextClickActive"
|
@context-click-active="setContextClickActive"
|
||||||
/>
|
/>
|
||||||
<view-control
|
<view-control
|
||||||
|
ref="navDown"
|
||||||
v-model="expanded"
|
v-model="expanded"
|
||||||
class="c-tree__item__view-control"
|
class="c-tree__item__view-control"
|
||||||
:control-class="'c-nav__down'"
|
:control-class="'c-nav__down'"
|
||||||
@ -137,6 +141,20 @@ export default {
|
|||||||
this.openmct.router.off('change:path', this.highlightIfNavigated);
|
this.openmct.router.off('change:path', this.highlightIfNavigated);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleClick(event) {
|
||||||
|
// skip for navigation, let viewControl handle click
|
||||||
|
if ([this.$refs.navUp.$el, this.$refs.navDown.$el].includes(event.target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
this.$refs.objectLabel.$el.click();
|
||||||
|
},
|
||||||
|
handleContextMenu(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
this.$refs.objectLabel.showContextMenu(event);
|
||||||
|
},
|
||||||
isNavigated() {
|
isNavigated() {
|
||||||
return this.navigationPath === this.openmct.router.currentLocation.path;
|
return this.navigationPath === this.openmct.router.currentLocation.path;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user