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
Resizing of events in team planner
Oliver Günther2779577b65a2
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 e9a66c0a83f..117db2e363c 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@@ -27,7 +27,7 @@ import {import { EventClickArg } from '@fullcalendar/common';import { StateService } from '@uirouter/angular';import resourceTimelinePlugin from '@fullcalendar/resource-timeline';-import interactionPlugin from '@fullcalendar/interaction';+import interactionPlugin, { EventResizeDoneArg } from '@fullcalendar/interaction';import { FullCalendarComponent } from '@fullcalendar/angular';import { I18nService } from 'core-app/core/i18n/i18n.service';import { ConfigurationService } from 'core-app/core/config/configuration.service';@@ -198,7 +198,6 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,this.calendarOptions$.next(this.calendar.calendarOptions({schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',- editable: false,selectable: true,plugins: [resourceTimelinePlugin,@@ -235,6 +234,9 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,select: this.handleDateClicked.bind(this) as unknown,resourceLabelContent: (data:ResourceLabelContentArg) => this.renderTemplate(this.resourceContent, data.resource.id, data),resourceLabelWillUnmount: (data:ResourceLabelContentArg) => this.unrenderTemplate(data.resource.id),+ // DnD configuration+ editable: true,+ eventResize: (resizeInfo:EventResizeDoneArg) => this.calendar.updateDates(resizeInfo),} as CalendarOptions),);});@@ -334,6 +336,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,return {id: `${workPackage.href as string}-${assignee}`,resourceId: assignee,+ durationEditable: !this.calendar.isMilestone(workPackage),title: workPackage.subject,start: startDate,end: exclusiveEnd,diff --git a/frontend/src/app/shared/components/calendar/op-calendar.service.ts b/frontend/src/app/shared/components/calendar/op-calendar.service.tsindex 7c4b8433b18..7daa39a121d 100644--- a/frontend/src/app/shared/components/calendar/op-calendar.service.ts+++ b/frontend/src/app/shared/components/calendar/op-calendar.service.ts@@ -39,6 +39,10 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { UIRouterGlobals } from '@uirouter/core';import { TimezoneService } from 'core-app/core/datetime/timezone.service';import { WorkPackagesListChecksumService } from 'core-app/features/work-packages/components/wp-list/wp-list-checksum.service';+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';export interface CalendarViewEvent {el:HTMLElement;@@ -79,6 +83,8 @@ export class OpCalendarService extends UntilDestroyedMixin {readonly halResourceService:HalResourceService,readonly uiRouterGlobals:UIRouterGlobals,readonly timezoneService:TimezoneService,+ readonly halEditing:HalResourceEditingService,+ readonly halNotification:HalResourceNotificationService,) {super();}@@ -104,30 +110,25 @@ export class OpCalendarService extends UntilDestroyedMixin {jQuery(event.el).tooltip({content: this.tooltipContentString(event.event.extendedProps.workPackage),items: '.fc-event',- close() {- jQuery('.ui-helper-hidden-accessible').remove();- },track: true,});}removeTooltip(element:HTMLElement):void {- // deactivate tooltip so that it is not displayed on the wp show page- jQuery(element).tooltip({- close() {- jQuery('.ui-helper-hidden-accessible').remove();- },- disabled: true,- });+ jQuery(element).tooltip('close');}eventDate(workPackage:WorkPackageResource, type:'start'|'due'):string {- if (this.schemaCache.of(workPackage).isMilestone) {+ if (this.isMilestone(workPackage)) {return workPackage.date;}return workPackage[`${type}Date`];}+ isMilestone(workPackage:WorkPackageResource):boolean {+ return this.schemaCache.of(workPackage).isMilestone as boolean;+ }+warnOnTooManyResults(collection:WorkPackageCollectionResource, isStatic = false):void {if (collection.count < collection.total) {this.tooManyResultsText = this.I18n.t('js.calendar.too_many',@@ -353,4 +354,22 @@ export class OpCalendarService extends UntilDestroyedMixin {{ cdate: this.timezoneService.formattedISODate(dates.start) },);}++ async updateDates(resizeInfo:EventResizeDoneArg):Promise<void> {+ const workPackage = resizeInfo.event.extendedProps.workPackage as WorkPackageResource;++ const changeset = this.halEditing.edit(workPackage);+ changeset.setValue('startDate', resizeInfo.event.startStr);+ const due = moment(resizeInfo.event.endStr)+ .subtract(1, 'day')+ .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();+ }+ }}