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

Focus the correct field in single date mode when both fields are empty

Henriette Darge2d4a8bf8bdfc
diff --git a/app/components/work_packages/date_picker/date_form_component.rb b/app/components/work_packages/date_picker/date_form_component.rb
index 3471c9b3a28..763a4c70b6d 100644
--- a/app/components/work_packages/date_picker/date_form_component.rb
+++ b/app/components/work_packages/date_picker/date_form_component.rb
@@ -110,13 +110,7 @@ module WorkPackages
def update_focused_field(focused_field)
if @date_mode.nil? || @date_mode != "range"
- if focused_field == "duration"
- return :duration
- elsif field_value(:due_date).present? && field_value(:start_date).nil?
- return :due_date
- elsif field_value(:start_date).present? && field_value(:due_date).nil?
- return :start_date
- end
+ return focused_field_for_single_date_mode(focused_field)
end
date_fields = {
@@ -129,6 +123,16 @@ module WorkPackages
date_fields.fetch(focused_field.to_s.underscore, :start_date)
end
+ def focused_field_for_single_date_mode(focused_field)
+ if focused_field == "duration"
+ :duration
+ elsif field_value(:start_date).nil?
+ :due_date
+ elsif field_value(:due_date).nil?
+ :start_date
+ end
+ end
+
def disabled?(name)
if name == :duration
if !@schedule_manually && @work_package.children.any?
diff --git a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
index 55ef8c2f864..3d538b97855 100644
--- a/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/wp-modal-date-picker/wp-modal-date-picker.component.ts
@@ -142,8 +142,8 @@ export class OpWpModalDatePickerComponent extends UntilDestroyedMixin implements
private isDifferentDates(dates:Date[], mode:DateMode):boolean {
const [start, end] = dates;
return mode === 'single'
- ? start.getTime() !== this.startDateValue?.getTime()
- : start.getTime() !== this.startDateValue?.getTime() || end?.getTime() !== this.dueDateValue?.getTime();
+ ? start?.getTime() !== this.startDateValue?.getTime()
+ : start?.getTime() !== this.startDateValue?.getTime() || end?.getTime() !== this.dueDateValue?.getTime();
}
private toDate(date:string|null):Date|null {