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/row/group-row-handler.ts

54 lines
1.7 KiB

import {debugLog} from '../../../../helpers/debug_output';
import {injectorBridge} from '../../../angular/angular-injector-bridge.functions';
import {WorkPackageTable} from '../../wp-fast-table';
import {States} from '../../../states.service';
import {TableEventHandler} from '../table-handler-registry';
import {WorkPackageTableSelection} from '../../state/wp-table-selection.service';
import {rowClassName} from '../../builders/rows/single-row-builder';
import {tdClassName} from '../../builders/cell-builder';
import {GroupedRowsBuilder, rowGroupClassName} from '../../builders/rows/grouped-rows-builder';
export class GroupRowHandler implements TableEventHandler {
// Injections
public states:States;
private builder:GroupedRowsBuilder;
constructor() {
injectorBridge(this);
this.builder = new GroupedRowsBuilder();
}
public get EVENT() {
return 'click.table.groupheader';
}
public get SELECTOR() {
return `.${rowGroupClassName} .expander`;
}
public handleEvent(table: WorkPackageTable, evt:JQueryEventObject) {
evt.preventDefault();
evt.stopPropagation();
let groupHeader = jQuery(evt.target).parents(`.${rowGroupClassName}`);
let groupIdentifier = groupHeader.data('groupIdentifier');
let state = this.collapsedState.getCurrentValue() || {};
state[groupIdentifier] = !state[groupIdentifier];
this.collapsedState.put(state);
// Refresh groups
8 years ago
var t0 = performance.now();
this.builder.refreshExpansionState(table);
var t1 = performance.now();
debugLog("Group redraw took " + (t1 - t0) + " milliseconds.");
}
private get collapsedState() {
return this.states.table.collapsedGroups;
}
}
GroupRowHandler.$inject = ['states'];