Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Refactor table events as output of the table component

Oliver Günther0a4e473856cd
diff --git a/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts b/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts
index 5c0171e6d89..25f2e9327f1 100644
--- a/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts
+++ b/frontend/src/app/components/wp-card-view/event-handler/click-handler.ts
@@ -49,29 +49,19 @@ export class CardClickHandler implements CardEventHandler {
return true;
}
- this.handleWorkPackage(wpId, element, evt);
+ this.handleWorkPackage(card, wpId, element, evt);
return false;
}
- protected handleWorkPackage(wpId:any, element:JQuery, evt:JQuery.TriggeredEvent) {
- this.setSelection(wpId, element, evt);
+ protected handleWorkPackage(card:WorkPackageCardViewComponent, wpId:any, element:JQuery, evt:JQuery.TriggeredEvent) {
+ this.setSelection(card, wpId, element, evt);
- // open work package on mobile after first click
- this.openFullViewOnMobile(wpId);
+ card.itemClicked.emit({ workPackageId: wpId, double: false });
}
- protected openFullViewOnMobile(wpId:string) {
- if (this.deviceService.isMobile) {
- this.$state.go(
- 'work-packages.show',
- {workPackageId: wpId}
- );
- }
- }
-
- protected setSelection(wpId:string, element:JQuery, evt:JQuery.TriggeredEvent) {
+ protected setSelection(card:WorkPackageCardViewComponent, wpId:string, element:JQuery, evt:JQuery.TriggeredEvent) {
let classIdentifier = element.data('classIdentifier');
let index = this.wpCardView.findRenderedCard(classIdentifier);
@@ -90,6 +80,8 @@ export class CardClickHandler implements CardEventHandler {
this.wpTableSelection.toggleRow(wpId);
}
+ card.selectionChanged.emit(this.wpTableSelection.getSelectedWorkPackageIds());
+
// The current card is the last selected work package
// not matter what other card are (de-)selected below.
// Thus save that card for the details view button.
diff --git a/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts b/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts
index f1490da44d6..0f9845d372e 100644
--- a/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts
+++ b/frontend/src/app/components/wp-card-view/event-handler/double-click-handler.ts
@@ -41,16 +41,8 @@ export class CardDblClickHandler implements CardEventHandler {
return true;
}
- this.handleWorkPackage(wpId);
-
+ card.itemClicked.emit({ workPackageId: wpId, double: true });
return false;
}
-
- protected handleWorkPackage(wpId:string) {
- this.$state.go(
- 'work-packages.show',
- {workPackageId: wpId}
- );
- }
}
diff --git a/frontend/src/app/components/wp-card-view/wp-card-view.component.ts b/frontend/src/app/components/wp-card-view/wp-card-view.component.ts
index fd96371fe0f..fd77e70102d 100644
--- a/frontend/src/app/components/wp-card-view/wp-card-view.component.ts
+++ b/frontend/src/app/components/wp-card-view/wp-card-view.component.ts
@@ -33,7 +33,10 @@ import {WorkPackageCardViewService} from "core-components/wp-card-view/services/
import {WorkPackageCardDragAndDropService} from "core-components/wp-card-view/services/wp-card-drag-and-drop.service";
import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";
import {DeviceService} from "core-app/modules/common/browser/device.service";
-import {WorkPackageViewHandlerToken} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
+import {
+ WorkPackageViewHandlerToken,
+ WorkPackageViewOutputs
+} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
import {componentDestroyed} from "@w11k/ngx-componentdestroyed";
import {HalEventsService} from "core-app/modules/hal/services/hal-events.service";
@@ -46,7 +49,7 @@ export type CardViewOrientation = 'horizontal'|'vertical';
templateUrl: './wp-card-view.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class WorkPackageCardViewComponent extends UntilDestroyedMixin implements OnInit, AfterViewInit {
+export class WorkPackageCardViewComponent extends UntilDestroyedMixin implements OnInit, AfterViewInit, WorkPackageViewOutputs {
@Input('dragOutOfHandler') public canDragOutOf:(wp:WorkPackageResource) => boolean;
@Input() public dragInto:boolean;
@Input() public highlightingMode:CardHighlightingMode;
@@ -65,6 +68,9 @@ export class WorkPackageCardViewComponent extends UntilDestroyedMixin implements
@ViewChild('container', { static: true }) public container:ElementRef;
@Output() public onMoved = new EventEmitter<void>();
+ @Output() selectionChanged = new EventEmitter<string[]>();
+ @Output() itemClicked = new EventEmitter<{ workPackageId:string, double:boolean }>();
+ @Output() stateLinkClicked = new EventEmitter<{ workPackageId:string, requestedState:string }>();
public trackByHref = AngularTrackingHelpers.trackByHrefAndProperty('lockVersion');
public query:QueryResource;
diff --git a/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts b/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts
index ab79903a7e8..93b0df60325 100644
--- a/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts
+++ b/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts
@@ -4,6 +4,9 @@ import {StateService} from '@uirouter/core';
export const uiStateLinkClass = '__ui-state-link';
export const checkedClassName = '-checked';
+export const currentDetailsState = 'currentDetailsState';
+export const currentShowState = 'currentShowState';
+
export class UiStateLinkBuilder {
constructor(public readonly $state:StateService,
@@ -11,11 +14,11 @@ export class UiStateLinkBuilder {
}
public linkToDetails(workPackageId:string, title:string, content:string) {
- return this.build(workPackageId, 'currentDetailsState', title, content);
+ return this.build(workPackageId, currentDetailsState, title, content);
}
public linkToShow(workPackageId:string, title:string, content:string) {
- return this.build(workPackageId, 'currentShowState', title, content);
+ return this.build(workPackageId, currentShowState, title, content);
}
private build(workPackageId:string, state:string, title:string, content:string) {
diff --git a/frontend/src/app/components/wp-fast-table/handlers/cell/edit-cell-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/cell/edit-cell-handler.ts
index a1668153375..16f9133173e 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/cell/edit-cell-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/cell/edit-cell-handler.ts
@@ -7,7 +7,7 @@ import {HalResourceEditingService} from "core-app/modules/fields/edit/services/h
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {WorkPackageTable} from '../../wp-fast-table';
import {ClickOrEnterHandler} from '../click-or-enter-handler';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {ClickPositionMapper} from "core-app/modules/common/set-click-position/set-click-position";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@@ -27,11 +27,11 @@ export class EditCellHandler extends ClickOrEnterHandler implements TableEventHa
return `.${displayClassName}.${editableClassName}`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tableAndTimelineContainer);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tableAndTimelineContainer);
}
- constructor(public readonly injector:Injector, table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
super();
}
diff --git a/frontend/src/app/components/wp-fast-table/handlers/cell/relations-cell-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/cell/relations-cell-handler.ts
index 4f41ab0993d..3ffd1294eb2 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/cell/relations-cell-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/cell/relations-cell-handler.ts
@@ -4,7 +4,7 @@ import {relationCellIndicatorClassName, relationCellTdClassName} from '../../bui
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {WorkPackageTable} from '../../wp-fast-table';
import {ClickOrEnterHandler} from '../click-or-enter-handler';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {WorkPackageViewRelationColumnsService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-relation-columns.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@@ -21,12 +21,11 @@ export class RelationsCellHandler extends ClickOrEnterHandler implements TableEv
return `.${relationCellIndicatorClassName}`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tableAndTimelineContainer);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tableAndTimelineContainer);
}
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
super();
}
diff --git a/frontend/src/app/components/wp-fast-table/handlers/click-or-enter-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/click-or-enter-handler.ts
index c1fe53b5853..f0c9f2008ac 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/click-or-enter-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/click-or-enter-handler.ts
@@ -1,5 +1,6 @@
import {keyCodes} from 'core-app/modules/common/keyCodes.enum';
import {WorkPackageTable} from "../wp-fast-table";
+import {TableEventComponent} from "core-components/wp-fast-table/handlers/table-handler-registry";
/**
@@ -16,8 +17,8 @@ export function onClickOrEnter(evt:JQuery.TriggeredEvent, callback:() => void) {
export abstract class ClickOrEnterHandler {
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent) {
- onClickOrEnter(evt, () => this.processEvent(table, evt));
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent) {
+ onClickOrEnter(evt, () => this.processEvent(view.workPackageTable, evt));
}
protected abstract processEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent):boolean;
diff --git a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-click-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-click-handler.ts
index b240cebafb5..1f106fa272c 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-click-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-click-handler.ts
@@ -4,12 +4,12 @@ import {uiStateLinkClass} from '../../builders/ui-state-link-builder';
import {WorkPackageTable} from '../../wp-fast-table';
import {ContextMenuHandler} from './context-menu-handler';
import {contextMenuLinkClassName} from "core-components/wp-table/table-actions/table-action";
+import {TableEventComponent} from "core-components/wp-fast-table/handlers/table-handler-registry";
export class ContextMenuClickHandler extends ContextMenuHandler {
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
- super(injector, table);
+ constructor(public readonly injector:Injector) {
+ super(injector);
}
public get EVENT() {
@@ -20,7 +20,7 @@ export class ContextMenuClickHandler extends ContextMenuHandler {
return `.${contextMenuLinkClassName}`;
}
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent):boolean {
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent):boolean {
let target = jQuery(evt.target);
// We want to keep the original context menu on hrefs
@@ -38,7 +38,7 @@ export class ContextMenuClickHandler extends ContextMenuHandler {
const wpId = element.data('workPackageId');
if (wpId) {
- super.openContextMenu(evt, wpId);
+ this.openContextMenu(view.workPackageTable, evt, wpId);
}
return false;
diff --git a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-handler.ts
index 56014f9899c..e5c3df18aa3 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-handler.ts
@@ -1,7 +1,7 @@
import {Injector} from '@angular/core';
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {WorkPackageTable} from '../../wp-fast-table';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {OPContextMenuService} from "core-components/op-context-menu/op-context-menu.service";
import {WorkPackageTableContextMenu} from "core-components/op-context-menu/wp-context-menu/wp-table-context-menu.directive";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@@ -10,8 +10,7 @@ export abstract class ContextMenuHandler implements TableEventHandler {
// Injections
@InjectField() public opContextMenu:OPContextMenuService;
- constructor(public readonly injector:Injector,
- protected table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
}
public get rowSelector() {
@@ -22,14 +21,14 @@ export abstract class ContextMenuHandler implements TableEventHandler {
public abstract get SELECTOR():string;
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tableAndTimelineContainer);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tableAndTimelineContainer);
}
- public abstract handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent):boolean;
+ public abstract handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent):boolean;
- protected openContextMenu(evt:JQuery.TriggeredEvent, workPackageId:string, positionArgs?:any):void {
- const handler = new WorkPackageTableContextMenu(this.injector, workPackageId, jQuery(evt.target) as JQuery, positionArgs, this.table);
+ protected openContextMenu(table:WorkPackageTable, evt:JQuery.TriggeredEvent, workPackageId:string, positionArgs?:any):void {
+ const handler = new WorkPackageTableContextMenu(this.injector, workPackageId, jQuery(evt.target) as JQuery, positionArgs, table);
this.opContextMenu.show(handler, evt);
}
}
diff --git a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-keyboard-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-keyboard-handler.ts
index 17ca20cf299..38502271db0 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-keyboard-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-keyboard-handler.ts
@@ -2,12 +2,12 @@ import {Injector} from '@angular/core';
import {keyCodes} from 'core-app/modules/common/keyCodes.enum';
import {WorkPackageTable} from '../../wp-fast-table';
import {ContextMenuHandler} from './context-menu-handler';
+import {TableEventComponent} from "core-components/wp-fast-table/handlers/table-handler-registry";
export class ContextMenuKeyboardHandler extends ContextMenuHandler {
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
- super(injector, table);
+ constructor(public readonly injector:Injector) {
+ super(injector);
}
public get EVENT() {
@@ -18,8 +18,8 @@ export class ContextMenuKeyboardHandler extends ContextMenuHandler {
return this.rowSelector;
}
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent):boolean {
- if (!table.configuration.contextMenuEnabled) {
+ public handleEvent(component:TableEventComponent, evt:JQuery.TriggeredEvent):boolean {
+ if (!component.workPackageTable.configuration.contextMenuEnabled) {
return false;
}
@@ -39,7 +39,7 @@ export class ContextMenuKeyboardHandler extends ContextMenuHandler {
// Set position args to open at element
let position = { my: 'left top', at: 'left bottom', of: target };
- super.openContextMenu(evt, wpId, position);
+ super.openContextMenu(component.workPackageTable, evt, wpId, position);
return false;
}
diff --git a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-rightclick-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-rightclick-handler.ts
index 85511126537..4a6323b4661 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-rightclick-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/context-menu/context-menu-rightclick-handler.ts
@@ -7,15 +7,14 @@ import {WorkPackageTable} from '../../wp-fast-table';
import {ContextMenuHandler} from './context-menu-handler';
import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-selection.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
+import {TableEventComponent} from "core-components/wp-fast-table/handlers/table-handler-registry";
export class ContextMenuRightClickHandler extends ContextMenuHandler {
@InjectField() readonly wpTableSelection:WorkPackageViewSelectionService;
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
-
- super(injector, table);
+ constructor(public readonly injector:Injector) {
+ super(injector);
}
public get EVENT() {
@@ -26,12 +25,12 @@ export class ContextMenuRightClickHandler extends ContextMenuHandler {
return `.${tableRowClassName},.${timelineCellClassName}`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tableAndTimelineContainer);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tableAndTimelineContainer);
}
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent):boolean {
- if (!table.configuration.contextMenuEnabled) {
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent):boolean {
+ if (!view.workPackageTable.configuration.contextMenuEnabled) {
return false;
}
let target = jQuery(evt.target);
@@ -51,13 +50,13 @@ export class ContextMenuRightClickHandler extends ContextMenuHandler {
const wpId = element.data('workPackageId');
if (wpId) {
- let [index,] = this.table.findRenderedRow(wpId);
+ let [index,] = view.workPackageTable.findRenderedRow(wpId);
if (!this.wpTableSelection.isSelected(wpId)) {
this.wpTableSelection.setSelection(wpId, index);
}
- super.openContextMenu(evt, wpId);
+ this.openContextMenu(view.workPackageTable, evt, wpId);
}
return false;
diff --git a/frontend/src/app/components/wp-fast-table/handlers/row/click-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/row/click-handler.ts
index a87f82a275f..b88e93a1551 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/row/click-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/row/click-handler.ts
@@ -6,7 +6,7 @@ import {States} from '../../../states.service';
import {KeepTabService} from '../../../wp-single-view-tabs/keep-tab/keep-tab.service';
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {WorkPackageTable} from '../../wp-fast-table';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-selection.service";
import {displayClassName} from "core-components/wp-edit-form/display-field-renderer";
import {activeFieldClassName} from "core-app/modules/fields/edit/edit-form/edit-form";
@@ -21,8 +21,7 @@ export class RowClickHandler implements TableEventHandler {
@InjectField() public wpTableSelection:WorkPackageViewSelectionService;
@InjectField() public wpTableFocus:WorkPackageViewFocusService;
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
}
public get EVENT() {
@@ -33,11 +32,11 @@ export class RowClickHandler implements TableEventHandler {
return `.${tableRowClassName}`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tbody);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tbody);
}
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent) {
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent) {
let target = jQuery(evt.target);
// Ignore links
@@ -61,16 +60,17 @@ export class RowClickHandler implements TableEventHandler {
return true;
}
- let [index, row] = table.findRenderedRow(classIdentifier);
+ let [index, row] = view.workPackageTable.findRenderedRow(classIdentifier);
// Update single selection if no modifier present
if (!(evt.ctrlKey || evt.metaKey || evt.shiftKey)) {
this.wpTableSelection.setSelection(wpId, index);
+ view.itemClicked.emit({ workPackageId: wpId, double: false });
}
// Multiple selection if shift present
if (evt.shiftKey) {
- this.wpTableSelection.setMultiSelectionFrom(table.renderedRows, wpId, index);
+ this.wpTableSelection.setMultiSelectionFrom(view.workPackageTable.renderedRows, wpId, index);
}
// Single selection expansion if ctrl / cmd(mac)
@@ -78,6 +78,8 @@ export class RowClickHandler implements TableEventHandler {
this.wpTableSelection.toggleRow(wpId);
}
+ view.selectionChanged.emit(this.wpTableSelection.getSelectedWorkPackageIds());
+
// The current row is the last selected work package
// not matter what other rows are (de-)selected below.
// Thus save that row for the details view button.
diff --git a/frontend/src/app/components/wp-fast-table/handlers/row/double-click-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/row/double-click-handler.ts
index 79ede1e52e8..83fc84137a2 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/row/double-click-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/row/double-click-handler.ts
@@ -6,7 +6,7 @@ import {States} from '../../../states.service';
import {tdClassName} from '../../builders/cell-builder';
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {WorkPackageTable} from '../../wp-fast-table';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {LinkHandling} from "core-app/modules/common/link-handling/link-handling";
import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-selection.service";
import {displayClassName} from "core-components/wp-edit-form/display-field-renderer";
@@ -21,8 +21,7 @@ export class RowDoubleClickHandler implements TableEventHandler {
@InjectField() public wpTableSelection:WorkPackageViewSelectionService;
@InjectField() public wpTableFocus:WorkPackageViewFocusService;
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
}
public get EVENT() {
@@ -33,11 +32,11 @@ export class RowDoubleClickHandler implements TableEventHandler {
return `.${tdClassName}`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tbody);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tbody);
}
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent) {
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent) {
let target = jQuery(evt.target);
// Skip clicks with modifiers
@@ -64,10 +63,7 @@ export class RowDoubleClickHandler implements TableEventHandler {
// Save the currently focused work package
this.wpTableFocus.updateFocus(wpId);
- this.$state.go(
- 'work-packages.show',
- {workPackageId: wpId}
- );
+ view.itemClicked.emit({ workPackageId: wpId, double: true });
return false;
}
diff --git a/frontend/src/app/components/wp-fast-table/handlers/row/group-row-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/row/group-row-handler.ts
index 1056429f456..f396bf8c97b 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/row/group-row-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/row/group-row-handler.ts
@@ -2,7 +2,7 @@ import {Injector} from '@angular/core';
import {debugLog} from '../../../../helpers/debug_output';
import {GroupedRowsBuilder} from '../../builders/modes/grouped/grouped-rows-builder';
import {WorkPackageTable} from '../../wp-fast-table';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";
import {rowGroupClassName} from "core-components/wp-fast-table/builders/modes/grouped/grouped-classes.constants";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@@ -12,10 +12,7 @@ export class GroupRowHandler implements TableEventHandler {
// Injections
@InjectField() public querySpace:IsolatedQuerySpace;
- private builder:GroupedRowsBuilder;
-
- constructor(public readonly injector:Injector, table:WorkPackageTable) {
- this.builder = new GroupedRowsBuilder(injector, table);
+ constructor(public readonly injector:Injector) {
}
public get EVENT() {
@@ -26,11 +23,11 @@ export class GroupRowHandler implements TableEventHandler {
return `.${rowGroupClassName} .expander`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tbody);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tbody);
}
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent) {
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent) {
evt.preventDefault();
evt.stopPropagation();
@@ -42,9 +39,10 @@ export class GroupRowHandler implements TableEventHandler {
this.collapsedState.putValue(state);
// Refresh groups
- var t0 = performance.now();
- this.builder.refreshExpansionState();
- var t1 = performance.now();
+ const builder = new GroupedRowsBuilder(this.injector, view.workPackageTable);
+ const t0 = performance.now();
+ builder.refreshExpansionState();
+ const t1 = performance.now();
debugLog('Group redraw took ' + (t1 - t0) + ' milliseconds.');
}
diff --git a/frontend/src/app/components/wp-fast-table/handlers/row/hierarchy-click-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/row/hierarchy-click-handler.ts
index 417b52a256a..d1601cc8e56 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/row/hierarchy-click-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/row/hierarchy-click-handler.ts
@@ -3,7 +3,7 @@ import {States} from '../../../states.service';
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {WorkPackageTable} from '../../wp-fast-table';
import {ClickOrEnterHandler} from '../click-or-enter-handler';
-import {TableEventHandler} from "core-components/wp-fast-table/handlers/table-handler-registry";
+import {TableEventComponent, TableEventHandler} from "core-components/wp-fast-table/handlers/table-handler-registry";
import {WorkPackageViewHierarchiesService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@@ -12,7 +12,7 @@ export class HierarchyClickHandler extends ClickOrEnterHandler implements TableE
@InjectField() public states:States;
@InjectField() public wpTableHierarchies:WorkPackageViewHierarchiesService;
- constructor(public readonly injector:Injector, table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
super();
}
@@ -24,8 +24,8 @@ export class HierarchyClickHandler extends ClickOrEnterHandler implements TableE
return `.wp-table--hierarchy-indicator`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tbody);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tbody);
}
public processEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent):boolean {
diff --git a/frontend/src/app/components/wp-fast-table/handlers/row/wp-state-links-handler.ts b/frontend/src/app/components/wp-fast-table/handlers/row/wp-state-links-handler.ts
index f87f0b2a5a3..f9903dbfcc0 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/row/wp-state-links-handler.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/row/wp-state-links-handler.ts
@@ -6,7 +6,7 @@ import {KeepTabService} from '../../../wp-single-view-tabs/keep-tab/keep-tab.ser
import {tableRowClassName} from '../../builders/rows/single-row-builder';
import {uiStateLinkClass} from '../../builders/ui-state-link-builder';
import {WorkPackageTable} from '../../wp-fast-table';
-import {TableEventHandler} from '../table-handler-registry';
+import {TableEventComponent, TableEventHandler} from '../table-handler-registry';
import {StateService} from '@uirouter/core';
import {WorkPackageViewSelectionService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-selection.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
@@ -20,8 +20,7 @@ export class WorkPackageStateLinksHandler implements TableEventHandler {
@InjectField() public wpTableSelection:WorkPackageViewSelectionService;
@InjectField() public wpTableFocus:WorkPackageViewFocusService;
- constructor(public readonly injector:Injector,
- table:WorkPackageTable) {
+ constructor(public readonly injector:Injector) {
}
public get EVENT() {
@@ -32,13 +31,13 @@ export class WorkPackageStateLinksHandler implements TableEventHandler {
return `.${uiStateLinkClass}`;
}
- public eventScope(table:WorkPackageTable) {
- return jQuery(table.tableAndTimelineContainer);
+ public eventScope(view:TableEventComponent) {
+ return jQuery(view.workPackageTable.tableAndTimelineContainer);
}
protected workPackage:WorkPackageResource;
- public handleEvent(table:WorkPackageTable, evt:JQuery.TriggeredEvent) {
+ public handleEvent(view:TableEventComponent, evt:JQuery.TriggeredEvent) {
// Avoid the state capture when clicking with modifier
if (evt.shiftKey || evt.ctrlKey || evt.metaKey || evt.altKey) {
return true;
@@ -59,15 +58,12 @@ export class WorkPackageStateLinksHandler implements TableEventHandler {
// Locate the row from event
let row = target.closest(`.${tableRowClassName}`);
let classIdentifier = row.data('classIdentifier');
- let [index, _] = table.findRenderedRow(classIdentifier);
+ let [index, _] = view.workPackageTable.findRenderedRow(classIdentifier);
// Update single selection if no modifier present
this.wpTableSelection.setSelection(workPackageId, index);
- this.$state.go(
- (this.keepTab as any)[state],
- {workPackageId: workPackageId, focus: true}
- );
+ view.stateLinkClicked.emit({ workPackageId: workPackageId, requestedState: state });
evt.preventDefault();
evt.stopPropagation();
diff --git a/frontend/src/app/components/wp-fast-table/handlers/table-handler-registry.ts b/frontend/src/app/components/wp-fast-table/handlers/table-handler-registry.ts
index 3d44106d1cf..3ac5136a45b 100644
--- a/frontend/src/app/components/wp-fast-table/handlers/table-handler-registry.ts
+++ b/frontend/src/app/components/wp-fast-table/handlers/table-handler-registry.ts
@@ -1,4 +1,4 @@
-import {Injector} from '@angular/core';
+import {EventEmitter, Injector} from '@angular/core';
import {WorkPackageTable} from '../wp-fast-table';
import {EditCellHandler} from './cell/edit-cell-handler';
import {RelationsCellHandler} from './cell/relations-cell-handler';
@@ -19,40 +19,46 @@ import {TimelineTransformer} from './state/timeline-transformer';
import {HighlightingTransformer} from "core-components/wp-fast-table/handlers/state/highlighting-transformer";
import {DragAndDropTransformer} from "core-components/wp-fast-table/handlers/state/drag-and-drop-transformer";
import {
- WorkPackageViewEventHandler,
+ WorkPackageViewEventHandler, WorkPackageViewOutputs,
WorkPackageViewHandlerRegistry
} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
+import {WorkPackageFocusContext} from "core-components/wp-table/wp-table.component";
type StateTransformers = {
// noinspection JSUnusedLocalSymbols
new(injector:Injector, table:WorkPackageTable):any;
};
-export type TableEventHandler = WorkPackageViewEventHandler<WorkPackageTable>;
+export interface TableEventComponent extends WorkPackageViewOutputs {
+ // Reference to the fast table instance
+ workPackageTable:WorkPackageTable;
+}
+
+export type TableEventHandler = WorkPackageViewEventHandler<TableEventComponent>;
-export class TableHandlerRegistry extends WorkPackageViewHandlerRegistry<WorkPackageTable> {
+export class TableHandlerRegistry extends WorkPackageViewHandlerRegistry<TableEventComponent> {
- protected eventHandlers:((t:WorkPackageTable) => WorkPackageViewEventHandler<WorkPackageTable>)[] = [
+ protected eventHandlers:((t:TableEventComponent) => TableEventHandler)[] = [
// Hierarchy expansion/collapsing
- t => new HierarchyClickHandler(this.injector, t),
+ () => new HierarchyClickHandler(this.injector),
// Clicking or pressing Enter on a single cell, editable or not
- t => new EditCellHandler(this.injector, t),
+ () => new EditCellHandler(this.injector),
// Clicking on the details view
- t => new WorkPackageStateLinksHandler(this.injector, t),
+ () => new WorkPackageStateLinksHandler(this.injector),
// Clicking on the row (not within a cell)
- t => new RowClickHandler(this.injector, t),
+ () => new RowClickHandler(this.injector),
// Double Clicking on the cell within the row
- t => new RowDoubleClickHandler(this.injector, t),
+ () => new RowDoubleClickHandler(this.injector),
// Clicking on group headers
- t => new GroupRowHandler(this.injector, t),
+ () => new GroupRowHandler(this.injector),
// Right clicking on rows
- t => new ContextMenuRightClickHandler(this.injector, t),
+ () => new ContextMenuRightClickHandler(this.injector),
// Left clicking on the dropdown icon
- t => new ContextMenuClickHandler(this.injector, t),
+ () => new ContextMenuClickHandler(this.injector),
// SHIFT+ALT+F10 on rows
- t => new ContextMenuKeyboardHandler(this.injector, t),
+ () => new ContextMenuKeyboardHandler(this.injector),
// Clicking on relations cells
- t => new RelationsCellHandler(this.injector, t)
+ () => new RelationsCellHandler(this.injector)
];
protected readonly stateTransformers:StateTransformers[] = [
@@ -66,9 +72,9 @@ export class TableHandlerRegistry extends WorkPackageViewHandlerRegistry<WorkPac
DragAndDropTransformer
];
- attachTo(viewRef:WorkPackageTable) {
+ attachTo(viewRef:TableEventComponent) {
this.stateTransformers.map((cls) => {
- return new cls(this.injector, viewRef);
+ return new cls(this.injector, viewRef.workPackageTable);
});
super.attachTo(viewRef);
diff --git a/frontend/src/app/components/wp-grid/wp-grid.component.ts b/frontend/src/app/components/wp-grid/wp-grid.component.ts
index a7ddd8b2720..86434fb94d5 100644
--- a/frontend/src/app/components/wp-grid/wp-grid.component.ts
+++ b/frontend/src/app/components/wp-grid/wp-grid.component.ts
@@ -26,7 +26,7 @@
// See docs/COPYRIGHT.rdoc for more details.
// ++
-import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input} from "@angular/core";
+import {ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output} from "@angular/core";
import {WorkPackageViewHighlightingService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-highlighting.service";
import {CardViewOrientation} from "core-components/wp-card-view/wp-card-view.component";
import {WorkPackageViewSortByService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-sort-by.service";
@@ -37,6 +37,7 @@ import {DragAndDropService} from "core-app/modules/common/drag-and-drop/drag-and
import {WorkPackageCardDragAndDropService} from "core-components/wp-card-view/services/wp-card-drag-and-drop.service";
import {WorkPackagesListService} from "core-components/wp-list/wp-list.service";
import {WorkPackageTableConfiguration} from "core-components/wp-table/wp-table-configuration";
+import {WorkPackageViewOutputs} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
@Component({
selector: 'wp-grid',
@@ -48,6 +49,9 @@ import {WorkPackageTableConfiguration} from "core-components/wp-table/wp-table-c
[showStatusButton]="true"
[orientation]="gridOrientation"
(onMoved)="switchToManualSorting()"
+ (selectionChanged)="selectionChanged.emit($event)"
+ (itemClicked)="itemClicked.emit($event)"
+ (stateLinkClicked)="stateLinkClicked.emit($event)"
[showEmptyResultsBox]="true"
[showInfoButton]="true"
[shrinkOnMobile]="true">
@@ -65,12 +69,16 @@ import {WorkPackageTableConfiguration} from "core-components/wp-table/wp-table-c
WorkPackageCardDragAndDropService
]
})
-export class WorkPackagesGridComponent {
+export class WorkPackagesGridComponent implements WorkPackageViewOutputs {
@Input() public configuration:WorkPackageTableConfiguration;
@Input() public showResizer:boolean = false;
@Input() public resizerClass:string = '';
@Input() public resizerStorageKey:string = '';
+ @Output() selectionChanged = new EventEmitter<string[]>();
+ @Output() itemClicked = new EventEmitter<{ workPackageId:string, double:boolean }>();
+ @Output() stateLinkClicked = new EventEmitter<{ workPackageId:string, requestedState:string }>();
+
public canDragOutOf:() => boolean;
public dragInto:boolean;
public gridOrientation:CardViewOrientation = 'horizontal';
diff --git a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
index cb29e5e8799..65fc3348efb 100644
--- a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
+++ b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
@@ -12,6 +12,7 @@ import {QueryFormResource} from "core-app/modules/hal/resources/query-form-resou
import {QueryFormDmService} from "core-app/modules/hal/dm-services/query-form-dm.service";
import {distinctUntilChanged, map, take, withLatestFrom} from "rxjs/operators";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
+import {KeepTabService} from "core-components/wp-single-view-tabs/keep-tab/keep-tab.service";
@Component({
selector: 'wp-embedded-table',
@@ -35,6 +36,7 @@ export class WorkPackageEmbeddedTableComponent extends WorkPackageEmbeddedBaseCo
@InjectField() wpTableTimeline:WorkPackageViewTimelineService;
@InjectField() wpTablePagination:WorkPackageViewPaginationService;
@InjectField() QueryFormDm:QueryFormDmService;
+ @InjectField() keepTab:KeepTabService;
// Cache the form promise
private formPromise:Promise<QueryFormResource>|undefined;
@@ -168,4 +170,20 @@ export class WorkPackageEmbeddedTableComponent extends WorkPackageEmbeddedBaseCo
return promise;
}
+
+ handleWorkPackageClicked(event:{ workPackageId:string; double:boolean }) {
+ if (event.double) {
+ this.$state.go(
+ 'work-packages.show',
+ { workPackageId: event.workPackageId }
+ );
+ }
+ }
+
+ openStateLink(event:{ workPackageId:string; requestedState:string }) {
+ this.$state.go(
+ (this.keepTab as any)[event.requestedState] || event.requestedState,
+ { workPackageId: event.workPackageId, focus: true }
+ );
+ }
}
diff --git a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html
index 60ebf266463..546f0ad512f 100644
--- a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html
+++ b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.html
@@ -17,11 +17,15 @@
<wp-table *ngIf="!configuration.isCardView"
[projectIdentifier]="projectIdentifier"
[configuration]="configuration"
+ (itemClicked)="handleWorkPackageClicked($event)"
+ (stateLinkClicked)="openStateLink($event)"
class="work-packages-split-view--tabletimeline-content"></wp-table>
<!-- GRID representation of the WP -->
<div class="work-packages-embedded-view--grid-view" >
<wp-grid *ngIf="configuration.isCardView"
+ (itemClicked)="handleWorkPackageClicked($event)"
+ (stateLinkClicked)="openStateLink($event)"
[configuration]="configuration">
</wp-grid>
</div>
diff --git a/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts
index 547d0f2c7a3..75be05b6ed6 100644
--- a/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts
+++ b/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts
@@ -48,7 +48,6 @@ import {input, InputState} from "reactivestates";
import {WorkPackageTable} from "core-components/wp-fast-table/wp-fast-table";
import {WorkPackageTimelineCellsRenderer} from "core-components/wp-table/timeline/cells/wp-timeline-cells-renderer";
import {States} from "core-components/states.service";
-import {WorkPackagesTableController} from "core-components/wp-table/wp-table.directive";
import {WorkPackageViewTimelineService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-timeline.service";
import {WorkPackageRelationsService} from "core-components/wp-relations/wp-relations.service";
import {WorkPackageViewHierarchiesService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy.service";
@@ -60,6 +59,7 @@ import {HalEventsService} from "core-app/modules/hal/services/hal-events.service
import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";
import {combineLatest} from "rxjs";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
+import {WorkPackagesTableComponent} from "core-components/wp-table/wp-table.component";
@Component({
selector: 'wp-timeline-container',
@@ -95,7 +95,7 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl
constructor(public readonly injector:Injector,
private elementRef:ElementRef,
private states:States,
- public wpTableDirective:WorkPackagesTableController,
+ public wpTableComponent:WorkPackagesTableComponent,
private NotificationsService:NotificationsService,
private wpTableTimeline:WorkPackageViewTimelineService,
private notificationService:WorkPackageNotificationService,
@@ -119,7 +119,7 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl
this.timelineBody = this.$element.find('.wp-table-timeline--body');
// Register this instance to the table
- this.wpTableDirective.registerTimeline(this, this.timelineBody[0]);
+ this.wpTableComponent.registerTimeline(this, this.timelineBody[0]);
// Refresh on window resize events
window.addEventListener('wp-resize.timeline', () => this.refreshRequest.putValue(undefined));
@@ -408,7 +408,7 @@ export class WorkPackageTimelineTableController extends UntilDestroyedMixin impl
// did the zoom level changed?
if (previousZoomLevel !== zoomLevel) {
this._viewParameters.settings.zoomLevel = zoomLevel;
- this.wpTableDirective.timeline.scrollLeft = 0;
+ this.wpTableComponent.timeline.scrollLeft = 0;
}
this.wpTableTimeline.appliedZoomLevel = zoomLevel;
diff --git a/frontend/src/app/components/wp-table/wp-table.directive.ts b/frontend/src/app/components/wp-table/wp-table.component.ts
similarity index 91%
rename from frontend/src/app/components/wp-table/wp-table.directive.ts
rename to frontend/src/app/components/wp-table/wp-table.component.ts
index e9b4de5ef44..70885a6e574 100644
--- a/frontend/src/app/components/wp-table/wp-table.directive.ts
+++ b/frontend/src/app/components/wp-table/wp-table.component.ts
@@ -30,17 +30,17 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
- ElementRef,
+ ElementRef, EventEmitter,
Injector,
Input,
NgZone,
- OnInit,
+ OnInit, Output,
ViewEncapsulation
} from '@angular/core';
import {QueryGroupByResource} from 'core-app/modules/hal/resources/query-group-by-resource';
import {QueryResource} from 'core-app/modules/hal/resources/query-resource';
import {I18nService} from 'core-app/modules/common/i18n/i18n.service';
-import {TableHandlerRegistry} from 'core-components/wp-fast-table/handlers/table-handler-registry';
+import {TableEventComponent, TableHandlerRegistry} from 'core-components/wp-fast-table/handlers/table-handler-registry';
import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";
import {combineLatest} from 'rxjs';
import {States} from '../states.service';
@@ -61,6 +61,13 @@ import {WorkPackageTable} from "core-components/wp-fast-table/wp-fast-table";
import {WorkPackageViewTimelineService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-timeline.service";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
+export interface WorkPackageFocusContext {
+ /** Work package that was focused */
+ workPackageId:string;
+ /** Through what action did the focus happen */
+ through:'row-double-click'|'id-click'|'details-icon';
+}
+
@Component({
templateUrl: './wp-table.directive.html',
styleUrls: ['./wp-table.styles.sass'],
@@ -68,11 +75,15 @@ import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixi
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'wp-table',
})
-export class WorkPackagesTableController extends UntilDestroyedMixin implements OnInit {
+export class WorkPackagesTableComponent extends UntilDestroyedMixin implements OnInit, TableEventComponent {
@Input() projectIdentifier:string;
@Input('configuration') configurationObject:WorkPackageTableConfigurationObject;
+ @Output() selectionChanged = new EventEmitter<string[]>();
+ @Output() itemClicked = new EventEmitter<{ workPackageId:string, double:boolean }>();
+ @Output() stateLinkClicked = new EventEmitter<{ workPackageId:string, requestedState:string }>();
+
public trackByHref = AngularTrackingHelpers.trackByHref;
public configuration:WorkPackageTableConfiguration;
@@ -210,7 +221,7 @@ export class WorkPackagesTableController extends UntilDestroyedMixin implements
);
this.tbody = tbody;
controller.workPackageTable = this.workPackageTable;
- new TableHandlerRegistry(this.injector).attachTo(this.workPackageTable);
+ new TableHandlerRegistry(this.injector).attachTo(this);
// Locate table and timeline elements
const tableAndTimeline = this.getTableAndTimelineElement();
diff --git a/frontend/src/app/modules/bim/ifc_models/bcf/list-container/bcf-list-container.component.ts b/frontend/src/app/modules/bim/ifc_models/bcf/list-container/bcf-list-container.component.ts
index 8cdf3231491..7c0dcbdfc01 100644
--- a/frontend/src/app/modules/bim/ifc_models/bcf/list-container/bcf-list-container.component.ts
+++ b/frontend/src/app/modules/bim/ifc_models/bcf/list-container/bcf-list-container.component.ts
@@ -1,22 +1,28 @@
import {ChangeDetectionStrategy, Component, OnInit} from "@angular/core";
import {WorkPackageViewHandlerToken} from "core-app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry";
-import {BcfCardViewHandlerRegistry} from "core-app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry";
import {WorkPackageListViewComponent} from "core-app/modules/work_packages/routing/wp-list-view/wp-list-view.component";
import {QueryResource} from "core-app/modules/hal/resources/query-resource";
import {HalResourceNotificationService} from "core-app/modules/hal/services/hal-resource-notification.service";
import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";
import {DragAndDropService} from "core-app/modules/common/drag-and-drop/drag-and-drop.service";
import {CausedUpdatesService} from "core-app/modules/boards/board/caused-updates/caused-updates.service";
-import {bimSplitViewIdentifier, BimViewService} from "core-app/modules/bim/ifc_models/pages/viewer/bim-view.service";
+import {
+ bimListViewIdentifier,
+ bimSplitViewIdentifier,
+ BimViewService
+} from "core-app/modules/bim/ifc_models/pages/viewer/bim-view.service";
import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
import {wpDisplayCardRepresentation} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-display-representation.service";
import {IfcModelsDataService} from "core-app/modules/bim/ifc_models/pages/viewer/ifc-models-data.service";
+import {IFCViewerService} from "core-app/modules/bim/ifc_models/ifc-viewer/ifc-viewer.service";
+import {States} from "core-components/states.service";
+import {BcfApiService} from "core-app/modules/bim/bcf/api/bcf-api.service";
+import {splitViewRoute} from "core-app/modules/work_packages/routing/split-view-routes.helper";
@Component({
templateUrl: '/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.html',
styleUrls: ['/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.sass'],
providers: [
- { provide: WorkPackageViewHandlerToken, useValue: BcfCardViewHandlerRegistry },
{ provide: HalResourceNotificationService, useClass: WorkPackageNotificationService },
DragAndDropService,
CausedUpdatesService
@@ -26,6 +32,9 @@ import {IfcModelsDataService} from "core-app/modules/bim/ifc_models/pages/viewer
export class BcfListContainerComponent extends WorkPackageListViewComponent implements OnInit {
@InjectField() bimView:BimViewService;
@InjectField() ifcModelsService:IfcModelsDataService;
+ @InjectField() viewer:IFCViewerService;
+ @InjectField() states:States;
+ @InjectField() bcfApi:BcfApiService;
public wpTableConfiguration = {
dragAndDropEnabled: false
@@ -43,4 +52,34 @@ export class BcfListContainerComponent extends WorkPackageListViewComponent impl
return this.bimView.currentViewerState() === bimSplitViewIdentifier;
}
}
+
+ handleWorkPackageClicked(event:{ workPackageId:string; double:boolean }) {
+ // Open the viewpoint if any
+ const wp = this.states.workPackages.get(event.workPackageId).value;
+ if (wp && this.viewer.viewerVisible() && wp.bcfViewpoints) {
+ this.viewer.showViewpoint(wp, 0);
+ }
+
+ if (event.double) {
+ this.$state.go(
+ splitViewRoute(this.$state),
+ { workPackageId: event.workPackageId }
+ );
+ }
+ }
+
+ openStateLink(event:{ workPackageId:string; requestedState:string }) {
+ // In case we're in a regular list without view,
+ // reuse the default list behavior
+ if (this.bimView.current === bimListViewIdentifier) {
+ super.openStateLink(event);
+ return;
+ }
+
+ // Otherwise, always open all links in the details view
+ this.$state.go(
+ splitViewRoute(this.$state),
+ { workPackageId: event.workPackageId, focus: true }
+ );
+ }
}
diff --git a/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry.ts b/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry.ts
deleted file mode 100644
index ea89bfa02ab..00000000000
--- a/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-card-view-handler-registry.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import {WorkPackageCardViewComponent} from "core-components/wp-card-view/wp-card-view.component";
-import {
- CardEventHandler,
- CardViewHandlerRegistry
-} from "core-components/wp-card-view/event-handler/card-view-handler-registry";
-import {BcfDoubleClickHandler} from "core-app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler";
-import {BcfClickHandler} from "core-app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-click-handler";
-import {CardRightClickHandler} from "core-components/wp-card-view/event-handler/right-click-handler";
-
-
-export class BcfCardViewHandlerRegistry extends CardViewHandlerRegistry {
-
- protected eventHandlers:((c:WorkPackageCardViewComponent) => CardEventHandler)[] = [
- // Clicking on the card (not within a cell)
- c => new BcfClickHandler(this.injector, c),
- // Double clicking on the card
- c => new BcfDoubleClickHandler(this.injector, c),
- // Right clicking on cards
- t => new CardRightClickHandler(this.injector, t),
- ];
-}
-
diff --git a/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-click-handler.ts b/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-click-handler.ts
deleted file mode 100644
index 8c7f17bf762..00000000000
--- a/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-click-handler.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import {CardClickHandler} from "core-components/wp-card-view/event-handler/click-handler";
-import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
-import {States} from "core-components/states.service";
-import {IFCViewerService} from "core-app/modules/bim/ifc_models/ifc-viewer/ifc-viewer.service";
-import {BcfApiService} from "core-app/modules/bim/bcf/api/bcf-api.service";
-import {BcfViewpointPaths} from "core-app/modules/bim/bcf/api/viewpoints/bcf-viewpoint.paths";
-
-export class BcfClickHandler extends CardClickHandler {
- @InjectField() viewer:IFCViewerService;
- @InjectField() states:States;
- @InjectField() bcfApi:BcfApiService;
-
- protected handleWorkPackage(wpId:string, element:JQuery<HTMLElement>, evt:JQuery.TriggeredEvent) {
- this.setSelection(wpId, element, evt);
- const wp = this.states.workPackages.get(wpId).value!;
-
- // Open the viewpoint if any
- if (this.viewer.viewerVisible() && wp.bcfViewpoints) {
- this.viewer.showViewpoint(wp, 0);
- }
- }
-}
\ No newline at end of file
diff --git a/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler.ts b/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler.ts
deleted file mode 100644
index 8ec49f82775..00000000000
--- a/frontend/src/app/modules/bim/ifc_models/ifc-base-view/event-handler/bcf-double-click-handler.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import {StateService} from "@uirouter/core";
-import {CardDblClickHandler} from "core-components/wp-card-view/event-handler/double-click-handler";
-import {InjectField} from "core-app/helpers/angular/inject-field.decorator";
-import {bimListViewIdentifier, BimViewService} from "core-app/modules/bim/ifc_models/pages/viewer/bim-view.service";
-
-export class BcfDoubleClickHandler extends CardDblClickHandler {
- @InjectField() state:StateService;
- @InjectField() bimView:BimViewService;
-
- protected handleWorkPackage(wpId:string) {
- if (this.bimView.current === bimListViewIdentifier) {
- this.state.go('work-packages.show', { workPackageId: wpId });
- } else {
- this.state.go('.details', { workPackageId: wpId });
- }
- }
-}
diff --git a/frontend/src/app/modules/boards/board/board-list/board-list.component.html b/frontend/src/app/modules/boards/board/board-list/board-list.component.html
index 2bfbac69c9e..7a670695281 100644
--- a/frontend/src/app/modules/boards/board/board-list/board-list.component.html
+++ b/frontend/src/app/modules/boards/board/board-list/board-list.component.html
@@ -55,7 +55,8 @@
[cardsRemovable]="board.isFree && canDragOutOf"
[showInfoButton]="true"
[highlightingMode]="board.highlightingMode"
- [showStatusButton]="showCardStatusButton()">
+ [showStatusButton]="showCardStatusButton()"
+ (itemClicked)="openFullViewOnDoubleClick($event)" >
</wp-card-view>
</div>
diff --git a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
index 77676c29202..fd762642994 100644
--- a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
+++ b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
@@ -465,4 +465,13 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
this.updateQuery(true);
});
}
+
+ openFullViewOnDoubleClick(event:{ workPackageId:string, double:boolean }) {
+ if (event.double) {
+ this.state.go(
+ 'work-packages.show',
+ { workPackageId: event.workPackageId }
+ );
+ }
+ }
}
diff --git a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
index 8e2d045ddb3..d33e5ff34ff 100644
--- a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
@@ -37,7 +37,6 @@ import {
import {HookService} from 'core-app/modules/plugins/hook-service';
import {WorkPackageEmbeddedTableComponent} from 'core-components/wp-table/embedded/wp-embedded-table.component';
import {WorkPackageEmbeddedTableEntryComponent} from 'core-components/wp-table/embedded/wp-embedded-table-entry.component';
-import {WorkPackagesTableController} from 'core-components/wp-table/wp-table.directive';
import {WorkPackageTablePaginationComponent} from 'core-components/wp-table/table-pagination/wp-table-pagination.component';
import {WpResizerDirective} from 'core-components/resizer/wp-resizer.component';
import {WorkPackageTimelineTableController} from 'core-components/wp-table/timeline/container/wp-timeline-container.directive';
@@ -168,6 +167,7 @@ import {WorkPackageViewPageComponent} from "core-app/modules/work_packages/routi
import {WorkPackageSettingsButtonComponent} from "core-components/wp-buttons/wp-settings-button/wp-settings-button.component";
import {BackButtonComponent} from "core-app/modules/common/back-routing/back-button.component";
import {DatePickerModal} from "core-components/datepicker/datepicker.modal";
+import {WorkPackagesTableComponent} from "core-components/wp-table/wp-table.component";
import {AttributeHelpTextComponent} from "core-app/modules/common/help-texts/attribute-help-text.component";
import {AttributeHelpTextModal} from "core-app/modules/common/help-texts/attribute-help-text.modal";
@@ -258,7 +258,7 @@ import {AttributeHelpTextModal} from "core-app/modules/common/help-texts/attribu
WorkPackagesGridComponent,
- WorkPackagesTableController,
+ WorkPackagesTableComponent,
WorkPackagesTableConfigMenu,
WorkPackageTablePaginationComponent,
@@ -386,7 +386,7 @@ import {AttributeHelpTextModal} from "core-app/modules/common/help-texts/attribu
AttributeHelpTextModal,
],
exports: [
- WorkPackagesTableController,
+ WorkPackagesTableComponent,
WorkPackageTablePaginationComponent,
WorkPackageEmbeddedTableComponent,
WorkPackageEmbeddedTableEntryComponent,
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.html b/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.html
index f4c83cc780a..f759c41dd5c 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.html
+++ b/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.html
@@ -5,6 +5,8 @@
<wp-table *ngIf="tableInformationLoaded && showListView"
[projectIdentifier]="CurrentProject.identifier"
[configuration]="wpTableConfiguration"
+ (itemClicked)="handleWorkPackageClicked($event)"
+ (stateLinkClicked)="openStateLink($event)"
class="work-packages-split-view--tabletimeline-content"></wp-table>
<!-- GRID representation of the WP -->
@@ -13,6 +15,8 @@
[ngClass]="{ '-with-resizer': showResizerInCardView() }" >
<wp-grid [configuration]="wpTableConfiguration"
[showResizer]="showResizerInCardView()"
+ (itemClicked)="handleWorkPackageCardClicked($event)"
+ (stateLinkClicked)="openStateLink($event)"
resizerClass="work-packages-partitioned-page--content-right"
resizerStorageKey="openProject-splitViewFlexBasis">
</wp-grid>
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts b/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts
index c8a99ffb3f3..38a101a0a41 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts
@@ -44,6 +44,8 @@ import {CurrentProjectService} from "core-components/projects/current-project.se
import {WorkPackageViewFiltersService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-filters.service";
import {UntilDestroyedMixin} from "core-app/helpers/angular/until-destroyed.mixin";
import {QueryResource} from "core-app/modules/hal/resources/query-resource";
+import {StateService} from "@uirouter/core";
+import {KeepTabService} from "core-components/wp-single-view-tabs/keep-tab/keep-tab.service";
@Component({
selector: 'wp-list-view',
@@ -84,6 +86,8 @@ export class WorkPackageListViewComponent extends UntilDestroyedMixin implements
constructor(readonly I18n:I18nService,
readonly injector:Injector,
+ readonly $state:StateService,
+ readonly keepTab:KeepTabService,
readonly querySpace:IsolatedQuerySpace,
readonly wpViewFilters:WorkPackageViewFiltersService,
readonly deviceService:DeviceService,
@@ -127,4 +131,36 @@ export class WorkPackageListViewComponent extends UntilDestroyedMixin implements
this.showListView = !(this.deviceService.isMobile ||
this.wpDisplayRepresentation.valueFromQuery(query) === wpDisplayCardRepresentation);
}
+
+ handleWorkPackageClicked(event:{ workPackageId:string; double:boolean }) {
+ if (event.double) {
+ this.openInFullView(event.workPackageId);
+ }
+ }
+
+ openStateLink(event:{ workPackageId:string; requestedState:string }) {
+ this.$state.go(
+ (this.keepTab as any)[event.requestedState] || event.requestedState,
+ { workPackageId: event.workPackageId, focus: true }
+ );
+ }
+
+ /**
+ * Special handling for clicking on cards.
+ * If we are on mobile, a click on the card should directly open the full view
+ */
+ handleWorkPackageCardClicked(event:{ workPackageId:string; double:boolean }) {
+ if (this.deviceService.isMobile) {
+ this.openInFullView(event.workPackageId);
+ } else {
+ this.handleWorkPackageClicked(event);
+ }
+ }
+
+ private openInFullView(workPackageId:string) {
+ this.$state.go(
+ 'work-packages.show',
+ { workPackageId: workPackageId }
+ );
+ }
}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts
index da080c7ca99..1eb2c692cbb 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/event-handling/event-handler-registry.ts
@@ -1,4 +1,4 @@
-import {InjectionToken, Injector} from '@angular/core';
+import {EventEmitter, InjectionToken, Injector} from '@angular/core';
export interface WorkPackageViewEventHandler<T> {
/** Event name to register **/
@@ -14,8 +14,13 @@ export interface WorkPackageViewEventHandler<T> {
eventScope(view:T):JQuery;
}
-export interface WorkPackageViewHandlerClass<T> {
- new(injector:Injector):WorkPackageViewEventHandler<any>;
+export interface WorkPackageViewOutputs {
+ // On selection updated
+ selectionChanged:EventEmitter<string[]>;
+ // On row (double) clicked
+ itemClicked:EventEmitter<{ workPackageId:string, double:boolean }>;
+ // On work package link / details icon clicked
+ stateLinkClicked:EventEmitter<{ workPackageId:string, requestedState:string }>;
}
export const WorkPackageViewHandlerToken = new InjectionToken<WorkPackageViewEventHandler<any>>('CardEventHandler');