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

Map the date correctly and set duration

Oliver Güntherfbed5082a5d1
diff --git a/frontend/src/app/shared/components/datepicker/helpers/date-modal.helpers.ts b/frontend/src/app/shared/components/datepicker/helpers/date-modal.helpers.ts
index 1c085c2250f..fdd1023418e 100644
--- a/frontend/src/app/shared/components/datepicker/helpers/date-modal.helpers.ts
+++ b/frontend/src/app/shared/components/datepicker/helpers/date-modal.helpers.ts
@@ -30,6 +30,16 @@ import { DatePicker } from 'core-app/shared/components/op-date-picker/datepicker
import { DateOption } from 'flatpickr/dist/types/options';
import { DayElement } from 'flatpickr/dist/types/instance';
+/**
+ * Map the date to the internal format,
+ * setting to null if it's empty.
+ * @param date
+ */
+// eslint-disable-next-line class-methods-use-this
+export function mappedDate(date:string|null):string|null {
+ return (date === '') ? null : date;
+}
+
// eslint-disable-next-line class-methods-use-this
export function parseDate(date:Date|string):Date|'' {
if (date instanceof Date) {
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index 9f349926635..f78b13fd9b4 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -67,6 +67,7 @@ import { DateModalRelationsService } from 'core-app/shared/components/datepicker
import { DateModalSchedulingService } from 'core-app/shared/components/datepicker/services/date-modal-scheduling.service';
import {
areDatesEqual,
+ mappedDate,
onDayCreate,
parseDate,
setDates,
@@ -303,8 +304,9 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
// Apply the dates if they could be changed
if (this.isSchedulable) {
- this.changeset.setValue('startDate', this.dates.start);
- this.changeset.setValue('dueDate', this.dates.end);
+ this.changeset.setValue('startDate', mappedDate(this.dates.start));
+ this.changeset.setValue('dueDate', mappedDate(this.dates.end));
+ this.changeset.setValue('duration', this.durationAsIso8601);
}
this.closeMe();
diff --git a/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts b/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts
index dc4e64a6452..fe1703013fb 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts
@@ -65,6 +65,7 @@ import { FormResource } from 'core-app/features/hal/resources/form-resource';
import { DateModalRelationsService } from 'core-app/shared/components/datepicker/services/date-modal-relations.service';
import { DateModalSchedulingService } from 'core-app/shared/components/datepicker/services/date-modal-scheduling.service';
import {
+ mappedDate,
onDayCreate,
parseDate,
setDates,
@@ -233,7 +234,7 @@ export class SingleDateModalComponent extends OpModalComponent implements AfterV
// Apply the dates if they could be changed
if (this.dateModalScheduling.isSchedulable) {
- this.changeset.setValue('date', this.date);
+ this.changeset.setValue('date', mappedDate(this.date));
}
this.closeMe();