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

Start including duration field into active fields

Oliver Günther0d230d4f4d4a
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.html b/frontend/src/app/shared/components/datepicker/datepicker.modal.html
index 558f7c3a3a4..b749490779f 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.html
+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.html
@@ -120,6 +120,7 @@
name="duration"
data-qa-selector="op-datepicker-modal--duration-field"
class="op-datepicker-modal--date-field"
+ [ngClass]="{'op-datepicker-modal--date-field_current' : showFieldAsActive('duration')}"
[(ngModel)]="formattedDuration"
[disabled]="!isSchedulable"
(focusin)="handleDurationFocusIn()"
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.service.ts b/frontend/src/app/shared/components/datepicker/datepicker.modal.service.ts
index ff47bcdc28b..e7eeac3d21d 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.service.ts
+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.service.ts
@@ -30,7 +30,10 @@ import {
Inject,
Injectable,
} from '@angular/core';
-import { DateKeys } from 'core-app/shared/components/datepicker/datepicker.modal';
+import {
+ DateFields,
+ DateKeys,
+} from 'core-app/shared/components/datepicker/datepicker.modal';
import { DatePicker } from 'core-app/shared/components/op-date-picker/datepicker';
import { DateOption } from 'flatpickr/dist/types/options';
import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
@@ -56,7 +59,7 @@ import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
@Injectable()
export class DatepickerModalService {
- currentlyActivatedDateField:DateKeys;
+ currentlyActivatedDateField:DateFields;
private changeset:WorkPackageChangeset = this.locals.changeset as WorkPackageChangeset;
@@ -189,7 +192,7 @@ export class DatepickerModalService {
return parsedDate1.getTime() === parsedDate2.getTime();
}
- setCurrentActivatedField(val:DateKeys):void {
+ setCurrentActivatedField(val:DateFields):void {
this.currentlyActivatedDateField = val;
}
@@ -197,7 +200,7 @@ export class DatepickerModalService {
this.currentlyActivatedDateField = this.currentlyActivatedDateField === 'start' ? 'end' : 'start';
}
- isStateOfCurrentActivatedField(val:DateKeys):boolean {
+ isStateOfCurrentActivatedField(val:DateFields):boolean {
return this.currentlyActivatedDateField === val;
}
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
index f80c559ef8f..195e43b7f9a 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
@@ -63,6 +63,7 @@ import {
} from 'rxjs';
export type DateKeys = 'date'|'start'|'end';
+export type DateFields = DateKeys|'duration';
@Component({
templateUrl: './datepicker.modal.html',
@@ -272,15 +273,17 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
return this.scheduleManually || !this.datepickerService.isParent;
}
- showFieldAsActive(field:DateKeys):boolean {
+ showFieldAsActive(field:DateFields):boolean {
return this.datepickerService.isStateOfCurrentActivatedField(field) && this.isSchedulable;
}
handleDurationFocusIn():void {
+ this.datepickerService.setCurrentActivatedField('duration');
this.formattedDuration = this.timezoneService.toDays(this.duration.toString()).toString();
}
handleDurationFocusOut():void {
+ this.datepickerService.setCurrentActivatedField('start');
this.formattedDuration = this.timezoneService.formattedDuration(this.duration.toString(), 'days');
}
@@ -386,7 +389,7 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
const newDates = this.datepickerService.isStateOfCurrentActivatedField('start') ? [selectedDate, parsedEndDate] : [parsedStartDate, selectedDate];
this.overwriteDatePickerWithNewDates(newDates);
}
- } else {
+ } else if (this.datepickerService.currentlyActivatedDateField !== 'duration') {
this.dates[this.datepickerService.currentlyActivatedDateField] = this.timezoneService.formattedISODate(selectedDate);
this.datepickerService.toggleCurrentActivatedField();
}
@@ -422,7 +425,7 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
this.onDataUpdated.emit(output);
}
- private initialActivatedField():DateKeys {
+ private initialActivatedField():DateFields {
return this.locals.fieldName === 'dueDate' ? 'end' : 'start';
}