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
implement moving entry by dragging
ulfertsd1acccd464c4
diff --git a/frontend/npm-shrinkwrap.json b/frontend/npm-shrinkwrap.jsonindex d93db2b6262..9b6ce05dca5 100644--- a/frontend/npm-shrinkwrap.json+++ b/frontend/npm-shrinkwrap.json@@ -3355,6 +3355,11 @@"resolved": "https://registry.npmjs.org/@fullcalendar/daygrid/-/daygrid-4.3.0.tgz","integrity": "sha512-OrGaRIGbELESOXOCXtoQVY4cOxnxmN7OrjDGbMoVITdoXWuIZ6sFNO84WcBQoRaIbkmqVM0SAU2MENwy+eEwqQ=="},+ "@fullcalendar/interaction": {+ "version": "4.3.0",+ "resolved": "https://registry.npmjs.org/@fullcalendar/interaction/-/interaction-4.3.0.tgz",+ "integrity": "sha512-kaKV+tdgH/oIrwTSMGYFec989L5r+KMYJ9ybwLc8G3LbMVcebo8fAlN9VizmGQAuopKfyvOw8yzJdjfmVCCRYQ=="+ },"@fullcalendar/timegrid": {"version": "4.3.0","resolved": "https://registry.npmjs.org/@fullcalendar/timegrid/-/timegrid-4.3.0.tgz",diff --git a/frontend/package.json b/frontend/package.jsonindex 7c058aaf496..251cfce6a3d 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -46,6 +46,7 @@"@fullcalendar/core": "4.3.1","@fullcalendar/daygrid": "4.3.0","@fullcalendar/timegrid": "4.3.0",+ "@fullcalendar/interaction": "4.3.0","@ng-select/ng-option-highlight": "0.0.2","@ng-select/ng-select": "^3.0.6","@sentry/browser": "^5.7.1",diff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.tsindex d776d3c756b..792c1bbda3f 100644--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts@@ -8,7 +8,7 @@ import {I18nService} from "core-app/modules/common/i18n/i18n.service";import {NotificationsService} from "core-app/modules/common/notifications/notifications.service";import {DomSanitizer} from "@angular/platform-browser";import timeGrid from '@fullcalendar/timegrid';-import { EventInput, EventApi } from '@fullcalendar/core';+import { EventInput, EventApi, Duration, View } from '@fullcalendar/core';import { EventSourceError } from '@fullcalendar/core/structs/event-source';import { ToolbarInput } from '@fullcalendar/core/types/input-types';import {ConfigurationService} from "core-app/modules/common/config/configuration.service";@@ -19,6 +19,8 @@ import {TimezoneService} from "core-components/datetime/timezone.service";import {CollectionResource} from "core-app/modules/hal/resources/collection-resource";import { TimeEntryEditService } from './edit/edit.service';import {TimeEntryCacheService} from "core-components/time-entries/time-entry-cache.service";+import interactionPlugin from '@fullcalendar/interaction';+interface CalendarViewEvent {el:HTMLElement;@@ -26,6 +28,16 @@ interface CalendarViewEvent {jsEvent:MouseEvent;}+interface CalendarMoveEvent {+ el:HTMLElement;+ event:EventApi;+ oldEvent:EventApi;+ delta:Duration;+ revert:() => void;+ jsEvent:Event;+ view:View;+}+@Component({templateUrl: './te-calendar.template.html',styleUrls: ['./te-calendar.component.sass'],@@ -38,7 +50,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI@Input() static:boolean = false;@Output() entries = new EventEmitter<CollectionResource<TimeEntryResource>>();- public calendarPlugins = [timeGrid];+ public calendarPlugins = [timeGrid, interactionPlugin];public calendarEvents:Function;public calendarHeader:ToolbarInput|boolean = {right: '',@@ -83,6 +95,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI// Therefore, setting the outputs via the underlying APIthis.ucCalendar.getApi().setOption('eventRender', (event:CalendarViewEvent) => { this.addTooltip(event); });this.ucCalendar.getApi().setOption('eventClick', (event:CalendarViewEvent) => { this.editEvent(event); });+ this.ucCalendar.getApi().setOption('eventDrop', (event:CalendarMoveEvent) => { this.moveEvent(event); });}public calendarEventsFunction(fetchInfo:{ start:Date, end:Date },@@ -123,7 +136,6 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewIprivate buildTimeEntryEntries(entries:TimeEntryResource[]) {let hoursDistribution:{ [key:string]:Moment } = {};- let dateSums:{ [key:string]:number } = {};return entries.map((entry) => {let start:Moment;@@ -142,6 +154,7 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewIreturn {title: hours < 0.5 ? '' : this.entryName(entry),+ startEditable: !!entry.update,start: start.format(),end: end.format(),entry: entry@@ -221,26 +234,46 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewI.timeEntryEdit.edit(originalEntry).then(modificationAction => {- this.memoizedTimeEntries.entries.then(collection => {- let foundIndex = collection.elements.findIndex(x => x.id === originalEntry.id);-- switch (modificationAction.action) {- case 'update':- collection.elements[foundIndex] = modificationAction.entry;- break;- case 'destroy':- collection.elements.splice(foundIndex, 1);- break;- }-- this.ucCalendar.getApi().refetchEvents();- });+ this.updateEventSet(modificationAction.entry, modificationAction.action);}).catch(() => {// do nothing, the user closed without changes});}+ private moveEvent(event:CalendarMoveEvent) {+ let entry = event.event.extendedProps.entry;++ entry.spentOn = moment(event.event.start!).format('YYYY-MM-DD');++ this+ .timeEntryDm+ .update(entry, entry.schema)+ .then(event => {+ this.updateEventSet(event, 'update');+ })+ .catch(() => {+ event.revert();+ });+ }++ private updateEventSet(event:TimeEntryResource, action:'update'|'destroy') {+ this.memoizedTimeEntries.entries.then(collection => {+ let foundIndex = collection.elements.findIndex(x => x.id === event.id);++ switch (action) {+ case 'update':+ collection.elements[foundIndex] = event;+ break;+ case 'destroy':+ collection.elements.splice(foundIndex, 1);+ break;+ }++ this.ucCalendar.getApi().refetchEvents();+ });+ }+private addTooltip(event:CalendarViewEvent) {if (!event.event.extendedProps.entry) {return;diff --git a/frontend/src/app/modules/hal/dm-services/time-entry-dm.service.ts b/frontend/src/app/modules/hal/dm-services/time-entry-dm.service.tsindex dc039eb8902..af08f080ff7 100644--- a/frontend/src/app/modules/hal/dm-services/time-entry-dm.service.ts+++ b/frontend/src/app/modules/hal/dm-services/time-entry-dm.service.ts@@ -52,6 +52,12 @@ export class TimeEntryDmService extends AbstractDmService<TimeEntryResource> {return this.pathHelper.api.v3.time_entries.id(id).toString();}+ public update(resource:TimeEntryResource, schema:SchemaResource|null = null) {+ let payload = this.extractPayload(resource, schema);++ return this.halResourceService.patch<TimeEntryResource>(resource.updateImmediately.$link.href, payload).toPromise();+ }+public updateForm(resource:TimeEntryResource, schema:SchemaResource|null = null) {let payload = this.extractPayload(resource, schema);