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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add dropping to new resources
Oliver Günther456b573b7726
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.tsindex 117db2e363c..ffd3d88a805 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@@ -11,6 +11,7 @@ import {import {CalendarOptions,DateSelectArg,+ EventDropArg,EventInput,} from '@fullcalendar/core';import {@@ -45,6 +46,8 @@ import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destrimport { ResourceLabelContentArg } from '@fullcalendar/resource-common';import { OpCalendarService } from 'core-app/shared/components/calendar/op-calendar.service';import { WorkPackageCollectionResource } from 'core-app/features/hal/resources/wp-collection-resource';+import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';+import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';@Component({selector: 'op-team-planner',@@ -122,6 +125,8 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,private viewLookup:EventViewLookupService,private I18n:I18nService,readonly calendar:OpCalendarService,+ readonly halEditing:HalResourceEditingService,+ readonly halNotification:HalResourceNotificationService,) {super();}@@ -236,7 +241,8 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,resourceLabelWillUnmount: (data:ResourceLabelContentArg) => this.unrenderTemplate(data.resource.id),// DnD configurationeditable: true,- eventResize: (resizeInfo:EventResizeDoneArg) => this.calendar.updateDates(resizeInfo),+ eventResize: (resizeInfo:EventResizeDoneArg) => this.updateEvent(resizeInfo),+ eventDrop: (dropInfo:EventDropArg) => this.updateEvent(dropInfo),} as CalendarOptions),);});@@ -382,4 +388,20 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,},);}++ private async updateEvent(info:EventResizeDoneArg|EventDropArg):Promise<void> {+ const changeset = this.calendar.updateDates(info);++ const resource = (info as EventDropArg).newResource;+ if (resource) {+ changeset.setValue('assignee', { href: resource.id });+ }++ try {+ const result = await this.halEditing.save(changeset);+ this.halNotification.showSave(result.resource, result.wasNew);+ } catch (e) {+ info.revert();+ }+ }}diff --git a/frontend/src/app/shared/components/calendar/op-calendar.service.ts b/frontend/src/app/shared/components/calendar/op-calendar.service.tsindex 7daa39a121d..09475bae0fa 100644--- a/frontend/src/app/shared/components/calendar/op-calendar.service.ts+++ b/frontend/src/app/shared/components/calendar/op-calendar.service.ts@@ -7,6 +7,7 @@ import {CalendarOptions,DatesSetArg,EventApi,+ EventDropArg,} from '@fullcalendar/core';import { I18nService } from 'core-app/core/i18n/i18n.service';import { ConfigurationService } from 'core-app/core/config/configuration.service';@@ -43,6 +44,7 @@ import { EventResizeDoneArg } from '@fullcalendar/interaction';import { HalResourceEditFieldHandler } from 'core-app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler';import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';import { HalResourceNotificationService } from 'core-app/features/hal/services/hal-resource-notification.service';+import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';export interface CalendarViewEvent {el:HTMLElement;@@ -84,7 +86,6 @@ export class OpCalendarService extends UntilDestroyedMixin {readonly uiRouterGlobals:UIRouterGlobals,readonly timezoneService:TimezoneService,readonly halEditing:HalResourceEditingService,- readonly halNotification:HalResourceNotificationService,) {super();}@@ -355,7 +356,7 @@ export class OpCalendarService extends UntilDestroyedMixin {);}- async updateDates(resizeInfo:EventResizeDoneArg):Promise<void> {+ updateDates(resizeInfo:EventResizeDoneArg|EventDropArg):ResourceChangeset<WorkPackageResource> {const workPackage = resizeInfo.event.extendedProps.workPackage as WorkPackageResource;const changeset = this.halEditing.edit(workPackage);@@ -365,11 +366,6 @@ export class OpCalendarService extends UntilDestroyedMixin {.format('YYYY-MM-DD');changeset.setValue('dueDate', due);- try {- const result = await this.halEditing.save(changeset);- this.halNotification.showSave(result.resource, result.wasNew);- } catch (e) {- resizeInfo.revert();- }+ return changeset;}}