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.6 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 {GroupedRowsBuilder, rowGroupClassName} from "../../builders/rows/grouped-rows-builder";
export class GroupRowHandler implements TableEventHandler {
// Injections
public states:States;
private builder:GroupedRowsBuilder;
constructor(table: WorkPackageTable) {
injectorBridge(this);
this.builder = new GroupedRowsBuilder(table);
}
public get EVENT() {
return 'click.table.groupheader';
}
public get SELECTOR() {
return `.${rowGroupClassName} .expander`;
}
public eventScope(table:WorkPackageTable) {
return jQuery(table.tbody);
}
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
var t0 = performance.now();
this.builder.refreshExpansionState();
var t1 = performance.now();
debugLog("Group redraw took " + (t1 - t0) + " milliseconds.");
}
private get collapsedState() {
return this.states.table.collapsedGroups;
}
}
GroupRowHandler.$inject = ['states'];