Files
openmct/src/ui/mixins/context-menu-gesture.js
Charles Hacskaylo 6375ecda34 Three Dot Menu Prototype (#3325)
* Three dot menu implementation

Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
Co-authored-by: Nikhil <nikhil.k.mandlik@nasa.gov>
2020-11-19 09:53:06 -08:00

42 lines
1.2 KiB
JavaScript

export default {
inject: ['openmct'],
props: {
'objectPath': {
type: Array,
default() {
return [];
}
}
},
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.get(this.objectPath);
let actions = actionsCollection.getVisibleActions();
let sortedActions = this.openmct.actions._groupAndSortActions(actions);
this.openmct.menus.showMenu(event.clientX, event.clientY, sortedActions);
}
}
};