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

Use dragula as dragging library to have better control on the drag events (e.g. change style of placeholder element)

Henriette Dargec3243de8e95d
diff --git a/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.html b/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.html
index 3eca2e2cfcc..d59cd297b5e 100644
--- a/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.html
+++ b/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.html
@@ -28,7 +28,9 @@
<ng-container
*ngIf="(isEmpty$ | async) === false; else emptyTemplate"
>
- <div class="op-quick-add-pane--results">
+ <div
+ #container
+ class="op-quick-add-pane--results">
<ng-container *ngFor="let wp of resultingWorkPackages">
<wp-single-card
[workPackage]="wp"
diff --git a/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.ts b/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.ts
index eaa5c7082d4..93ed909e097 100644
--- a/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.ts
+++ b/frontend/src/app/features/team-planner/team-planner/add-work-packages/quick-add-pane.component.ts
@@ -2,8 +2,9 @@ import {
ChangeDetectionStrategy,
Component,
ElementRef,
- Input,
+ HostListener,
OnInit,
+ ViewChild,
} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { imagePath } from 'core-app/shared/helpers/images/path-helper';
@@ -24,8 +25,9 @@ import { CurrentProjectService } from 'core-app/core/current-project/current-pro
import { UrlParamsHelperService } from 'core-app/features/work-packages/components/wp-query/url-params-helper';
import { IsolatedQuerySpace } from 'core-app/features/work-packages/directives/query-space/isolated-query-space';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
-import { Draggable } from '@fullcalendar/interaction';
+import { ThirdPartyDraggable } from '@fullcalendar/interaction';
import { DragMetaInput } from '@fullcalendar/common';
+import { Drake } from 'dragula';
@Component({
selector: 'op-quick-add-pane',
@@ -34,6 +36,20 @@ import { DragMetaInput } from '@fullcalendar/common';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class QuickAddPaneComponent extends UntilDestroyedMixin implements OnInit {
+ @ViewChild('container') container:ElementRef;
+
+ @ViewChild('container')
+ set dragContainer(v:ElementRef|undefined) {
+ // ViewChild reference may be undefined initially
+ // due to ngIf
+ if (v !== undefined) {
+ if (this.drake) {
+ this.drake.destroy();
+ }
+ this.registerDrag();
+ }
+ }
+
searchString = '';
isEmpty$ = new BehaviorSubject<boolean>(true);
@@ -51,7 +67,7 @@ export class QuickAddPaneComponent extends UntilDestroyedMixin implements OnInit
resultingWorkPackages:WorkPackageResource[] = [];
- draggable:Draggable;
+ drake:Drake;
constructor(
private readonly querySpace:IsolatedQuerySpace,
@@ -66,7 +82,13 @@ export class QuickAddPaneComponent extends UntilDestroyedMixin implements OnInit
}
ngOnInit():void {
- this.registerDrag();
+ }
+
+ ngOnDestroy() {
+ super.ngOnDestroy();
+ if (this.drake) {
+ this.drake.destroy();
+ }
}
searchWorkPackages(searchString:string):void {
@@ -111,7 +133,7 @@ export class QuickAddPaneComponent extends UntilDestroyedMixin implements OnInit
.filtered(filters)
.get()
.pipe(
- debounceTime(250),
+ debounceTime(100),
map((collection) => collection.elements),
catchError((error:unknown) => {
this.notificationService.handleRawError(error);
@@ -136,13 +158,19 @@ export class QuickAddPaneComponent extends UntilDestroyedMixin implements OnInit
}
private registerDrag():void {
- if (this.draggable) {
- // Destroy old drag handlers to avoid multiple events
- this.draggable.destroy();
- }
+ this.drake = dragula({
+ containers: [this.container?.nativeElement],
+ revertOnSpill: true,
+ });
+
+ this.drake.on('drag', (el:HTMLElement) => {
+ el.classList.add('gu-transit');
+ });
- this.draggable = new Draggable(this.ref.nativeElement, {
+ // eslint-disable-next-line no-new
+ new ThirdPartyDraggable(this.container?.nativeElement, {
itemSelector: '.op-quick-add-pane--wp',
+ mirrorSelector: '.gu-mirror', // the dragging element that dragula renders
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
eventData: this.eventData.bind(this),
});
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
index e612dfd9b04..ae6b5181ae7 100644
--- a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
+++ b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
@@ -454,7 +454,10 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
.subscribe(async (wp) => {
const changeset = this.halEditing.edit(wp);
changeset.setValue('startDate', dropInfo.event.startStr);
- changeset.setValue('dueDate', dropInfo.event.endStr);
+ const due = moment(dropInfo.event.endStr)
+ .subtract(1, 'day')
+ .format('YYYY-MM-DD');
+ changeset.setValue('dueDate', due);
const resource = dropInfo.event.getResources()[0];
if (resource) {