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

Only change the focus when the triggered field was the combinedField. Otherwise we respect the users choice

Henriette Darge810a9832b1dc
diff --git a/app/components/work_packages/date_picker/dialog_content_component.rb b/app/components/work_packages/date_picker/dialog_content_component.rb
index bfed9196319..a292e5fb286 100644
--- a/app/components/work_packages/date_picker/dialog_content_component.rb
+++ b/app/components/work_packages/date_picker/dialog_content_component.rb
@@ -86,6 +86,7 @@ module WorkPackages
def show_banner?
@schedule_manually || has_relations?
end
+
def has_relations?
precedes_relations.any? || follows_relations.any? || children.any?
end
diff --git a/app/components/work_packages/date_picker/form_content_component.rb b/app/components/work_packages/date_picker/form_content_component.rb
index 7406e021682..33130183020 100644
--- a/app/components/work_packages/date_picker/form_content_component.rb
+++ b/app/components/work_packages/date_picker/form_content_component.rb
@@ -48,7 +48,7 @@ module WorkPackages
@show_date_form = show_date_form
@work_package = work_package
@schedule_manually = ActiveModel::Type::Boolean.new.cast(schedule_manually)
- @focused_field = parse_focused_field(focused_field)
+ @focused_field = focused_field
@touched_field_map = touched_field_map
end
@@ -79,10 +79,6 @@ module WorkPackages
def disabled_checkbox?
!schedule_manually && work_package.children.any?
end
-
- def parse_focused_field(focused_field)
- %i[start_date due_date duration].include?(focused_field) ? focused_field : :start_date
- end
end
end
end
diff --git a/app/forms/work_packages/date_picker/date_form.rb b/app/forms/work_packages/date_picker/date_form.rb
index e69e8846b97..14a9a524ee4 100644
--- a/app/forms/work_packages/date_picker/date_form.rb
+++ b/app/forms/work_packages/date_picker/date_form.rb
@@ -61,7 +61,7 @@ module WorkPackages
@work_package = work_package
@schedule_manually = schedule_manually
@is_milestone = is_milestone
- @focused_field = update_focused_field
+ @focused_field = update_focused_field(focused_field)
@touched_field_map = touched_field_map
@disabled = disabled
end
@@ -145,19 +145,22 @@ module WorkPackages
name == :duration
end
- def update_focused_field
- return @focused_field if @focused_field == :duration
+ def update_focused_field(focused_field)
+ return :start_date if focused_field.nil?
- if @focused_field.nil?
- @focused_field = :start_date
- end
-
- opposite_field = @focused_field == :start_date ? :due_date : :start_date
-
- if field_value(@focused_field).present? && field_value(opposite_field).nil?
- opposite_field
+ case focused_field.to_s.underscore
+ when "combined_date"
+ if field_value(:start_date).present? && field_value(:due_date).nil?
+ :due_date
+ else
+ :start_date
+ end
+ when "due_date"
+ :due_date
+ when "duration"
+ :duration
else
- @focused_field
+ :start_date
end
end
diff --git a/app/views/work_packages/date_picker/show.html.erb b/app/views/work_packages/date_picker/show.html.erb
index 9863110334b..a8198c36dbe 100644
--- a/app/views/work_packages/date_picker/show.html.erb
+++ b/app/views/work_packages/date_picker/show.html.erb
@@ -1 +1 @@
-<%= render(WorkPackages::DatePicker::DialogContentComponent.new(work_package:, schedule_manually:))%>
+<%= render(WorkPackages::DatePicker::DialogContentComponent.new(work_package:, schedule_manually:, focused_field: params[:field]))%>