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/table-handler-registry.ts

76 lines
2.7 KiB

import {TimelineTransformer} from "./state/timeline-transformer";
import {HierarchyTransformer} from "./state/hierarchy-transformer";
import {WorkPackageTable} from "../wp-fast-table";
import {SelectionTransformer} from "./state/selection-transformer";
import {RowsTransformer} from "./state/rows-transformer";
import {ColumnsTransformer} from "./state/columns-transformer";
import {ContextMenuKeyboardHandler} from "./context-menu/context-menu-keyboard-handler";
import {GroupRowHandler} from "./row/group-row-handler";
import {RowDoubleClickHandler} from "./row/double-click-handler";
import {RowClickHandler} from "./row/click-handler";
import {WorkPackageStateLinksHandler} from "./row/wp-state-links-handler";
import {EditCellHandler} from "./cell/edit-cell-handler";
import {HierarchyClickHandler} from "./row/hierarchy-click-handler";
import {RelationsCellHandler} from './cell/relations-cell-handler';
import {RelationsTransformer} from './state/relations-transformer';
import {ContextMenuRightClickHandler} from "./context-menu/context-menu-rightclick-handler";
import {ContextMenuClickHandler} from "./context-menu/context-menu-click-handler";
export interface TableEventHandler {
EVENT:string;
SELECTOR:string;
handleEvent(table:WorkPackageTable, evt:JQueryEventObject):void;
eventScope(table:WorkPackageTable):JQuery;
}
export class TableHandlerRegistry {
static eventHandlers: ((t: WorkPackageTable) => TableEventHandler)[] = [
// Hierarchy expansion/collapsing
t => new HierarchyClickHandler(t),
// Clicking or pressing Enter on a single cell, editable or not
t => new EditCellHandler(t),
// Clicking on the details view
t => new WorkPackageStateLinksHandler(t),
// Clicking on the row (not within a cell)
t => new RowClickHandler(t),
t => new RowDoubleClickHandler(t),
// Clicking on group headers
t => new GroupRowHandler(t),
// Right clicking on rows
t => new ContextMenuRightClickHandler(t),
// Left clicking on the dropdown icon
t => new ContextMenuClickHandler(t),
// SHIFT+ALT+F10 on rows
t => new ContextMenuKeyboardHandler(t),
// Clicking on relations cells
t => new RelationsCellHandler(t)
];
static stateTransformers = [
SelectionTransformer,
RowsTransformer,
ColumnsTransformer,
TimelineTransformer,
HierarchyTransformer,
RelationsTransformer
];
static attachTo(table: WorkPackageTable) {
this.stateTransformers.map((cls) => {
return new cls(table);
});
this.eventHandlers.map(factory => {
let handler = factory(table);
let target = handler.eventScope(table);
target.on(handler.EVENT, handler.SELECTOR, (evt:JQueryEventObject) => {
handler.handleEvent(table, evt);
});
return handler;
});
}
}