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/double-click-handler.ts

62 lines
1.8 KiB

import {debugLog} from '../../../../helpers/debug_output';
8 years ago
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';
export class RowDoubleClickHandler implements TableEventHandler {
// Injections
public $state:ng.ui.IStateService;
public states:States;
public wpTableSelection:WorkPackageTableSelection;
constructor(table: WorkPackageTable) {
8 years ago
injectorBridge(this);
}
public get EVENT() {
return 'dblclick.table.row';
}
public get SELECTOR() {
return `.${rowClassName}`;
}
public eventScope(table:WorkPackageTable) {
return jQuery(table.tbody);
}
8 years ago
public handleEvent(table: WorkPackageTable, evt:JQueryEventObject) {
let target = jQuery(evt.target);
// Shortcut to any clicks within a cell
// We don't want to handle these.
if (target.parents(`.${tdClassName}`).length) {
debugLog('Skipping click on inner cell');
8 years ago
return;
}
// Locate the row from event
let element = target.closest(this.SELECTOR);
let row = table.rowObject(element.data('workPackageId'));
// Ignore links
if (target.is('a') || target.parent().is('a')) {
8 years ago
return;
}
// Save the currently focused work package
this.states.focusedWorkPackage.put(row.workPackageId);
this.$state.go(
'work-packages.show',
{ workPackageId: row.workPackageId }
);
}
}
RowDoubleClickHandler.$inject = ['$state', 'states', 'wpTableSelection'];