openmct/src/ui/mixins/context-menu-gesture.js
Nikhil 071a13b219
[Imagery] Click on image to get a large view (#3770)
* [Imagery] Click on image to get a large view #3582
* Created new viewLargeAction.
* Changes in view registry to add parent element property inside view object.
* Separate class for views and added missing changes for LadTableSet.
* Renamed callBack to onItemClicked.

Co-authored-by: Andrew Henry <akhenry@gmail.com>
2021-07-29 09:19:07 -07:00

58 lines
1.8 KiB
JavaScript

export default {
inject: ['openmct'],
props: {
'objectPath': {
type: Array,
default() {
return [];
}
}
},
data() {
return {
contextClickActive: false
};
},
mounted() {
//TODO: touch support
this.$el.addEventListener('contextmenu', this.showContextMenu);
function updateObject(oldObject, newObject) {
Object.assign(oldObject, newObject);
}
this.objectPath.forEach(object => {
if (object) {
this.$once('hook:destroyed',
this.openmct.objects.observe(object, '*', updateObject.bind(this, object)));
}
});
},
destroyed() {
this.$el.removeEventListener('contextMenu', this.showContextMenu);
},
methods: {
showContextMenu(event) {
event.preventDefault();
event.stopPropagation();
let actionsCollection = this.openmct.actions.getActionsCollection(this.objectPath);
let actions = actionsCollection.getVisibleActions();
let sortedActions = this.openmct.actions._groupAndSortActions(actions);
const menuOptions = {
onDestroy: this.onContextMenuDestroyed
};
const menuItems = this.openmct.menus.actionsToMenuItems(sortedActions, actionsCollection.objectPath, actionsCollection.view);
this.openmct.menus.showMenu(event.clientX, event.clientY, menuItems, menuOptions);
this.contextClickActive = true;
this.$emit('context-click-active', true);
},
onContextMenuDestroyed() {
this.contextClickActive = false;
this.$emit('context-click-active', false);
}
}
};