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

51 lines
1.4 KiB

import {WorkPackageTable} from '../wp-fast-table';
import {RowClickHandler} from './row/click-handler';
import {EditCellHandler} from './cell/edit-cell-handler';
import {WorkPackageStateLinksHandler} from './row/wp-state-links-handler';
import {SelectionTransformer} from './state/selection-transformer';
import {RowsTransformer} from './state/rows-transformer';
import {ColumnsTransformer} from './state/columns-transformer';
import {GroupRowHandler} from './row/group-row-handler';
export interface TableEventHandler {
EVENT:string;
SELECTOR:string;
handleEvent(table: WorkPackageTable, evt: JQueryEventObject):void;
}
export class TableHandlerRegistry {
static eventHandlers = [
// Clicking or pressing Enter on a single cell, editable or not
EditCellHandler,
// Clicking on the details view
WorkPackageStateLinksHandler,
// Clicking on the row (not within a cell)
RowClickHandler,
GroupRowHandler
];
static stateTransformers = [
SelectionTransformer,
RowsTransformer,
ColumnsTransformer,
];
static attachTo(table: WorkPackageTable) {
let body = jQuery(table.tbody);
this.stateTransformers.map((cls) => {
return new cls(table);
});
this.eventHandlers.map((cls) => {
let handler = <TableEventHandler> new cls();
body.on(handler.EVENT, handler.SELECTOR, (evt:JQueryEventObject) => {
handler.handleEvent(table, evt);
});
return handler;
});
}
}