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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[61894] Fix disappearing fields in date picker when in automatic mode
Christophe Bliardf9f603c189f8
diff --git a/app/components/work_packages/date_picker/form_content_component.rb b/app/components/work_packages/date_picker/form_content_component.rbindex eb24e462622..8257c66e402 100644--- a/app/components/work_packages/date_picker/form_content_component.rb+++ b/app/components/work_packages/date_picker/form_content_component.rb@@ -69,11 +69,11 @@ module WorkPackagesdef milestone?# Either the work package is a milestone OR in the create form, the angular 'date' field was triggered OR# in the WorkPackage create form, the datepicker dialog was already updated via Turbo- # in which case the field param is overwritten and we have to check whether there is a due date field+ # in which case the field param is overwritten and we have to check whether the duration field is absent@milestone ||=@work_package.milestone? ||params[:field] == "date" ||- (params[:work_package].present? && params[:work_package][:due_date].nil?)+ (params[:work_package].present? && params[:work_package][:duration].nil?)enddef disabled_checkbox?diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rbindex 467e9d39820..762bddf5f9c 100644--- a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb@@ -994,6 +994,53 @@ RSpec.describe "Datepicker modal logic test cases (WP #43539)", :js, with_settinendend+ context "when setting 'Duration' and 'Working days only' of an automatically scheduled work package" do+ let(:work_package) do+ bug_wp.tap do |wp|+ # add a predecessor so that automatic scheduling mode can be selected and date picker is visible.+ predecessor = milestone_wp+ milestone_wp.update!(+ start_date: "2022-06-17",+ due_date: "2022-06-19",+ duration: 4,+ ignore_non_working_days: true+ )+ create(:follows_relation, to: predecessor, from: wp)+ end+ end+ let(:current_attributes) do+ {+ start_date: "2022-06-20",+ due_date: "2022-06-21",+ duration: 2,+ schedule_manually: false+ }+ end++ it "updates the finish date, instead of disappearing (Regression #61894)" do+ datepicker.expect_automatic_scheduling_mode+ datepicker.expect_due_date "2022-06-21", disabled: true+ datepicker.expect_duration 2+ datepicker.expect_working_days_only true++ datepicker.set_duration 6++ # start date is 20 and Saturday and Sunday are non-working days, so finish date is 27+ datepicker.expect_due_date "2022-06-27", disabled: true++ datepicker.uncheck_working_days_only++ # start date is 20, non-working days are ignored so finish date is 25+ datepicker.expect_due_date "2022-06-25", disabled: true++ apply_and_expect_saved start_date: Date.parse("2022-06-20"),+ due_date: Date.parse("2022-06-25"),+ duration: 6,+ ignore_non_working_days: true,+ schedule_manually: false+ end+ end+context "when setting start and due date through today links" dolet(:current_attributes) do{diff --git a/spec/support/components/datepicker/work_package_datepicker.rb b/spec/support/components/datepicker/work_package_datepicker.rbindex 295e6f15e9d..39b2e161c5d 100644--- a/spec/support/components/datepicker/work_package_datepicker.rb+++ b/spec/support/components/datepicker/work_package_datepicker.rb@@ -158,6 +158,10 @@ module Componentsfind("label", text: "Working days only").clickend+ def uncheck_working_days_only+ page.find(:checkbox, "Working days only").uncheck+ end+def clear_durationset_duration("")end