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

Show duration value inside the field. It is formatted to add "days" after the actual value

Henriette Darge8c484a88f694
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.html b/frontend/src/app/shared/components/datepicker/datepicker.modal.html
index 0ff9be814eb..558f7c3a3a4 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.html
+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.html
@@ -120,7 +120,10 @@
name="duration"
data-qa-selector="op-datepicker-modal--duration-field"
class="op-datepicker-modal--date-field"
+ [(ngModel)]="formattedDuration"
[disabled]="!isSchedulable"
+ (focusin)="handleDurationFocusIn()"
+ (focusout)="handleDurationFocusOut()"
></spot-text-field>
</div>
</div>
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
index a4ce6c36398..4e7f0515cfa 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
@@ -107,6 +107,10 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
includeNonWorkingDays = false;
+ duration:number;
+
+ formattedDuration:string;
+
htmlId = '';
dates:{ [key in DateKeys]:string } = {
@@ -137,6 +141,8 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
this.singleDate = this.changeset.isWritable('date');
this.scheduleManually = !!this.changeset.value('scheduleManually');
this.includeNonWorkingDays = !this.changeset.value('ignoreNonWorkingDays');
+ this.duration = this.changeset.value('duration') as number;
+ this.formattedDuration = this.timezoneService.formattedDuration(this.duration.toString(), 'days');
if (this.singleDate) {
this.dates.date = this.changeset.value('date') as string;
@@ -270,6 +276,14 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
return this.datepickerService.isStateOfCurrentActivatedField(field) && this.isSchedulable;
}
+ handleDurationFocusIn():void {
+ this.formattedDuration = this.timezoneService.toDays(this.duration.toString()).toString();
+ }
+
+ handleDurationFocusOut():void {
+ this.formattedDuration = this.timezoneService.formattedDuration(this.duration.toString(), 'days');
+ }
+
private initializeDatepicker(minimalDate?:Date|null) {
this.datePickerInstance?.destroy();
this.datePickerInstance = new DatePicker(