OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/frontend/app/components/wp-fast-table/handlers/context-menu/context-menu-keyboard-handl...

43 lines
1.1 KiB

import {Injector} from '@angular/core';
import {keyCodes} from '../../../common/keyCodes.enum';
import {WorkPackageTable} from '../../wp-fast-table';
import {ContextMenuHandler} from './context-menu-handler';
export class ContextMenuKeyboardHandler extends ContextMenuHandler {
constructor(public readonly injector:Injector,
table:WorkPackageTable) {
super(injector, table);
}
public get EVENT() {
return 'keydown.table.contextmenu';
}
public get SELECTOR() {
return this.rowSelector;
}
public handleEvent(table:WorkPackageTable, evt:JQueryEventObject):boolean {
let target = jQuery(evt.target);
if (!(evt.keyCode === keyCodes.F10 && evt.shiftKey && evt.altKey)) {
return true;
}
evt.preventDefault();
evt.stopPropagation();
// Locate the row from event
const element = target.closest(this.SELECTOR);
const wpId = element.data('workPackageId');
// Set position args to open at element
let position = {of: target};
super.openContextMenu(evt, wpId, position);
return false;
}
}