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
Update dates only when not clearing the active field
Oliver Günther872f8ae019b3
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts b/frontend/src/app/shared/components/datepicker/datepicker.modal.tsindex 61686550dba..6a19006bcd2 100644--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts@@ -218,13 +218,42 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV// Always update the whole form to ensure that no values are lost/inconsistentif (this.singleDate) {this.updateDate('date', this.dates.date);- } else if (this.datepickerService.currentlyActivatedDateField === 'start') {+ return;+ }++ const activeField = this.datepickerService.currentlyActivatedDateField;++ if (activeField === 'start') {this.updateDate('end', this.dates.end);this.updateDate('start', this.dates.start);} else if (this.datepickerService.currentlyActivatedDateField === 'end') {this.updateDate('start', this.dates.start);this.updateDate('end', this.dates.end);}++ const startPresent = this.dates.start !== '';+ const endPresent = this.dates.end !== '';++ // In case of start and due, update form+ if (startPresent && endPresent) {+ this.dateUpdates$.next({ startDate: this.dates.start, dueDate: this.dates.end });+ }++ // In case of start and duration and end date is null+ if (startPresent && !endPresent && activeField !== 'end' && this.duration) {+ this.dateUpdates$.next({+ startDate: this.dates.start,+ duration: this.durationAsIso8601,+ });+ }++ // In case of end and duration and start date is null+ if (!startPresent && endPresent && activeField !== 'start' && this.duration) {+ this.dateUpdates$.next({+ dueDate: this.dates.end,+ duration: this.durationAsIso8601,+ });+ }});}@@ -321,12 +350,12 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterVif (this.dates.start) {this.dateUpdates$.next({startDate: this.dates.start,- duration: this.timezoneService.toISODuration(this.duration, 'days'),+ duration: this.durationAsIso8601,});} else if (this.dates.end) {this.dateUpdates$.next({dueDate: this.dates.end,- duration: this.timezoneService.toISODuration(this.duration, 'days'),+ duration: this.durationAsIso8601,});}}@@ -335,6 +364,10 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterVthis.duration = typeof value === 'string' ? parseInt(value, 10) : value;}+ private get durationAsIso8601():string {+ return this.timezoneService.toISODuration(this.duration, 'days');+ }+private showDurationWithDays() {this.displayedDuration = this.text.days(this.duration);}@@ -408,6 +441,7 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV}private handleDatePickerChange(dates:Date[]) {+ console.warn(dates);switch (dates.length) {case 1: {const selectedDate = dates[0];@@ -431,8 +465,7 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterVif (this.datepickerService.isStateOfCurrentActivatedField('end')) {this.overwriteDatePickerWithNewDates([parsedStartDate, selectedDate]);} else {- this.dates.start = this.timezoneService.formattedISODate(selectedDate);- this.dates.end = '';+ this.overwriteDatePickerWithNewDates([selectedDate, selectedDate]);this.datepickerService.toggleCurrentActivatedField();}} else if (this.datepickerService.areDatesEqual(selectedDate, parsedStartDate) || this.datepickerService.areDatesEqual(selectedDate, parsedEndDate)) {@@ -444,6 +477,15 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV} else if (this.datepickerService.currentlyActivatedDateField !== 'duration') {this.dates[this.datepickerService.currentlyActivatedDateField] = this.timezoneService.formattedISODate(selectedDate);this.datepickerService.toggleCurrentActivatedField();++ // If duration has been set, calculate the other date field+ if (this.datepickerService.currentlyActivatedDateField === 'start' && this.duration) {+ this.dateUpdates$.next({ startDate: this.dates.start, duration: this.durationAsIso8601 });+ }++ if (this.datepickerService.currentlyActivatedDateField === 'end' && this.duration) {+ this.dateUpdates$.next({ dueDate: this.dates.end, duration: this.durationAsIso8601 });+ }}break;@@ -453,6 +495,7 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterVthis.dates.start = this.timezoneService.formattedISODate(dates[0]);this.dates.end = this.timezoneService.formattedISODate(dates[1]);this.datepickerService.toggleCurrentActivatedField();+ this.dateUpdates$.next({ startDate: this.dates.start, dueDate: this.dates.end });break;}default: {