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

Please rubocop and fix last check for showing the text field in single date mode

Henriette Darge5e46f9b582cd
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 f7d1bbc3895..63959f4e8d1 100644
--- a/app/components/work_packages/date_picker/date_form_component.rb
+++ b/app/components/work_packages/date_picker/date_form_component.rb
@@ -63,12 +63,9 @@ module WorkPackages
def show_text_field?(name)
return true if @is_milestone || !@schedule_manually
- return true if @date_mode.present? && @date_mode == "range"
- return true if field_value(name).present? || @touched_field_map["#{name}_touched"]
+ return true if range_date_mode?
- return true if name == :due_date && field_value(:start_date).nil?
-
- name == :due_date && @touched_field_map["start_date_touched"].present? && !@touched_field_map["start_date_touched"]
+ show_text_field_in_single_date_mode?(name)
end
def text_field_options(name:, label:)
@@ -194,6 +191,28 @@ module WorkPackages
work_package_datepicker_dialog_content_path(permitted_params)
end
end
+
+ def range_date_mode?
+ @date_mode.present? && @date_mode == "range"
+ end
+
+ def field_value_present_or_touched?(name)
+ field_value(name).present? || @touched_field_map["#{name}_touched"]
+ end
+
+ def show_text_field_in_single_date_mode?(name)
+ return true if field_value_present_or_touched?(name)
+
+ # Start date is only shown in the assertion above
+ return false if name != :due_date
+
+ # This handles the edge case, that the datepicker starts in single date mode, with the due date being hidden.
+ # Normally, the start date is the hidden one, except if only a start date is set.
+ # In case we delete the start date, we have to ensure that the datepicker does not switch the fields
+ # and suddenly hides the start date. That is why we check for the touched value.
+ true if field_value(:start_date).nil? &&
+ (@touched_field_map["start_date_touched"] == false || @touched_field_map["start_date_touched"].nil?)
+ end
end
end
end
diff --git a/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
index 065d339d6bb..105e9593d03 100644
--- a/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
@@ -658,6 +658,7 @@ RSpec.describe "Datepicker: Single-date mode logic test cases (WP #61146)", :js,
datepicker.set_due_date ""
wait_for_network_idle
datepicker.set_start_date ""
+ wait_for_network_idle
datepicker.expect_start_date ""
datepicker.expect_due_date ""
@@ -682,6 +683,7 @@ RSpec.describe "Datepicker: Single-date mode logic test cases (WP #61146)", :js,
datepicker.set_start_date ""
wait_for_network_idle
datepicker.set_due_date ""
+ wait_for_network_idle
datepicker.expect_start_date ""
datepicker.expect_due_date ""